devote / HTML5-History-API

HTML5 History API expansion for browsers not supporting pushState, replaceState
http://spb-piksel.ru
MIT License
1.02k stars 182 forks source link

add simple test illustrating hashchange event breakage #59

Open ahamid opened 10 years ago

ahamid commented 10 years ago

I believe this test demonstrates that the standard hashchange event is broken.

In onHashChangeEvent, fireNow and lastURL values are different, and appear to capture the last [sic] and next [sic] hash values.

function onHashChange(event) {
 // https://github.com/devote/HTML5-History-API/issues/46
 var fireNow = lastURL;
 // new value to lastURL
 lastURL = windowLocation.href;

e..g

> fireNow
"file:///home/user/workspace/HTML5-History-API/test/test_hashchange_html5.html"
> lastURL
"file:///home/user/workspace//HTML5-History-API/test/test_hashchange_html5.html#/path"

however, later, the lastURL and newURL values are compared, and they are identical

var oldURLObject = parseURL(lastURL, true);
var newURLObject = parseURL();
...
if (oldURLObject._hash !== newURLObject._hash) {
  // if current hash not equal previous hash
  dispatchEvent(event);
}

and the event is never fired.

devote commented 10 years ago

Hi,

Thank you very much for pointing out the error. This I did not complete the problem associated with https://github.com/devote/HTML5-History-API/issues/46

Now I fixed the problem and now it should work fine.