diff --git a/src/core/polyfills.js b/src/core/polyfills.js index 6f616f8ed..56f704b2c 100644 --- a/src/core/polyfills.js +++ b/src/core/polyfills.js @@ -44,19 +44,25 @@ // attach events on it. window.navigation = document.createElement("div"); + const create_event = (args) => { + event = new CustomEvent("navigate"); + event.destination = { url: args[2] }; + return event; + }; + // Patch pushState to trigger an `navigate` event on the navigation // object when the URL changes. const pushState = window.history.pushState; window.history.pushState = function () { pushState.apply(window.history, arguments); - window.navigation.dispatchEvent(new Event("navigate")); + window.navigation.dispatchEvent(create_event(arguments)); }; // Same with replaceState const replaceState = window.history.replaceState; window.history.replaceState = function () { replaceState.apply(window.history, arguments); - window.navigation.dispatchEvent(new Event("navigate")); + window.navigation.dispatchEvent(create_event(arguments)); }; } })();