Skip to content

[css-transitions-1] Clarify/confirm behavior when reparenting a transitioning element #3309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stephenmcgruer opened this issue Nov 9, 2018 · 4 comments
Labels
css-transitions-1 Current Work

Comments

@stephenmcgruer
Copy link
Contributor

What steps will reproduce the problem?
(1) Navigate to https://output.jsbin.com/celuzow/quiet
(2) Click start transition.
(3) Click reparent element during the transition.

In Chrome, Firefox and Safari, the transition is immediately finished. In Edge, the transition animation is continued after the element is reparented.

From the Chrome side we believe the immediate-finish behavior is correct; I just want to make sure that the spec backs this view, and add a WPT test if one doesn't already exist. One argument may be that it is covered by https://drafts.csswg.org/css-transitions/#starting :

If an element is no longer in the document, implementations must cancel any running transitions on it and remove transitions on it from the completed transitions.

Technically reparenting requires removing the element from its previous parent before setting the new parent. Whether that constitutes being 'no longer in the document' I'm not sure.

@tabatkins
Copy link
Member

The precise nature of the "slow transition" behavior isn't super-specified (tho Web Animations does some nice work in reifying the transition into an explicit Animation object), but I agree with you that Chrome/Firefox/Safari's behavior is the desirable one.

Basically, moving an element in the tree should clear all style-related information about it; as far as CSS is concerned, the old element simply evaporated into thin air and a brand new element appeared somewhere else. Thus, just as transitions are canceled when the property they're associated with gets changed again, transitions should simply be dropped when their associated element disappears. This is the same behavior you'd get from flickering it to display:none and back.

Whether a move is technically a "remove, then insert" (I think it is for other purposes?), it should be treated the same for transition-canceling purposes.

@birtles birtles added the css-transitions-1 Current Work label Nov 10, 2018
@birtles
Copy link
Contributor

birtles commented Nov 10, 2018

I agree with that interpretation but would it help to explicitly call that out somehow? If so, I'm not sure if that should happen by referencing so generic CSS machinery, or by just extending that sentence with some appropriate DOM vocabulary to the effect of, "If an element is no longer in the document or is assigned a different parent node...".

Once we have that, we can more easily add a WPT for this.

@Loirooriol
Copy link
Contributor

If an element is no longer in the document or is assigned a different parent node...

Firefox and Chromium finish the transition even if the parent node is the same, and even if the node ends up at the same place (e.g. if you use appendChild but the node is already the last child).

I guess the relevant step is https://dom.spec.whatwg.org/#concept-node-adopt

  1. If node’s parent is not null, remove node from its parent.

So the element is temporarily 'no longer in the document', even if it's inserted back into the document immediately after.

@stephenmcgruer
Copy link
Contributor Author

Given that that wording exists in the DOM spec, I propose I add a css-transition/ WPT test (or tests) to ensure this behavior and we don't adjust the css-transitions-1 spec. I am open to opposing opinions :).

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Dec 12, 2018
As per w3c/csswg-drafts#3309, any CSS
Transition on a reparented element should be cancelled, as it leaves and
then re-enters the Document. This already works on Chrome, Firefox, and
Safari but fails on Edge.

Bug: 902328
Change-Id: I097675a8146c8047417dd48193d0747216418cfb
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Dec 13, 2018
As per w3c/csswg-drafts#3309, any CSS
Transition on a reparented element should be cancelled, as it leaves and
then re-enters the Document. This already works on Chrome, Firefox, and
Safari but fails on Edge.

Bug: 902328
Change-Id: I097675a8146c8047417dd48193d0747216418cfb
aarongable pushed a commit to chromium/chromium that referenced this issue Dec 14, 2018
As per w3c/csswg-drafts#3309, any CSS
Transition on a reparented element should be cancelled, as it leaves and
then re-enters the Document. This already works on Chrome, Firefox, and
Safari but fails on Edge.

Bug: 902328
Change-Id: I097675a8146c8047417dd48193d0747216418cfb
Reviewed-on: https://chromium-review.googlesource.com/c/1374742
Reviewed-by: vmpstr <vmpstr@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616830}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Dec 14, 2018
As per w3c/csswg-drafts#3309, any CSS
Transition on a reparented element should be cancelled, as it leaves and
then re-enters the Document. This already works on Chrome, Firefox, and
Safari but fails on Edge.

Bug: 902328
Change-Id: I097675a8146c8047417dd48193d0747216418cfb
Reviewed-on: https://chromium-review.googlesource.com/c/1374742
Reviewed-by: vmpstr <vmpstr@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616830}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Dec 14, 2018
As per w3c/csswg-drafts#3309, any CSS
Transition on a reparented element should be cancelled, as it leaves and
then re-enters the Document. This already works on Chrome, Firefox, and
Safari but fails on Edge.

Bug: 902328
Change-Id: I097675a8146c8047417dd48193d0747216418cfb
Reviewed-on: https://chromium-review.googlesource.com/c/1374742
Reviewed-by: vmpstr <vmpstr@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616830}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Jan 23, 2019
…ng, a=testonly

