@jsenv/dom 0.17.62 → 0.17.64

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.
Files changed (2) hide show
  1. package/dist/jsenv_dom.js +34 -12
  2. package/package.json +1 -1
package/dist/jsenv_dom.js CHANGED
@@ -15790,9 +15790,9 @@ const isAncestorOpen = (ancestor) => {
15790
15790
  };
15791
15791
 
15792
15792
  /**
15793
- * Whether `element` is on screen even though the openable ancestor it was
15794
- * resolved against is closed. Ask it only about an ancestor `isAncestorOpen`
15795
- * already said is closed.
15793
+ * Whether `element` is on screen even though `ancestor`, the openable ancestor
15794
+ * it was resolved against, is closed. Ask it only about an ancestor
15795
+ * `isAncestorOpen` already said is closed.
15796
15796
  *
15797
15797
  * `[aria-expanded]` in OPENABLE_SELECTOR covers two opposite kinds of element:
15798
15798
  * the surface being opened (a <dialog>, a [popover], and the plain <div> navi's
@@ -15802,11 +15802,19 @@ const isAncestorOpen = (ancestor) => {
15802
15802
  * aria-expanded describes the popup it controls rather than its own contents:
15803
15803
  * its façade stays on screen the entire time aria-expanded is "false".
15804
15804
  *
15805
- * Markup tells the two apart badly, so ask the layout instead. A closed surface
15806
- * is display:none, natively for [popover]/<dialog> and through the library's
15807
- * own closed-state CSS ([navi-hidden], :not([popover])) for the custom
15808
- * renderers — so nothing inside one answers true here, while everything a
15809
- * trigger keeps on screen does.
15805
+ * A <dialog> or a [popover] is only ever a surface, and the UA hides a closed
15806
+ * one outright (display: none), so nothing inside has a box: answered from the
15807
+ * markup, without touching the layout. Anything else — a <details> whose
15808
+ * <summary> stays on screen, a bare [aria-expanded] — is asked of the layout
15809
+ * instead: a closed custom surface is display:none through the library's own
15810
+ * closed-state CSS ([navi-hidden], :not([popover])), so nothing inside one
15811
+ * answers true here, while everything a trigger keeps on screen does.
15812
+ *
15813
+ * The layout question is a forced style recalculation. Asked once per element
15814
+ * from a mount that also writes styles between the questions, each one costs a
15815
+ * recalculation of everything dirtied since the last, so a caller that knows
15816
+ * the answer another way (a surface it is itself building the content of, see
15817
+ * @jsenv/navi's use_displayed_layout_effect.js) should not reach this.
15810
15818
  *
15811
15819
  * Ask it about an ancestor that is closed AND settled — on mount, or when
15812
15820
  * setting up a long-lived observer. A surface animating its way out still has a
@@ -15814,7 +15822,10 @@ const isAncestorOpen = (ancestor) => {
15814
15822
  * display/overlay), so asked at the instant one closes this says "on screen"
15815
15823
  * about something on its way off it.
15816
15824
  */
15817
- const isDisplayedDespiteClosedAncestor = (element) => {
15825
+ const isDisplayedDespiteClosedAncestor = (element, ancestor) => {
15826
+ if (ancestor.tagName === "DIALOG" || ancestor.hasAttribute("popover")) {
15827
+ return false;
15828
+ }
15818
15829
  if (typeof element.checkVisibility !== "function") {
15819
15830
  // Nothing to tell the two apart with: leave the caller treating the closed
15820
15831
  // ancestor as hiding this element.
@@ -17141,7 +17152,8 @@ const visibleRectEffect = (
17141
17152
  // which is the opposite answer — so a surface closing later goes on
17142
17153
  // counting, unasked.
17143
17154
  const elementIsInAncestorFacade =
17144
- !openableAncestorIsOpen && isDisplayedDespiteClosedAncestor(element);
17155
+ !openableAncestorIsOpen &&
17156
+ isDisplayedDespiteClosedAncestor(element, openableAncestor);
17145
17157
  if (!openableAncestorIsOpen && !elementIsInAncestorFacade) {
17146
17158
  ancestorClosedCount++;
17147
17159
  pauseResizeWatching();
@@ -17555,6 +17567,11 @@ const toContainerAlignedPosition = (value) => {
17555
17567
  * many px of that same edge — avoids the (wider) element overflowing past it. 0 disables
17556
17568
  * the snap entirely.
17557
17569
  * @param {number} [options.minLeft=0] - Minimum left coordinate (document-relative).
17570
+ * @param {boolean} [options.fill=false] - `element` is known to take the whole available
17571
+ * area net of `marginWithContainer`, on both axes (a dialog stretched to its container
17572
+ * by CSS). Its box is then derived from the container rather than measured: reading
17573
+ * offsetWidth/offsetHeight forces a layout of everything the element holds, for a number
17574
+ * the caller already knows. Only meaningful without an `anchor`.
17558
17575
  * @param {HTMLElement|null} [options.container] - The container `element` is genuinely
17559
17576
  * `position: absolute` relative to (its own containing block) — decoupled from whether
17560
17577
  * there's a real `anchor`, since `element` can be container-relative either way (e.g. the
@@ -17595,6 +17612,7 @@ const pickPositionRelativeTo = (
17595
17612
  marginWithAnchor = 0,
17596
17613
  alignToAnchorBox = "border-box",
17597
17614
  marginWithContainer = 0,
17615
+ fill = false,
17598
17616
  container,
17599
17617
  } = {},
17600
17618
  ) => {
@@ -17741,8 +17759,12 @@ const pickPositionRelativeTo = (
17741
17759
  // instant (a popover using animation="scaling"/"expand-*") — so
17742
17760
  // getBoundingClientRect() answers where it is painted, at its *shrunk*
17743
17761
  // mid-animation size, instead of the box being measured here.
17744
- const elementWidth = element.offsetWidth;
17745
- const elementHeight = element.offsetHeight;
17762
+ const elementWidth = fill
17763
+ ? availableWidth - 2 * marginWithContainer
17764
+ : element.offsetWidth;
17765
+ const elementHeight = fill
17766
+ ? availableHeight - 2 * marginWithContainer
17767
+ : element.offsetHeight;
17746
17768
  const anchorWidth = anchorRight - anchorLeft;
17747
17769
  const anchorHeight = anchorBottom - anchorTop;
17748
17770
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/dom",
3
- "version": "0.17.62",
3
+ "version": "0.17.64",
4
4
  "type": "module",
5
5
  "description": "DOM utilities for writing frontend code",
6
6
  "repository": {