[whatwg] Firing popstate for all history entry changes

Ian Hickson ian at hixie.ch
Fri Aug 27 16:03:18 PDT 2010


On Wed, 25 Aug 2010, Mihai Parparita wrote:
>
> [...] it seems like the (web) developer's mental model for popstate 
> would be much simpler if it fired whenever the current session history 
> entry changed, regardless of whether it has a state object or was the 
> first entry. Then if someone wished to listen to all history events, 
> they would just have to use onpopstate, instead of a combination of 
> onpopstate and onhashchange.

Ok, I've changed popstate to get fired (or queued up, if before 'load') 
for every traversal, not just those to non-null states.


On Wed, 25 Aug 2010, Justin Lebar wrote:
> >
> > It might also help if the event wasn't called "popstate", since that 
> > implies a 1:1 relationship with pushState calls, but you can already 
> > get popstate events without corresponding pushState calls. 
> > "historytraversal" perhaps?
> 
> I think we've decided here that the time for major changes to this API 
> has past -- it's already in use in the wild.  If we *do* want to change 
> the API, I'd like to get in line.  :)

Indeed.


> > However, it seems like the (web) developer's mental model for popstate 
> > would be much simpler if it fired whenever the current session history 
> > entry changed, regardless of whether it has a state object or was the 
> > first entry.
> 
> This is the model Firefox uses, and we're prepared to ship it in the 
> upcoming release of version 4.  It's divergent from WebKit, which has 
> already shipped, but WebKit is going to have to change anyway. 
> (http://webkit.org/b/41372)

Ok.


BTW, there's another problem with this API, which is that since popstates 
are dropped while the document is loading, calling pushState() while the 
document is loading leads to a very confused state. Should we make 
pushState() throw an exception if called before load? (replaceState() is 
probably ok, though even that's a bit dodgy.)

I assume we don't want to change this, in which case I should probably put 
a note in the spec warning about using pushState() and replaceState() 
before load. Any opinions on this?

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list