Skip to content

fix(animations): cleanup DOM elements when the root view is removed - #41059

Closed
arturovt wants to merge 1 commit into
angular:masterfrom
arturovt:fix/39955
Closed

arturovt wants to merge 1 commit into
angular:masterfrom
arturovt:fix/39955

Conversation

@arturovt

@arturovt arturovt commented Mar 2, 2021

Copy link
Copy Markdown
Contributor

PR Checklist

PR Type

  • Bugfix

@google-cla google-cla Bot added the cla: yes label Mar 2, 2021
@pullapprove
pullapprove Bot requested review from alxhub and jelbourn March 2, 2021 23:42
@arturovt

arturovt commented Mar 2, 2021

Copy link
Copy Markdown
Contributor Author

@atscott re-opened the PR as was asked here #41001 (comment)

@zarend zarend added the area: animations legacy animations package only. Otherwise use area: core. label Mar 3, 2021
@ngbot ngbot Bot added this to the Backlog milestone Mar 3, 2021
@atscott atscott added the action: presubmit The PR is in need of a google3 presubmit label Mar 18, 2021
Currently, when importing `BrowserAnimationsModule`, Angular uses `AnimationRenderer`
as the renderer. When the root view is removed, the `AnimationRenderer` defers the actual
work to the `TransitionAnimationEngine` to do this, and the `TransitionAnimationEngine`
doesn't actually remove the DOM node, but just calls `markElementAsRemoved()`.

The actual DOM node is not removed until `TransitionAnimationEngine` "flushes".

Unfortunately, though, that "flush" will never happen, since the root view is being
destroyed and there will be no more flushes.

This commit adds `flush()` call when the root view is being destroyed.

BREAKING CHANGE:
DOM elements are now correctly removed when the root view is removed.
If you are using SSR and use the app's HTML for rendering, you will need
to ensure that you save the HTML to a variable before destorying the
app.
It is also possible that tests could be accidentally relying on the old behavior by
trying to find an element that was not removed in a previous test. If
this is the case, the failing tests should be updated to ensure they
have proper setup code which initializes elements they rely on.
@atscott

atscott commented Mar 19, 2021

Copy link
Copy Markdown
Contributor

global presubmit

caretaker note: Please merge and sync this on its own.
Also caretaker note: This is a resubmit of #41001 which had all approvals.

@atscott atscott added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: major This PR is targeted for the next major release and removed action: presubmit The PR is in need of a google3 presubmit labels Mar 19, 2021
@mhevery mhevery closed this in c49b280 Mar 22, 2021
@arturovt
arturovt deleted the fix/39955 branch March 23, 2021 05:41
TeriGlover pushed a commit to TeriGlover/angular that referenced this pull request Apr 5, 2021
…ngular#41059)

Currently, when importing `BrowserAnimationsModule`, Angular uses `AnimationRenderer`
as the renderer. When the root view is removed, the `AnimationRenderer` defers the actual
work to the `TransitionAnimationEngine` to do this, and the `TransitionAnimationEngine`
doesn't actually remove the DOM node, but just calls `markElementAsRemoved()`.

The actual DOM node is not removed until `TransitionAnimationEngine` "flushes".

Unfortunately, though, that "flush" will never happen, since the root view is being
destroyed and there will be no more flushes.

This commit adds `flush()` call when the root view is being destroyed.

BREAKING CHANGE:
DOM elements are now correctly removed when the root view is removed.
If you are using SSR and use the app's HTML for rendering, you will need
to ensure that you save the HTML to a variable before destorying the
app.
It is also possible that tests could be accidentally relying on the old behavior by
trying to find an element that was not removed in a previous test. If
this is the case, the failing tests should be updated to ensure they
have proper setup code which initializes elements they rely on.

PR Close angular#41059
@angular-automatic-lock-bot

Copy link
Copy Markdown

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.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Apr 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: animations legacy animations package only. Otherwise use area: core. cla: yes merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants