Skip to content

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

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

Copy link
Copy Markdown
Contributor

PR Checklist

PR Type

  • Bugfix

@pullapprove
pullapprove Bot requested review from crisbeto and mhevery February 25, 2021 21:02
@google-cla google-cla Bot added the cla: yes label Feb 25, 2021
@arturovt

Copy link
Copy Markdown
Contributor Author

This is a replacement of this PR (#39982).

@atscott cc. There were some presubmit failures, but you mentioned in that comment that you manually fixed some issues (#39982 (comment)). Could you try to re-run the presubmit?

@atscott

atscott commented Feb 25, 2021

Copy link
Copy Markdown
Contributor

triggered global tests to see what still needs to be fixed (if any).

@zarend zarend added the area: animations legacy animations package only. Otherwise use area: core. label Feb 26, 2021
@ngbot ngbot Bot added this to the Backlog milestone Feb 26, 2021
@atscott

atscott commented Mar 1, 2021

Copy link
Copy Markdown
Contributor

Global tests are all green. This should be good to go now 👍

@atscott atscott added action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release labels Mar 1, 2021
@ngbot

ngbot Bot commented Mar 1, 2021

Copy link
Copy Markdown

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "google3" is failing
    pending missing required labels: target: *
    pending status "pullapprove" is pending
    pending 2 pending code reviews

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@arturovt

arturovt commented Mar 1, 2021

Copy link
Copy Markdown
Contributor Author

@atscott oh great 👍

Well, I see the Presubmit Failed 😄

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. It
is 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 1, 2021

Copy link
Copy Markdown
Contributor

@atscott oh great 👍

Well, I see the Presubmit Failed 😄

There were some unrelated failures. I just need to force it green :)

@crisbeto crisbeto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@atscott

atscott commented Mar 2, 2021 •

Copy link
Copy Markdown
Contributor

After a bit more investigation, the failure was legitimate - the SSR code was configured to destroy the platform (internal link to the code) before returning the generated HTML which resulted in the Angular elements being cleaned up as well. I missed this in the global tests because I hadn't configured them to run with Ivy enabled.
We'll have to re-open this PR, rerun the tests, and evaluate what this change means for SSR clients -- it could be quite a bit more breaking than anticipated if others have their server rendering set up in a similar way.

This was referenced Mar 15, 2021
@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 2, 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. breaking changes cla: yes target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants