| 1 |
// packages/interactivity-router/build-module/full-page.mjs |
| 2 |
var isValidLink = (ref) => ref && ref instanceof window.HTMLAnchorElement && ref.href && (!ref.target || ref.target === "_self") && ref.origin === window.location.origin && !ref.pathname.startsWith("/wp-admin") && !ref.pathname.startsWith("/wp-login.php") && !ref.getAttribute("href").startsWith("#") && !new URL(ref.href).searchParams.has("_wpnonce"); |
| 3 |
var isValidEvent = (event) => event && event.button === 0 && // Left clicks only. |
| 4 |
!event.metaKey && // Open in new tab (Mac). |
| 5 |
!event.ctrlKey && // Open in new tab (Windows). |
| 6 |
!event.altKey && // Download. |
| 7 |
!event.shiftKey && !event.defaultPrevented; |
| 8 |
document.addEventListener("click", async (event) => { |
| 9 |
const ref = event.target.closest("a"); |
| 10 |
if (isValidLink(ref) && isValidEvent(event)) { |
| 11 |
event.preventDefault(); |
| 12 |
const { actions } = await import("@wordpress/interactivity-router"); |
| 13 |
actions.navigate(ref.href); |
| 14 |
} |
| 15 |
}); |
| 16 |
document.addEventListener( |
| 17 |
"mouseenter", |
| 18 |
async (event) => { |
| 19 |
if (event.target?.nodeName === "A") { |
| 20 |
const ref = event.target.closest("a"); |
| 21 |
if (isValidLink(ref) && isValidEvent(event)) { |
| 22 |
const { actions } = await import("@wordpress/interactivity-router"); |
| 23 |
actions.prefetch(ref.href); |
| 24 |
} |
| 25 |
} |
| 26 |
}, |
| 27 |
true |
| 28 |
); |
| 29 |
//# sourceMappingURL=full-page.js.map |
| 30 |
|