Skip to content

Commit 579184c

Browse files
committed
Did some cleaning. Trying to fix safariPoll issue.
1 parent 330416f commit 579184c

File tree

8 files changed

+471
-367
lines changed

8 files changed

+471
-367
lines changed

demo/bcherry.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
<p>There's a bug in the HTML5 "popstate" event, as implemented in WebKit (Safari and Chrome). View this page in one of those browsers. Your browser has had history entries added from #0 to #19 (you should start at #19). Hitting back/forward will navigate through these. On each URL, the large number above should reflect the hash value. If you hit back/forward quickly, you'll notice that your number gets out of sync with the URL. This is because WebKit is dropping popstate events (they are not firing). It seems to happen when outbound network requests are in progress when the user navigates in their browser happens. In this case, your browser is downloading an image that takes 1s to serve on every popstate, so you'll have to wait 1s between backs/forwards to have the feature work correctly. You could also cause constant network traffic by putting an image download in a setInterval, in which case your popstate events will never fire. This implementation simulates an AJAX application that makes a network request when you navigate between URLs using pushState/popstate. View the source for more info.</p>
3232
<p>This was filed as <a href="https://bugs.webkit.org/show_bug.cgi?id=42940">Bug 42940</a> with WebKit on July 24, 2010. The Firefox 4 beta does not have this bug, which is good news.</p>
3333
<p>This is put together by <a href="http://www.adequatelygood.com">Ben Cherry</a>. Ben is a front-end engineer at <a href="http://twitter.com/">Twitter</a>, and you can follow him at <a href="http://twitter.com/bcherry">@bcherry</a>.</p>
34+
<p>This bug was fixed in <a href="http://github.com/balupton/history.js">History.js</a> by <a href="http://balupton.com">Benjamin Lupton</a>. Benjamin is a freelance web 2.0 consultant, and you can follow him at <a href="http://twitter.com/balupton">@balupton</a>.</p>
3435
<script>
36+
// Prepare
37+
window.History.debug.enable = true;
38+
3539
// Bind to popstate
3640
$(window).bind("statechange", function(e) {
3741
var State = window.History.getState();
@@ -41,7 +45,7 @@
4145
console.log("popstate", State, window.location.href);
4246
}
4347
// update the page
44-
$("#n").text(State.data.n);
48+
$("#n").text(typeof State.data.n !== 'undefined' ? State.data.n : State.url);
4549

4650
// Make an outbound image request that will take 1s. This request seems to be the cause of dropped popstates.
4751
// Removing this, or replacing it with something else, avoids the issue. Even if it's replaced with slow, blocking code (i.e. 1s of execution) events are not dropped.

0 commit comments

Comments
 (0)