Skip to content

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

Closed

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 [email protected]: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

Activity

  1. added
    area: animations
    on Dec 3, 2020
  2. modified the milestone: needsTriage on Dec 3, 2020
  3. added
    memory leak
    P3
    on Dec 9, 2020
  4. modified the milestones: needsTriage, Backlog on Dec 9, 2020
  5. arturovt commented on Mar 2, 2021

    @arturovt
    ContributorAuthor

    Fixed by #41001

  6. zarend commented on Mar 2, 2021

    @zarend
    Contributor

    Reverting this in #41056

  7. reopened this on Mar 2, 2021
  8. arturovt commented on Apr 2, 2021

    @arturovt
    ContributorAuthor

    Fixed by #41059

  9. angular-automatic-lock-bot commented on May 3, 2021

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  10. locked and limited conversation to collaborators on May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3area: animationscore: DOM renderingmemory leakstate: has PR

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions