Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/ngx-fast-lib/src/lib/fast-svg.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ let element: HTMLElement = undefined as any;
function createGetImgFn(renderer: Renderer2): (src: string) => HTMLElement {
if (element === undefined) {
element = renderer.createElement('img');
element.setAttribute(
'style',
'display: none; contain: content; content-visibility: auto;'
);
// setAttribute('style', ...) is not allowed when strict CSP is in place.
element.style.display = 'none';
element.style.contain = 'content';
element.style.contentVisibility = 'auto';
element.setAttribute('loading', 'lazy');
element.setAttribute('alt', 'loading helper');
element.setAttribute('width', '0');
Expand Down
28 changes: 11 additions & 17 deletions packages/ngx-fast-lib/src/lib/svg-registry.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,17 @@ function createDomParser(document: Document): (s: string) => HTMLElement {
}

function styleDomCacheForPerformance(el: HTMLElement): HTMLElement {
/**
* reduce paint area with width/height 0 and overflow hidden
* fixed position of -2000px to always have it offscreen and outside any native trigger (viewport observer in content visibilities)
* contain:content to leverage css perf features for older browsers not supporting content-visibility * : auto to exclude it completely from styles recalculation
*/
el.setAttribute(
'style',
`
overflow: hidden;
width: 0px;
height: 0px;
position: fixed;
bottom: -2000px;
contain: content;
content-visibility: auto;
`
);
// reduce paint area with width/height 0 and overflow hidden
// fixed position of -2000px to always have it offscreen and outside any native trigger (viewport observer in content visibilities)
// contain:content to leverage css perf features for older browsers not supporting content-visibility * : auto to exclude it completely from styles recalculation
// setAttribute('style', ...) is not allowed when strict CSP is in place.
el.style.overflow = 'hidden';
el.style.width = '0px';
el.style.height = '0px';
el.style.position = 'fixed';
el.style.bottom = '-2000px';
el.style.contain = 'content';
el.style.contentVisibility = 'auto';
return el;
}

Expand Down