Automatic update from web-platform-tests
[CSS Transitions] Add test for reparenting

As per w3c/csswg-drafts#3309, any CSS
Transition on a reparented element should be cancelled, as it leaves and
then re-enters the Document. This already works on Chrome, Firefox, and
Safari but fails on Edge.

Bug: 902328
Change-Id: I097675a8146c8047417dd48193d0747216418cfb
Reviewed-on: https://chromium-review.googlesource.com/c/1374742
Reviewed-by: vmpstr <vmpstr@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616830}

--

wpt-commits: cf8b055289c68215fd4a3274c94d0f5484c27dd3
wpt-pr: 14486
mykmelez pushed a commit to mykmelez/gecko that referenced this issue Jan 23, 2019
…ng, a=testonly

Automatic update from web-platform-tests
[CSS Transitions] Add test for reparenting

As per w3c/csswg-drafts#3309, any CSS
Transition on a reparented element should be cancelled, as it leaves and
then re-enters the Document. This already works on Chrome, Firefox, and
Safari but fails on Edge.

Bug: 902328
Change-Id: I097675a8146c8047417dd48193d0747216418cfb
Reviewed-on: https://chromium-review.googlesource.com/c/1374742
Reviewed-by: vmpstr <vmpstr@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616830}

--

wpt-commits: cf8b055289c68215fd4a3274c94d0f5484c27dd3
wpt-pr: 14486
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Oct 3, 2019
…ng, a=testonly

Automatic update from web-platform-tests
[CSS Transitions] Add test for reparenting

As per w3c/csswg-drafts#3309, any CSS
Transition on a reparented element should be cancelled, as it leaves and
then re-enters the Document. This already works on Chrome, Firefox, and
Safari but fails on Edge.

Bug: 902328
Change-Id: I097675a8146c8047417dd48193d0747216418cfb
Reviewed-on: https://chromium-review.googlesource.com/c/1374742
Reviewed-by: vmpstr <vmpstrchromium.org>
Commit-Queue: Stephen McGruer <smcgruerchromium.org>
Cr-Commit-Position: refs/heads/master{#616830}

--

wpt-commits: cf8b055289c68215fd4a3274c94d0f5484c27dd3
wpt-pr: 14486

UltraBlame original commit: 86ca0a729bfcfa8a0d8c0e223fd6285b682bb600
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Oct 3, 2019
…ng, a=testonly

Automatic update from web-platform-tests
[CSS Transitions] Add test for reparenting

As per w3c/csswg-drafts#3309, any CSS
Transition on a reparented element should be cancelled, as it leaves and
then re-enters the Document. This already works on Chrome, Firefox, and
Safari but fails on Edge.

Bug: 902328
Change-Id: I097675a8146c8047417dd48193d0747216418cfb
Reviewed-on: https://chromium-review.googlesource.com/c/1374742
Reviewed-by: vmpstr <vmpstrchromium.org>
Commit-Queue: Stephen McGruer <smcgruerchromium.org>
Cr-Commit-Position: refs/heads/master{#616830}

--

wpt-commits: cf8b055289c68215fd4a3274c94d0f5484c27dd3
wpt-pr: 14486

UltraBlame original commit: 86ca0a729bfcfa8a0d8c0e223fd6285b682bb600
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Oct 3, 2019
…ng, a=testonly

Automatic update from web-platform-tests
[CSS Transitions] Add test for reparenting

As per w3c/csswg-drafts#3309, any CSS
Transition on a reparented element should be cancelled, as it leaves and
then re-enters the Document. This already works on Chrome, Firefox, and
Safari but fails on Edge.

Bug: 902328
Change-Id: I097675a8146c8047417dd48193d0747216418cfb
Reviewed-on: https://chromium-review.googlesource.com/c/1374742
Reviewed-by: vmpstr <vmpstrchromium.org>
Commit-Queue: Stephen McGruer <smcgruerchromium.org>
Cr-Commit-Position: refs/heads/master{#616830}

--

wpt-commits: cf8b055289c68215fd4a3274c94d0f5484c27dd3
wpt-pr: 14486

UltraBlame original commit: 86ca0a729bfcfa8a0d8c0e223fd6285b682bb600
bhearsum pushed a commit to mozilla-releng/staging-firefox that referenced this issue May 1, 2025
…ng, a=testonly

Automatic update from web-platform-tests
[CSS Transitions] Add test for reparenting

As per w3c/csswg-drafts#3309, any CSS
Transition on a reparented element should be cancelled, as it leaves and
then re-enters the Document. This already works on Chrome, Firefox, and
Safari but fails on Edge.

Bug: 902328
Change-Id: I097675a8146c8047417dd48193d0747216418cfb
Reviewed-on: https://chromium-review.googlesource.com/c/1374742
Reviewed-by: vmpstr <vmpstr@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616830}

--

wpt-commits: cf8b055289c68215fd4a3274c94d0f5484c27dd3
wpt-pr: 14486
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-transitions-1 Current Work
Projects
None yet
Development

No branches or pull requests

4 participants