From 198c369bfc02c8947a047bac20d304b105c2ed4f Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Mon, 13 Jan 2025 00:02:58 +0100 Subject: [PATCH] =?UTF-8?q?fix(core=20polyfills):=E2=80=8C=20Pass=20a=20de?= =?UTF-8?q?stination=20object=20with=20a=20url=20property=20along=20with?= =?UTF-8?q?=20the=20navigate=20event.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/polyfills.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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)); }; } })();