[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/script-modules/interactivity-router/ -> full-page.js (source)

   1  // packages/interactivity-router/build-module/full-page.js
   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  );


Generated : Wed Apr 15 08:20:10 2026 Cross-referenced by PHPXref