5125fb9611d90216a17ec67d0bd8a7b17b2fb734 |
|
08-Jul-2011 |
Ryan Grove <ryan@wonko.com> |
Queue save() and replace() calls to prevent race conditions. [Fixes #2530506]
Making multiple consecutive calls to save() or replace() would result in
each call dispatching to the URL of the final call, due to a combination
of HTML5 history quirks and a race condition in how dispatching was
handled.
The fix is to add all save() and replace() calls to a queue and ensure
that we don't start processing one until the previous one (if any) has
finished, thus guaranteeing that all calls will result in a dispatch to
the correct URLs.
We also ensure that a save() or replace() call never occurs before
window.onload, since this triggers a Chrome bug that would cause a
duplicate popstate event for the call that was already handled. |