Skip to content

Commit 41740e3

Browse files
authored
[css-view-transitions-2] Skip only a duplicate element instead of the whole transition (#13858)
* [css-view-transitions-2] Skip only a duplicate element instead of the whole transition Closes #13438 * Add console.warn note
1 parent 7fa0d2f commit 41740e3

1 file changed

Lines changed: 13 additions & 17 deletions

File tree

css-view-transitions-2/Overview.bs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,7 @@ spec:css2; type:dfn; text:viewport
553553
and the transition is initiated.
554554

555555
Note that {{ViewTransitionUpdateCallback|updateCallback}}, if provided, is *always* called,
556-
even if the transition cannot happen
557-
(e.g. due to duplicate `view-transition-name` values).
556+
even if the transition cannot happen.
558557
The transition is an enhancement around the state change, so a failure to create a transition never prevents the state change.
559558
See [[#transitions-as-enhancements]] for more details on this principle.
560559

@@ -609,8 +608,7 @@ Note: An <code>element.startViewTransition()</code> call does not update
609608
and the transition is initiated.
610609

611610
Note that {{ViewTransitionUpdateCallback|updateCallback}}, if provided, is *always* called,
612-
even if the transition cannot happen
613-
(e.g. due to duplicate `view-transition-name` values).
611+
even if the transition cannot happen.
614612
The transition is an enhancement around the state change, so a failure to create a transition never prevents the state change.
615613
See [[#transitions-as-enhancements]] for more details on this principle.
616614

@@ -716,8 +714,7 @@ the active view transition of an element is exposed to script via a property on
716714
and the animation is about to start.
717715

718716
It rejects if the transition cannot begin.
719-
This can be due to misconfiguration, such as duplicate 'view-transition-name's,
720-
or if {{ViewTransition/updateCallbackDone}} returns a rejected promise.
717+
This can be due to misconfiguration, e.g. if {{ViewTransition/updateCallbackDone}} returns a rejected promise.
721718

722719
The point that {{ViewTransition/ready}} fulfills
723720
is the ideal opportunity to animate the [=view transition pseudo-elements=]
@@ -2348,6 +2345,9 @@ A 'view-transition-name' generated by <css>auto</css> is a [=tree-scoped name=].
23482345

23492346
: <dfn for="captured element">old border width</dfn>
23502347
:: 'border-width' [=used value=] (top, right, bottom and left pixel values) or null, initially null.
2348+
2349+
: <dfn for="captured element">duplicate</dfn>
2350+
:: A boolean, initiallly false.
23512351
</dl>
23522352

23532353
In addition, a [=captured element=] has the following <dfn for="captured element">style definitions</dfn>:
@@ -2483,6 +2483,10 @@ It has the following [=struct/items=]:
24832483
If failure is returned, then [=skip the view transition|skip=] |transition| with an "{{InvalidStateError}}" {{DOMException}} in |transition|'s [=relevant Realm=],
24842484
and return.
24852485

2486+
1. [=list/Remove=] from |transition|'s [=ViewTransition/named elements=] every entry whose value's [=captured element/duplicate=] is true.
2487+
2488+
Note: User agents are encouraged to alert the developer that the duplicate was removed, e.g. via a console warning.
2489+
24862490
1. [=list/For each=] |capturedElement| of |transition|'s [=ViewTransition/named elements=]' [=map/values=]:
24872491

24882492
1. If |capturedElement|'s [=captured element/new element=] is not null,
@@ -2512,8 +2516,6 @@ It has the following [=struct/items=]:
25122516

25132517
1. Let |namedElements| be |transition|'s [=ViewTransition/named elements=].
25142518

2515-
1. Let |usedTransitionNames| be a new [=/set=] of strings.
2516-
25172519
1. Let |captureElements| be a new [=/list=] of elements.
25182520

25192521
1. If the [=snapshot containing block size=] exceeds an [=implementation-defined=] maximum, then return failure.
@@ -2548,22 +2550,14 @@ It has the following [=struct/items=]:
25482550
or |element| is [=element-not-rendered|not rendered=],
25492551
then [=continue=].
25502552

2551-
1. If |usedTransitionNames| [=list/contains=] |transitionName|, then:
2552-
2553-
1. [=list/For each=] |element| in |captureElements|:
2554-
2555-
1. Set |element|'s [=captured in a view transition=] to false.
2556-
2557-
1. Return failure.
2553+
1. If |namedElements|[|transitionName|] exists, then set |namedElements|[|transitionName|]'s [=captured element/duplicate=] to true and [=continue=].
25582554

25592555
1. If <em>any other</em> [=active view transition=] contains |element|
25602556
in its [=captured elements=],
25612557
then for each such [=active view transition=],
25622558
in [=tree order=] of their corresponding [=ViewTransition/root elements=],
25632559
[=skip the view transition|skip=] that view transition with an "{{AbortError}}" {{DOMException}} in |document|’s [=relevant Realm=].
25642560

2565-
1. [=set/Append=] |transitionName| to |usedTransitionNames|.
2566-
25672561
1. Set |element|'s [=captured in a view transition=] to true.
25682562

25692563
1. [=list/Append=] |element| to |captureElements|.
@@ -2646,6 +2640,8 @@ It has the following [=struct/items=]:
26462640
This implies than names which only exist in the new DOM (entry animations) will be painted on top of names only in the old DOM (exit animations) and names in both DOMs (paired animations).
26472641
This might not be the right layering for all cases. See <a href="https://github.com/w3c/csswg-drafts/issues/8941">issue 8941</a>.
26482642

2643+
1. If |namedElements|[|transitionName|]'s [=new element=] is not null, then set |namedElements|[|transitionName|]'s [=captured element/duplicate=] to true.
2644+
26492645
1. Set |namedElements|[|transitionName|]'s [=new element=] to |element|.
26502646
</div>
26512647

0 commit comments

Comments
 (0)