@jsenv/dom 0.17.33 → 0.17.34

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 +28 -7
  2. package/package.json +1 -1
package/dist/jsenv_dom.js CHANGED
@@ -4896,9 +4896,18 @@ const findFocusable = (element, { exclude } = {}) => {
4896
4896
  return focusableDescendant;
4897
4897
  };
4898
4898
 
4899
- // note: keep in mind that an element with overflow: 'hidden' is scrollable
4900
- // it can be scrolled using keyboard arrows or JavaScript properties such as scrollTop, scrollLeft
4901
- // the only overflow that prevents scroll is "visible"
4899
+ // `hidden` and `clip` both cut the content off and are two different things
4900
+ // here, which is what `includeHidden` is about:
4901
+ // - `hidden` IS a scroll container. Nothing scrolls it by hand, but keyboard
4902
+ // arrows and scrollTop/scrollLeft do, so whoever cares where an element can
4903
+ // be brought into view has to count it.
4904
+ // - `clip` is not one. It clips and stops there: it has no scroll box at all,
4905
+ // and scrollTop/scrollLeft on it read back 0 whatever they are set to. That
4906
+ // is the whole reason a layout reaches for it (see navi's
4907
+ // docs/MOBILE_LAYOUT_PITFALLS.md), so it is never included, whatever the
4908
+ // caller asks for.
4909
+ // `visible` is the other non-scrolling value, and the only one on which the
4910
+ // content still reaches the ancestors.
4902
4911
  const isScrollable = (element, { includeHidden } = {}) => {
4903
4912
  if (canHaveVerticalScroll(element, { includeHidden })) {
4904
4913
  return true;
@@ -4940,7 +4949,10 @@ const canHaveVerticalScroll = (element, { includeHidden }) => {
4940
4949
  }
4941
4950
  return false;
4942
4951
  }
4943
- if (verticalOverflow === "hidden" || verticalOverflow === "clip") {
4952
+ if (verticalOverflow === "clip") {
4953
+ return false;
4954
+ }
4955
+ if (verticalOverflow === "hidden") {
4944
4956
  return includeHidden;
4945
4957
  }
4946
4958
  const overflow = getStyle(element, "overflow");
@@ -4951,7 +4963,10 @@ const canHaveVerticalScroll = (element, { includeHidden }) => {
4951
4963
  }
4952
4964
  return false;
4953
4965
  }
4954
- if (overflow === "hidden" || overflow === "clip") {
4966
+ if (overflow === "clip") {
4967
+ return false;
4968
+ }
4969
+ if (overflow === "hidden") {
4955
4970
  return includeHidden;
4956
4971
  }
4957
4972
  return true; // "auto", "scroll"
@@ -4965,7 +4980,10 @@ const canHaveHorizontalScroll = (element, { includeHidden }) => {
4965
4980
  }
4966
4981
  return false;
4967
4982
  }
4968
- if (horizontalOverflow === "hidden" || horizontalOverflow === "clip") {
4983
+ if (horizontalOverflow === "clip") {
4984
+ return false;
4985
+ }
4986
+ if (horizontalOverflow === "hidden") {
4969
4987
  return includeHidden;
4970
4988
  }
4971
4989
  const overflow = getStyle(element, "overflow");
@@ -4976,7 +4994,10 @@ const canHaveHorizontalScroll = (element, { includeHidden }) => {
4976
4994
  }
4977
4995
  return false;
4978
4996
  }
4979
- if (overflow === "hidden" || overflow === "clip") {
4997
+ if (overflow === "clip") {
4998
+ return false;
4999
+ }
5000
+ if (overflow === "hidden") {
4980
5001
  return includeHidden;
4981
5002
  }
4982
5003
  return true; // "auto", "scroll"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/dom",
3
- "version": "0.17.33",
3
+ "version": "0.17.34",
4
4
  "type": "module",
5
5
  "description": "DOM utilities for writing frontend code",
6
6
  "repository": {