Post

I released a polyfill with pretty good good support for navigation history entries. As I start to think about how to tackle navigation transition lifecycle (Navigate event, cancellation, interceptors, etc.) I was wondering if you have any wisdom to share in the parts you think are impossible? 🙏🏼

Keeping the browser loading spinner going pops to mind, but there may be more. Things like knowing a navigation is just a `hashChange` seems tricky in the case of traversals. As in, how do you know it's same-document or not?

0 reposts0 likes

Yeah, hash changes were tricky to handle, but I think I got it down. I was surprised to learn they fire a popstate event! All of my e2e tests around history entries work with both native Navigation or the polyfill so far.

I believe sameDocument is indeed impossible. As well as navigationType: ‘reload’ on entry change event. The polyfill also introduces some restrictions on history API calls since we have to augment the state object with our entry key and ID.

So the browser spinner is shown while interception handler resolves? That’s pretty neat, thankfully I think its omission is some acceptable graceful degradation. What I’m wondering is can we polyfill sufficiently enough that a navigation-powered router for a SPA can be implemented.