-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should this API be able to completely replace window.history? What about window.location? #67
Comments
I think this is the main point in favor of keeping |
I don't find But with virtualized scrolling lists etc, it might not be enough to make this work reliable as you want to know what node/data is shown as well as its viewport offset |
For |
I think having a more expressive scroll restoration API is the direction I would push things in personally. Tying scroll restoration to history is awkward, given new improvements like bfcache that make restoring to state more trivial than they used to be. If we wanted to have a more expressive API, giving users some control over when scroll positions were saved, and how they were restored, I think would make the API much more useful. But we should also ourselves how much can be accomplished with just a better history API |
Don't we already have this with |
I think replaceState etc is useful when updating things like map location (Google Maps like experiences - @denladeside) and video/music player positions. You might click back or forward by mistake and be able to undo mistake without losing position |
At Maersk, we are using replaceState for a critical internal enterprise tool to keep a single page application router (with UI and app states) and URL bar in sync (Google Maps style). It makes it easily possible for folks to share (or bookmark) exact views/states. |
I've spun off the reload() question into #112 |
The explainer details why
window.history
is an unfortunate API. Given a web developer starting from scratch on a new application, in the glorious future where app history ships everywhere, it seems like it'd be nice if such a web developer could ignorewindow.history
entirely.With the current design, this is mostly possible, with one exception: the navigation API's control over scroll restoration is not complete compared to
history.scrollRestoration
. In particular it does not control cross-document scroll restoration.Should it have that ability? What would that look like?
Other issues to note in the comparison
The navigation API, by design, doesn't have any insight into other-frame history entries. If an application needs such capabilities, it would need to coordinate with those frames, either by using
iframeEl.contentWindow.navigation
for same-origin-domain frames, orpostMessage()
ing to cross-origin-domain frames.The navigation API takes on a very different model for single-page app navs, as explained in this section. In particular it has no counterpart to
history.pushState()
orreplaceState()
which just update the current document's URL; instead you need to intercept a navigation using thenavigate
event and then usetransitionWhile()
inside the event handler. This is by design, but it's possible there are cases we haven't thought of yet where just updating the current document's URL is a good idea.A similar question is, should you be able to use
navigation
instead of usinglocation
? The combined capabilities ofnavigation.navigate()
andnavigation.currentEntry.url
cover much ofLocation
. However:location.hash
orlocation.pathname
require more work to emulate, e.g.(new URL(navigation.currentEntry.url)).hash
, or several lines for the setters.location.ancestorOrigins
.The text was updated successfully, but these errors were encountered: