Skip to content

Commit

Permalink
perf(platform-browser): do not remove renderer from cache when `REMOV…
Browse files Browse the repository at this point in the history
…E_STYLES_ON_COMPONENT_DESTROY` is enabled. (#51005)

Removing the renderer from cache is not needed when `REMOVE_STYLES_ON_COMPONENT_DESTROY` is enabled. This change retains the behaviour of keeping the renderer cached for the entire lifecycle of the application the same way it is done when `REMOVE_STYLES_ON_COMPONENT_DESTROY` is disabled.

This seems to have be causing an increase in scripting. See: http://b/290666638

PR Close #51005
  • Loading branch information
alan-agius4 authored and dylhunn committed Jul 11, 2023
1 parent a4b0d29 commit 31419f6
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions packages/platform-browser/src/dom/dom_renderer.ts
Expand Up @@ -132,7 +132,6 @@ export class DomRendererFactory2 implements RendererFactory2, OnDestroy {
break;
}

renderer.onDestroy = () => rendererByCompId.delete(type.id);
rendererByCompId.set(type.id, renderer);
}

Expand Down Expand Up @@ -397,8 +396,6 @@ class ShadowDomRenderer extends DefaultDomRenderer2 {

class NoneEncapsulationDomRenderer extends DefaultDomRenderer2 {
private readonly styles: string[];
private rendererUsageCount = 0;
onDestroy: VoidFunction|undefined;

constructor(
eventManager: EventManager,
Expand All @@ -416,7 +413,6 @@ class NoneEncapsulationDomRenderer extends DefaultDomRenderer2 {

applyStyles(): void {
this.sharedStylesHost.addStyles(this.styles);
this.rendererUsageCount++;
}

override destroy(): void {
Expand All @@ -425,10 +421,6 @@ class NoneEncapsulationDomRenderer extends DefaultDomRenderer2 {
}

this.sharedStylesHost.removeStyles(this.styles);
this.rendererUsageCount--;
if (this.rendererUsageCount === 0) {
this.onDestroy?.();
}
}
}

Expand Down

0 comments on commit 31419f6

Please sign in to comment.