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

When should the URL change when using transitionWhile? #232

Closed jakearchibald closed 2 years ago

jakearchibald commented 2 years ago

With MPA:

  1. Begin fetching
  2. Time passes
  3. Fetch complete
  4. Switch to new page - URL changes here

With transitionWhile:

  1. Begin fetching
  2. transitionWhile called - URL changes here
  3. Time passes
  4. Fetch complete
  5. Alter DOM

This means old-page content is being shown between steps 2-5, but with the new URL. This presents issues for relative URLs (including links, images, fetch()), which won't behave as expected.

It feels like URL changing should be deferred until the promise passed to transitionWhile resolves, perhaps with an optional commitURLChange() method to perform the swap sooner.

jakearchibald commented 2 years ago

Along with the URL issue, there's also the general issue of the content not matching the URL.

domenic commented 2 years ago

This is essentially a dupe of https://github.com/WICG/navigation-api/issues/66 . Let me merge it into there.