Skip to content

Commit

Permalink
Merge pull request #148 from taguchimail/fix/147
Browse files Browse the repository at this point in the history
Retain history.state when calling pushstate/replacestate fixes #147
  • Loading branch information
jmalonzo committed May 25, 2016
2 parents 4840d88 + 46abdef commit b594c20
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/app-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,19 @@
path = '#' + path;
}
}
var currentState = window.history.state;
if (options && options.replace === true) {
window.history.replaceState(null, null, path);
window.history.replaceState(currentState, null, path);
} else {
window.history.pushState(null, null, path);
window.history.pushState(currentState, null, path);
}

// dispatch a popstate event
try {
var popstateEvent = new PopStateEvent('popstate', {
bubbles: false,
cancelable: false,
state: {}
state: currentState
});

if ('dispatchEvent_' in window) {
Expand All @@ -161,7 +162,7 @@
} catch(error) {
// Internet Exploder
var fallbackEvent = document.createEvent('CustomEvent');
fallbackEvent.initCustomEvent('popstate', false, false, { state: {} });
fallbackEvent.initCustomEvent('popstate', false, false, { state: currentState });
window.dispatchEvent(fallbackEvent);
}
};
Expand Down

0 comments on commit b594c20

Please sign in to comment.