| ▲ | altbdoor 7 hours ago | |
I know there will probably be some complications here and there, but this could be done with Web Components too, right? | ||
| ▲ | kcrwfrd_ 2 hours ago | parent | next [-] | |
Yes you could, or even just a vanilla DOM event handler on a button click. The problem is that you cannot introspect the browser’s history with the history API. So you have to hack your way around that if you want the “go back in history if possible, otherwise navigate to fallback url” behavior. Which I guess is easier if you’re in a react SPA. Or if you’re fully a MPA and can just check document.referrer There’s a brand new Navigation API that does let you introspect history entries from the same origin, which perfectly addresses the issue. I wrote a polyfill in order to take advantage of the navigation API for this exact problem: https://github.com/kcrwfrd/navigation-ponyfill | ||
| ▲ | jimbob45 5 hours ago | parent | prev [-] | |
Came to ask this myself. Oddly enough, I think they’ve kind of slipped under everyone’s radar. | ||