From f6a3700b9c28adb9552912ddaaa3c440f1a1c80b Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Sun, 16 Mar 2025 20:37:10 +0000 Subject: [PATCH 1/2] [css-view-transitions-1] Flush the callback queue before performing other view-transition operations This ensures that a DOM update callback that skips the active transition would take effect. Closes #11943 --- css-view-transitions-1/Overview.bs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/css-view-transitions-1/Overview.bs b/css-view-transitions-1/Overview.bs index 7f584f5a570..131f51a8c68 100644 --- a/css-view-transitions-1/Overview.bs +++ b/css-view-transitions-1/Overview.bs @@ -1235,6 +1235,10 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface; To perform pending transition operations given a {{Document}} |document|, perform the following steps: + 1. [=Flush the update callback queue=]. + + Note: this ensures that any changes to the DOM scheduled by other skipped transitions are done before the old state for this transition is captured. + 1. If |document|'s [=document/active view transition=] is not null, then: 1. If |document|'s [=document/active view transition=]'s [=ViewTransition/phase=] is "`pending-capture`", @@ -1256,10 +1260,6 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface; 1. Let |document| be |transition|'s [=relevant global object's=] [=associated document=]. - 1. [=Flush the update callback queue=]. - - Note: this ensures that any changes to the DOM scheduled by other skipped transitions are done before the old state for this transition is captured. - 1. [=Capture the old state=] for |transition|. If failure is returned, then [=skip the view transition=] for |transition| with an "{{InvalidStateError}}" {{DOMException}} in |transition|'s [=relevant Realm=], From 188be52d9514af919e367d7ef3c9cc2090f9a25f Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Thu, 27 Mar 2025 17:22:24 +0000 Subject: [PATCH 2/2] Add note --- css-view-transitions-1/Overview.bs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/css-view-transitions-1/Overview.bs b/css-view-transitions-1/Overview.bs index 131f51a8c68..a0ced1a4cfc 100644 --- a/css-view-transitions-1/Overview.bs +++ b/css-view-transitions-1/Overview.bs @@ -1235,10 +1235,6 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface; To perform pending transition operations given a {{Document}} |document|, perform the following steps: - 1. [=Flush the update callback queue=]. - - Note: this ensures that any changes to the DOM scheduled by other skipped transitions are done before the old state for this transition is captured. - 1. If |document|'s [=document/active view transition=] is not null, then: 1. If |document|'s [=document/active view transition=]'s [=ViewTransition/phase=] is "`pending-capture`", @@ -1663,15 +1659,19 @@ urlPrefix: https://wicg.github.io/navigation-api/; type: interface; 1. [=list/Append=] |transition| to |transition|'s [=relevant settings object=]'s [=update callback queue=]. 1. [=Queue a global task=] on the [=DOM manipulation task source=], given |transition|'s [=relevant global object=], to [=flush the update callback queue=]. -
- To flush the update callback queue given a {{Document}} |document|: + To flush the update callback queue given a {{Document}} |document|: 1. [=list/For each=] |transition| in |document|'s [=update callback queue=], [=call the update callback=] given |transition|. 1. Set |document|'s [=update callback queue=] to an empty list.
+ Note: a scheduled update callback is guaranteed to be called before the next rendering steps, regardless of whether the + transition has succeeded or not. This is guaranteed by [=flush the update callback queue|flushing=] the queue in one of two situations: + the beginning of the rendering loop, or in a task that runs while [=document/rendering suppression for view transitions|rendering is supressed=]. + + ## [=Skip the view transition=] ## {#skip-the-view-transition-algorithm}