@jsenv/navi 0.29.503 → 0.29.504

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
+ hideNodesBetween(start, end);
37856
+ // The page renders on its own while kept (a component reading a signal
37857
+ // the address moved), never through this container: a top node it
37858
+ // replaces lands between the markers unmarked. Its mutation is heard
37859
+ // before the next frame.
37860
+ const observer = new MutationObserver(() => {
37861
+ if (entry.hold.released) {
37862
+ observer.disconnect();
37863
+ return;
37865
37864
  }
37866
- node = node.nextSibling;
37867
- }
37865
+ hideNodesBetween(start, end);
37866
+ });
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,22 @@ const useContentKeepingLeavingPages = (branch, readShownBranch, parentPage) => {
37903
37907
  };
37904
37908
  };
37905
37909
  const countRenders = count => count + 1;
37910
+ const hideNodesBetween = (start, end) => {
37911
+ const focusedElement = document.activeElement;
37912
+ let node = start.nextSibling;
37913
+ while (node && node !== end) {
37914
+ if (node.nodeType === Node.ELEMENT_NODE && !node.hasAttribute(LEAVING_ATTRIBUTE)) {
37915
+ node.setAttribute(LEAVING_ATTRIBUTE, "");
37916
+ // What the keyboard held in it goes where the page's removal would
37917
+ // have sent it: a hidden element keeps the focus, and would go on
37918
+ // receiving the keys pressed during the movement.
37919
+ if (node.contains(focusedElement)) {
37920
+ focusedElement.blur();
37921
+ }
37922
+ }
37923
+ node = node.nextSibling;
37924
+ }
37925
+ };
37906
37926
  // The page a container renders, as RoutePageContext hands it over (see
37907
37927
  // route_page_context.js). Shown while the container would pick its branch, or
37908
37928
  // a branch rendering the same element (it is then carried over), and while the