56 lines
1.6 KiB
JavaScript
56 lines
1.6 KiB
JavaScript
// Metro module 1066 (f1067).
|
|
import { triggerHandlers, supportsHistory, fill, addHandler, maybeInstrument } from "./Module817";
|
|
import { WINDOW } from "./Module1039";
|
|
let href;
|
|
const instrumentHistory = function instrumentHistory() {
|
|
WINDOW.addEventListener("popstate", () => {
|
|
const href2 = WINDOW.location.href;
|
|
const from = href;
|
|
href = href2;
|
|
if (from !== href2) {
|
|
triggerHandlers("history", {
|
|
from,
|
|
to: href2
|
|
});
|
|
}
|
|
});
|
|
if (supportsHistory()) {
|
|
const historyReplacementFunction = function historyReplacementFunction(c24028_0) {
|
|
return function(...args) {
|
|
const r9 = args.length > 2 ? args[2] : void 0;
|
|
if (r9) {
|
|
const from = href;
|
|
const to = (function getAbsoluteUrl(a0) {
|
|
let r18;
|
|
try {
|
|
r18 = new URL(a0, WINDOW.location.origin).toString();
|
|
} catch ($e) {
|
|
return a0;
|
|
}
|
|
return r18;
|
|
})(String(r9));
|
|
href = to;
|
|
if (from === to) {
|
|
return c24028_0.apply(this, args);
|
|
}
|
|
triggerHandlers("history", {
|
|
from,
|
|
to
|
|
});
|
|
}
|
|
return c24028_0.apply(this, args);
|
|
};
|
|
};
|
|
fill(WINDOW.history, "pushState", historyReplacementFunction);
|
|
fill(WINDOW.history, "replaceState", historyReplacementFunction);
|
|
}
|
|
};
|
|
Object.defineProperty(exports, Symbol.toStringTag, {
|
|
value: "Module"
|
|
});
|
|
export function addHistoryInstrumentationHandler(a0) {
|
|
addHandler("history", a0);
|
|
maybeInstrument("history", instrumentHistory);
|
|
}
|
|
export { instrumentHistory };
|