foss-design 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -700,6 +700,33 @@ async function takeSnapshot() {
700
700
  } catch {
701
701
  }
702
702
  }
703
+ function keepLinksInFrame() {
704
+ const report = (target, form) => post({
705
+ type: "link",
706
+ href: target.href,
707
+ path: target.origin === location.origin ? target.pathname + target.search + target.hash : null,
708
+ form
709
+ });
710
+ const onClick = (event) => {
711
+ if (event.defaultPrevented || event.button > 1) return;
712
+ const link = event.target?.closest?.("a[href], area[href]");
713
+ if (!link || link.hasAttribute("download")) return;
714
+ const target = new URL(link.href, location.href);
715
+ if (target.protocol !== "http:" && target.protocol !== "https:") return;
716
+ const samePage = target.origin === location.origin && target.pathname === location.pathname && target.search === location.search;
717
+ if (samePage && target.hash) return;
718
+ event.preventDefault();
719
+ report(target, false);
720
+ };
721
+ window.addEventListener("click", onClick);
722
+ window.addEventListener("auxclick", onClick);
723
+ window.addEventListener("submit", (event) => {
724
+ const form = event.target;
725
+ if (event.defaultPrevented || form.method === "dialog") return;
726
+ event.preventDefault();
727
+ report(new URL(form.getAttribute("action") || location.href, location.href), true);
728
+ });
729
+ }
703
730
  var booted = false;
704
731
  var hmrBound = false;
705
732
  var canvasHost = false;
@@ -759,6 +786,7 @@ function boot() {
759
786
  },
760
787
  true
761
788
  );
789
+ if (embedded) keepLinksInFrame();
762
790
  window.addEventListener("blur", () => post({ type: "blur" }));
763
791
  window.addEventListener("error", (event) => recordError(event.message || "Script error"));
764
792
  window.addEventListener("unhandledrejection", (event) => {