You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a bit of a tangent to #2710 which attempts to make a very minor and incremental change to the spec (or rather simply expose an existing datapoint). This document, however, re-envisions a bigger part of the spec. Most of Google web apps that I've worked closely with employ this kind of API.
To sum this approach up: the history.state currently is a bit too brittle. It's too easy to overwrite or null it out without different parts of the app knowing about this. What I propose is to change the API to set history state properties separately (one by one or in a group). This would make history state feel more like localStorage.setItem/getItem API. It will remove collisions and make state more reliable.
It looks like you're trying to use the history state as both an object and a stack at the same time. I feel like this could become confusing on a webpage that heavily uses the history state. I'm also concerned that these changes may affect webpages using the current api. You mention making it feel more like localStorage, but why not make it exactly like localStorage (with the exception of having to stringify everything)? history.state and history.length could work the same as they do now, and there would be three new functions: history.setItem, history.getItem, and history.removeItem. Setting items this way would not affect history.state, so it wouldn't break anything.
Other potentially relevant discussions: #1454#2985
@Yay295 this could go independent of current API which would be kept for backward compatibility. The exact shape of API is TBD, of course. The setItem, however, doesn't really represent two typical actions for history stack: push and replace. So, that has to be considered. Maybe it could be done via a separate argument or such.
I took a stub at outlining what the new Web History API could look like and what are the main challenges are using it: https://medium.com/@dvoytenko/new-web-history-api-91a1a21ff7b8
This is a bit of a tangent to #2710 which attempts to make a very minor and incremental change to the spec (or rather simply expose an existing datapoint). This document, however, re-envisions a bigger part of the spec. Most of Google web apps that I've worked closely with employ this kind of API.
To sum this approach up: the
history.state
currently is a bit too brittle. It's too easy to overwrite or null it out without different parts of the app knowing about this. What I propose is to change the API to set history state properties separately (one by one or in a group). This would make history state feel more likelocalStorage.setItem/getItem
API. It will remove collisions and make state more reliable./cc @domenic, @natechapin, @spanicker, @RByers, @tbondwilkinson, @Yay295, @annevk
The text was updated successfully, but these errors were encountered: