PluginProbe
Gutenberg / 23.3.1
Gutenberg v23.3.1
23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 7.4.0 All 402 releases
gutenberg / build / modules / interactivity-router / full-page.js

full-page.js in Gutenberg 23.3.1, at build/modules/interactivity-router/full-page.js

30 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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