mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Currently style of components using `encapsulation`, `None` or `Emulated` will not be removed from the DOM once the component get destroyed.
This change addresses this by keeping track of the number of times a component is rendered, when the component is destroyed the counter is decreased and once this reaches zero the style element is removed from the DOM.
Currently, this new behaviour is on opt-in bases, but it will be changed in the next major version.
To opt-in, set the `REMOVE_STYLES_ON_COMPONENT_DESTROY` DI token to `true`.
Example
```ts
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule
],
providers: [
{ provide: REMOVE_STYLES_ON_COMPONENT_DESTROY, useValue: true }
],
bootstrap: [AppComponent]
})
export class AppModule { }
```
Closes #16670
PR Close #48298
|
||
|---|---|---|
| .. | ||
| browser | ||
| dom | ||
| security | ||
| static_assets | ||
| browser_util_spec.ts | ||
| BUILD.bazel | ||
| testing_public_spec.ts | ||