@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.
@@ -36560,7 +36560,8 @@ const useContentKeepingLeavingPages = (branch, readShownBranch, parentPage) => {
36560
36560
  hold: leavingPagesHold,
36561
36561
  startRef: createRef(),
36562
36562
  endRef: createRef(),
36563
- hidden: false
36563
+ hidden: false,
36564
+ observer: null
36564
36565
  });
36565
36566
  leavingPagesHold.containers.add(rerender);
36566
36567
  // Keyed apart from the page it takes the place of, which is still there.
@@ -36600,20 +36601,22 @@ const useContentKeepingLeavingPages = (branch, readShownBranch, parentPage) => {
36600
36601
  }
36601
36602
  entry.hidden = true;
36602
36603
  entry.page.leavingSignal.value = true;
36603
- const focusedElement = document.activeElement;
36604
- let node = start.nextSibling;
36605
- while (node && node !== end) {
36606
- if (node.nodeType === Node.ELEMENT_NODE) {
36607
- node.setAttribute(LEAVING_ATTRIBUTE, "");
36608
- // What the keyboard held in it goes where the page's removal would
36609
- // have sent it: a hidden element keeps the focus, and would go on
36610
- // receiving the keys pressed during the movement.
36611
- if (node.contains(focusedElement)) {
36612
- focusedElement.blur();
36613
- }
36604
+ hideNodesBetween(start, end);
36605
+ // The page renders on its own while kept (a component reading a signal
36606
+ // the address moved), never through this container: a top node it
36607
+ // replaces lands between the markers unmarked. Its mutation is heard
36608
+ // before the next frame.
36609
+ const observer = new MutationObserver(() => {
36610
+ if (entry.hold.released) {
36611
+ observer.disconnect();
36612
+ return;
36614
36613
  }
36615
- node = node.nextSibling;
36616
- }
36614
+ hideNodesBetween(start, end);
36615
+ });
36616
+ observer.observe(start.parentNode, {
36617
+ childList: true
36618
+ });
36619
+ entry.observer = observer;
36617
36620
  }
36618
36621
  });
36619
36622
  // Also run when a Suspense boundary above parks this container — a page
@@ -36625,6 +36628,7 @@ const useContentKeepingLeavingPages = (branch, readShownBranch, parentPage) => {
36625
36628
  return () => {
36626
36629
  for (const entry of leavingRef.current) {
36627
36630
  entry.hold.containers.delete(rerender);
36631
+ entry.observer?.disconnect();
36628
36632
  }
36629
36633
  leavingRef.current = [];
36630
36634
  };
@@ -36652,6 +36656,22 @@ const useContentKeepingLeavingPages = (branch, readShownBranch, parentPage) => {
36652
36656
  };
36653
36657
  };
36654
36658
  const countRenders = count => count + 1;
36659
+ const hideNodesBetween = (start, end) => {
36660
+ const focusedElement = document.activeElement;
36661
+ let node = start.nextSibling;
36662
+ while (node && node !== end) {
36663
+ if (node.nodeType === Node.ELEMENT_NODE && !node.hasAttribute(LEAVING_ATTRIBUTE)) {
36664
+ node.setAttribute(LEAVING_ATTRIBUTE, "");
36665
+ // What the keyboard held in it goes where the page's removal would
36666
+ // have sent it: a hidden element keeps the focus, and would go on
36667
+ // receiving the keys pressed during the movement.
36668
+ if (node.contains(focusedElement)) {
36669
+ focusedElement.blur();
36670
+ }
36671
+ }
36672
+ node = node.nextSibling;
36673
+ }
36674
+ };
36655
36675
  // The page a container renders, as RoutePageContext hands it over (see
36656
36676
  // route_page_context.js). Shown while the container would pick its branch, or
36657
36677
  // a branch rendering the same element (it is then carried over), and while the