Skip to content

DOM elements are not removed when the root view is removedΒ #39955

@arturovt

Description

@arturovt

🐞 bug report

Affected Package

The issue is caused by package @angular/animations (probably)

Is this a regression?

I cannot say

Description

All DOM elements remain when calling NgModuleRef.destroy(), but actually, all ngOnDestroy hooks are invoked, event listeners are removed, basically, all cleanups are done except removing nodes from DOM.

⚠️ This happens only when the BrowserAnimationsModule is imported, this doesn't happen with BrowserModule.

πŸ”¬ Minimal Reproduction

$ git clone git@github.com:arturovt/ngmoduleref-destroy-issue.git
$ cd ngmoduleref-destroy-issue
$ yarn
  1. Start dev server yarn ng s
  2. Go to http://localhost:4200, open dev tools, click the "Destroy" button. Notice logs in the console
  3. Notice that DOM elements are NOT removed

🌍 Your Environment

Angular Version:


Angular CLI: 11.0.3
Node: 12.20.0
OS: linux x64

Angular: 11.0.3
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1100.3
@angular-devkit/build-angular   0.1100.3
@angular-devkit/core            11.0.3
@angular-devkit/schematics      11.0.3
@schematics/angular             11.0.3
@schematics/update              0.1100.3
rxjs                            6.6.3
typescript                      4.0.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: animationscore: DOM renderingmemory leakIssue related to a memory leakstate: has PR

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions