Closed DanweDE closed 5 years ago
I'm experiencing this bug too, it's quite unfortunate. Steps to reproduce:
Define a route with a handler function and then try this code in console:
location.hash = ''; location.hash = '/some/route/'
The handler is triggered twice. Interestingly enough, it only happens when the hash
is changed in a quick succesion like this.
The bug is caused by Grapnel's path()
function, which reads the path from current URL rather than from the hashchange
event object. The trouble is that when two hashchange
events come one after another, the URL changes too quickly and path()
returns the wrong path.
If
pushState : false
is used in the options, the "navigate" event is being triggered two times. This is the case in both Chrome 41 Ubuntu 14.10 and Firefox 36.0.4 Ubuntu 14.10 after callingGrapnel#navigate
. When usingpushState : true
the event is only triggered once as expected.