@jsenv/navi 0.29.503 → 0.29.505

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.
@@ -37811,7 +37811,8 @@ const useContentKeepingLeavingPages = (branch, readShownBranch, parentPage) => {
37811
37811
  hold: leavingPagesHold,
37812
37812
  startRef: createRef(),
37813
37813
  endRef: createRef(),
37814
- hidden: false
37814
+ hidden: false,
37815
+ observer: null
37815
37816
  });
37816
37817
  leavingPagesHold.containers.add(rerender);
37817
37818
  // Keyed apart from the page it takes the place of, which is still there.
@@ -37851,20 +37852,22 @@ const useContentKeepingLeavingPages = (branch, readShownBranch, parentPage) => {
37851
37852
  }
37852
37853
  entry.hidden = true;
37853
37854
  entry.page.leavingSignal.value = true;
37854
- const focusedElement = document.activeElement;
37855
- let node = start.nextSibling;
37856
- while (node && node !== end) {
37857
- if (node.nodeType === Node.ELEMENT_NODE) {
37858
- node.setAttribute(LEAVING_ATTRIBUTE, "");
37859
- // What the keyboard held in it goes where the page's removal would
37860
- // have sent it: a hidden element keeps the focus, and would go on
37861
- // receiving the keys pressed during the movement.
37862
- if (node.contains(focusedElement)) {
37863
- focusedElement.blur();
37864
- }
37855
+ // The page renders on its own while kept (a component reading a signal
37856
+ // the address moved), never through this container: a top node it
37857
+ // replaces lands between the markers unmarked, a text it writes shows
37858
+ // again. Both are heard before the next frame.
37859
+ const observer = new MutationObserver(() => {
37860
+ if (entry.hold.released) {
37861
+ observer.disconnect();
37862
+ return;
37865
37863
  }
37866
- node = node.nextSibling;
37867
- }
37864
+ hideNodesBetween(start, end, observer);
37865
+ });
37866
+ hideNodesBetween(start, end, observer);
37867
+ observer.observe(start.parentNode, {
37868
+ childList: true
37869
+ });
37870
+ entry.observer = observer;
37868
37871
  }
37869
37872
  });
37870
37873
  // Also run when a Suspense boundary above parks this container — a page
@@ -37876,6 +37879,7 @@ const useContentKeepingLeavingPages = (branch, readShownBranch, parentPage) => {
37876
37879
  return () => {
37877
37880
  for (const entry of leavingRef.current) {
37878
37881
  entry.hold.containers.delete(rerender);
37882
+ entry.observer?.disconnect();
37879
37883
  }
37880
37884
  leavingRef.current = [];
37881
37885
  };
@@ -37903,6 +37907,32 @@ const useContentKeepingLeavingPages = (branch, readShownBranch, parentPage) => {
37903
37907
  };
37904
37908
  };
37905
37909
  const countRenders = count => count + 1;
37910
+ const hideNodesBetween = (start, end, observer) => {
37911
+ const focusedElement = document.activeElement;
37912
+ let node = start.nextSibling;
37913
+ while (node && node !== end) {
37914
+ if (node.nodeType === Node.ELEMENT_NODE) {
37915
+ if (!node.hasAttribute(LEAVING_ATTRIBUTE)) {
37916
+ node.setAttribute(LEAVING_ATTRIBUTE, "");
37917
+ // What the keyboard held in it goes where the page's removal would
37918
+ // have sent it: a hidden element keeps the focus, and would go on
37919
+ // receiving the keys pressed during the movement.
37920
+ if (node.contains(focusedElement)) {
37921
+ focusedElement.blur();
37922
+ }
37923
+ }
37924
+ } else if (node.nodeType === Node.TEXT_NODE && node.data !== "") {
37925
+ // No CSS reaches a text node, and it stays where it is: Preact inserts
37926
+ // next to it. Emptied for good, since the page is taken down without
37927
+ // being shown again, and Preact only writes it when its text changes.
37928
+ node.data = "";
37929
+ observer.observe(node, {
37930
+ characterData: true
37931
+ });
37932
+ }
37933
+ node = node.nextSibling;
37934
+ }
37935
+ };
37906
37936
  // The page a container renders, as RoutePageContext hands it over (see
37907
37937
  // route_page_context.js). Shown while the container would pick its branch, or
37908
37938
  // a branch rendering the same element (it is then carried over), and while the