Skip to content

Navigation API: Don't run navigation handlers until entry is committed.#12256

Merged
zcorpan merged 2 commits intowhatwg:mainfrom
farre:issue/12222/1
Mar 20, 2026
Merged

Navigation API: Don't run navigation handlers until entry is committed.#12256
zcorpan merged 2 commits intowhatwg:mainfrom
farre:issue/12222/1

Conversation

@farre
Copy link
Copy Markdown
Contributor

@farre farre commented Mar 12, 2026

Currently per spec, #update-the-navigation-api-entries-for-a-same-document-navigation will be called in different order to the #wait-for-all navigation handler list depending on if the navigation is intercepted or not. This is not ideal, but even more so, in case of a "traverse" navigation, the callback passed to the #wait-for-all and the might be called before the call to #update-the-navigation-api-entries-for-a-same-document-navigation has happened.

This means that we'll run the finish steps with the wrong session history entry.

Since all same document navigations, intercepted or otherwise, eventually call #update-the-navigation-api-entries-for-a-same-document-navigation we can ensure that we never run the navigation handlers with bad state.

This patch also reverts the patch that introduced always having a method tracker, since that was intended to solve this issue but failed doing so.

Fixes #12222, and #12165. Reverts #11814.

(See WHATWG Working Mode: Changes for more details.)


/nav-history-apis.html ( diff )

Copy link
Copy Markdown
Collaborator

@noamr noamr left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for digging in to this!

Comment thread source
Currently per spec, #update-the-navigation-api-entries-for-a-same-document-navigation
will be called in different order to the #wait-for-all navigation handler
list depending on if the navigation is intercepted or not. This is not
ideal, but even more so, in case of a "traverse" navigation, the
callback passed to the #wait-for-all and the might be called before
the call to #update-the-navigation-api-entries-for-a-same-document-navigation
has happened.

This means that we'll run the finish steps with the wrong session
history entry.

Since all same document navigations, intercepted or otherwise, eventually
call #update-the-navigation-api-entries-for-a-same-document-navigation
we can ensure that we never run the navigation handlers with bad state.

This patch also reverts the patch that introduced always having a
method tracker, since that was intended to solve this issue but
failed doing so.

Fixes whatwg#12222, and whatwg#12165. Reverts whatwg#11814.
Comment thread source
@zcorpan zcorpan merged commit 8630938 into whatwg:main Mar 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

#commit-a-navigate-event needs to defer calling intercept handlers.

3 participants