Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(platform-browser): only append style element on creation #52237

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/platform-browser/src/dom/shared_styles_host.ts
Expand Up @@ -139,6 +139,7 @@ export class SharedStylesHost implements OnDestroy {
if (existingStyleElement) {
return existingStyleElement;
}

const styleNodesInDOM = this.styleNodesInDOM;
const styleEl = styleNodesInDOM?.get(style);
if (styleEl?.parentNode === host) {
Expand Down Expand Up @@ -166,6 +167,8 @@ export class SharedStylesHost implements OnDestroy {
styleEl.setAttribute(APP_ID_ATTRIBUTE_NAME, this.appId);
}

host.appendChild(styleEl);

return styleEl;
}
}
Expand All @@ -175,8 +178,6 @@ export class SharedStylesHost implements OnDestroy {
const styleResult = styleRef.get(style)!; // This will always be defined in `changeUsageCount`
const styleEl = this.getStyleElement(host, style, styleResult.elements);

host.appendChild(styleEl);

if (styleResult.usage === 0) {
disableStylesheet(styleEl);
} else {
Expand Down