WICG / navigation-api

The new navigation API provides a new interface for navigations and session history, with a focus on single-page application navigations.
https://html.spec.whatwg.org/multipage/nav-history-apis.html#navigation-api
484 stars 30 forks source link

Handler ordering problems due to microtask subtleties #242

Closed domenic closed 2 years ago

domenic commented 2 years ago

When the stack is not-empty for a navigation, e.g. because it's caused by navigation.navigate(), we end up with

i.e. the result is currententrychange -> intercept() handlers -> committed promise handlers.

When the stack is empty for a navigation, e.g. because it's caused by users clicking on <a>s or it's a traversal (which requires an in-parallel + queue a task round trip), then we have:

i.e. the result is either currententrychange -> committed promise handlers -> intercept() handlers, or currententrychange -> intercept() handlers -> committed promise handlers, depending on whether or not currententrychange has any listeners.

This is weird and should probably be avoided. We should have the order be either currententrychange -> committed promise handlers -> intercept() handlers consistently, or currententrychange -> intercept() handlers -> committed promise handlers consistently.