@wordpress/dom 3.50.0 → 3.51.0

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.51.0 (2024-02-09)
6
+
5
7
  ## 3.50.0 (2024-01-24)
6
8
 
7
9
  ## 3.49.0 (2024-01-10)
@@ -41,7 +41,6 @@ function getOffsetParent(node) {
41
41
  }
42
42
 
43
43
  // offsetParent is undocumented/draft.
44
- return (/** @type {Node & { offsetParent: Node }} */closestElement.offsetParent
45
- );
44
+ return /** @type {Node & { offsetParent: Node }} */closestElement.offsetParent;
46
45
  }
47
46
  //# sourceMappingURL=get-offset-parent.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_getComputedStyle","_interopRequireDefault","require","getOffsetParent","node","closestElement","parentNode","nodeType","ELEMENT_NODE","getComputedStyle","position","offsetParent"],"sources":["@wordpress/dom/src/dom/get-offset-parent.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Returns the closest positioned element, or null under any of the conditions\n * of the offsetParent specification. Unlike offsetParent, this function is not\n * limited to HTMLElement and accepts any Node (e.g. Node.TEXT_NODE).\n *\n * @see https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetparent\n *\n * @param {Node} node Node from which to find offset parent.\n *\n * @return {Node | null} Offset parent.\n */\nexport default function getOffsetParent( node ) {\n\t// Cannot retrieve computed style or offset parent only anything other than\n\t// an element node, so find the closest element node.\n\tlet closestElement;\n\twhile ( ( closestElement = /** @type {Node} */ ( node.parentNode ) ) ) {\n\t\tif ( closestElement.nodeType === closestElement.ELEMENT_NODE ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( ! closestElement ) {\n\t\treturn null;\n\t}\n\n\t// If the closest element is already positioned, return it, as offsetParent\n\t// does not otherwise consider the node itself.\n\tif (\n\t\tgetComputedStyle( /** @type {Element} */ ( closestElement ) )\n\t\t\t.position !== 'static'\n\t) {\n\t\treturn closestElement;\n\t}\n\n\t// offsetParent is undocumented/draft.\n\treturn /** @type {Node & { offsetParent: Node }} */ ( closestElement )\n\t\t.offsetParent;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,eAAeA,CAAEC,IAAI,EAAG;EAC/C;EACA;EACA,IAAIC,cAAc;EAClB,OAAUA,cAAc,GAAG,mBAAsBD,IAAI,CAACE,UAAY,EAAK;IACtE,IAAKD,cAAc,CAACE,QAAQ,KAAKF,cAAc,CAACG,YAAY,EAAG;MAC9D;IACD;EACD;EAEA,IAAK,CAAEH,cAAc,EAAG;IACvB,OAAO,IAAI;EACZ;;EAEA;EACA;EACA,IACC,IAAAI,yBAAgB,GAAE,sBAAyBJ,cAAiB,CAAC,CAC3DK,QAAQ,KAAK,QAAQ,EACtB;IACD,OAAOL,cAAc;EACtB;;EAEA;EACA,OAAO,6CAA+CA,cAAc,CAClEM;EAAY;AACf"}
1
+ {"version":3,"names":["_getComputedStyle","_interopRequireDefault","require","getOffsetParent","node","closestElement","parentNode","nodeType","ELEMENT_NODE","getComputedStyle","position","offsetParent"],"sources":["@wordpress/dom/src/dom/get-offset-parent.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Returns the closest positioned element, or null under any of the conditions\n * of the offsetParent specification. Unlike offsetParent, this function is not\n * limited to HTMLElement and accepts any Node (e.g. Node.TEXT_NODE).\n *\n * @see https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetparent\n *\n * @param {Node} node Node from which to find offset parent.\n *\n * @return {Node | null} Offset parent.\n */\nexport default function getOffsetParent( node ) {\n\t// Cannot retrieve computed style or offset parent only anything other than\n\t// an element node, so find the closest element node.\n\tlet closestElement;\n\twhile ( ( closestElement = /** @type {Node} */ ( node.parentNode ) ) ) {\n\t\tif ( closestElement.nodeType === closestElement.ELEMENT_NODE ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( ! closestElement ) {\n\t\treturn null;\n\t}\n\n\t// If the closest element is already positioned, return it, as offsetParent\n\t// does not otherwise consider the node itself.\n\tif (\n\t\tgetComputedStyle( /** @type {Element} */ ( closestElement ) )\n\t\t\t.position !== 'static'\n\t) {\n\t\treturn closestElement;\n\t}\n\n\t// offsetParent is undocumented/draft.\n\treturn /** @type {Node & { offsetParent: Node }} */ ( closestElement )\n\t\t.offsetParent;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,eAAeA,CAAEC,IAAI,EAAG;EAC/C;EACA;EACA,IAAIC,cAAc;EAClB,OAAUA,cAAc,GAAG,mBAAsBD,IAAI,CAACE,UAAY,EAAK;IACtE,IAAKD,cAAc,CAACE,QAAQ,KAAKF,cAAc,CAACG,YAAY,EAAG;MAC9D;IACD;EACD;EAEA,IAAK,CAAEH,cAAc,EAAG;IACvB,OAAO,IAAI;EACZ;;EAEA;EACA;EACA,IACC,IAAAI,yBAAgB,GAAE,sBAAyBJ,cAAiB,CAAC,CAC3DK,QAAQ,KAAK,QAAQ,EACtB;IACD,OAAOL,cAAc;EACtB;;EAEA;EACA,OAAO,4CAA+CA,cAAc,CAClEM,YAAY;AACf"}
@@ -38,7 +38,7 @@ function isEdge(container, isReverse, onlyVertical = false) {
38
38
  }
39
39
  return container.value.length === container.selectionStart;
40
40
  }
41
- if (! /** @type {HTMLElement} */container.isContentEditable) {
41
+ if (!( /** @type {HTMLElement} */container.isContentEditable)) {
42
42
  return true;
43
43
  }
44
44
  const {
@@ -1 +1 @@
1
- {"version":3,"names":["_isRtl","_interopRequireDefault","require","_getRangeHeight","_getRectangleFromRange","_isSelectionForward","_hiddenCaretRangeFromPoint","_assertIsDefined","_isInputOrTextArea","_scrollIfNoRange","isEdge","container","isReverse","onlyVertical","isInputOrTextArea","selectionStart","selectionEnd","value","length","isContentEditable","ownerDocument","defaultView","assertIsDefined","selection","getSelection","rangeCount","range","getRangeAt","collapsedRange","cloneRange","isForward","isSelectionForward","isCollapsed","collapse","collapsedRangeRect","getRectangleFromRange","rangeRect","rangeHeight","getRangeHeight","height","isReverseDir","isRTL","containerRect","getBoundingClientRect","x","left","right","y","top","bottom","testRange","scrollIfNoRange","hiddenCaretRangeFromPoint","testRect","verticalSide","horizontalSide","verticalDiff","horizontalDiff","hasVerticalDiff","Math","abs","hasHorizontalDiff"],"sources":["@wordpress/dom/src/dom/is-edge.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport isRTL from './is-rtl';\nimport getRangeHeight from './get-range-height';\nimport getRectangleFromRange from './get-rectangle-from-range';\nimport isSelectionForward from './is-selection-forward';\nimport hiddenCaretRangeFromPoint from './hidden-caret-range-from-point';\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\nimport { scrollIfNoRange } from './scroll-if-no-range';\n\n/**\n * Check whether the selection is at the edge of the container. Checks for\n * horizontal position by default. Set `onlyVertical` to true to check only\n * vertically.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse Set to true to check left, false to check right.\n * @param {boolean} [onlyVertical=false] Set to true to check only vertical position.\n *\n * @return {boolean} True if at the edge, false if not.\n */\nexport default function isEdge( container, isReverse, onlyVertical = false ) {\n\tif (\n\t\tisInputOrTextArea( container ) &&\n\t\ttypeof container.selectionStart === 'number'\n\t) {\n\t\tif ( container.selectionStart !== container.selectionEnd ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( isReverse ) {\n\t\t\treturn container.selectionStart === 0;\n\t\t}\n\n\t\treturn container.value.length === container.selectionStart;\n\t}\n\n\tif ( ! ( /** @type {HTMLElement} */ ( container ).isContentEditable ) ) {\n\t\treturn true;\n\t}\n\n\tconst { ownerDocument } = container;\n\tconst { defaultView } = ownerDocument;\n\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\n\tif ( ! selection || ! selection.rangeCount ) {\n\t\treturn false;\n\t}\n\n\tconst range = selection.getRangeAt( 0 );\n\tconst collapsedRange = range.cloneRange();\n\tconst isForward = isSelectionForward( selection );\n\tconst isCollapsed = selection.isCollapsed;\n\n\t// Collapse in direction of selection.\n\tif ( ! isCollapsed ) {\n\t\tcollapsedRange.collapse( ! isForward );\n\t}\n\n\tconst collapsedRangeRect = getRectangleFromRange( collapsedRange );\n\tconst rangeRect = getRectangleFromRange( range );\n\n\tif ( ! collapsedRangeRect || ! rangeRect ) {\n\t\treturn false;\n\t}\n\n\t// Only consider the multiline selection at the edge if the direction is\n\t// towards the edge. The selection is multiline if it is taller than the\n\t// collapsed selection.\n\tconst rangeHeight = getRangeHeight( range );\n\tif (\n\t\t! isCollapsed &&\n\t\trangeHeight &&\n\t\trangeHeight > collapsedRangeRect.height &&\n\t\tisForward === isReverse\n\t) {\n\t\treturn false;\n\t}\n\n\t// In the case of RTL scripts, the horizontal edge is at the opposite side.\n\tconst isReverseDir = isRTL( container ) ? ! isReverse : isReverse;\n\tconst containerRect = container.getBoundingClientRect();\n\n\t// To check if a selection is at the edge, we insert a test selection at the\n\t// edge of the container and check if the selections have the same vertical\n\t// or horizontal position. If they do, the selection is at the edge.\n\t// This method proves to be better than a DOM-based calculation for the\n\t// horizontal edge, since it ignores empty textnodes and a trailing line\n\t// break element. In other words, we need to check visual positioning, not\n\t// DOM positioning.\n\t// It also proves better than using the computed style for the vertical\n\t// edge, because we cannot know the padding and line height reliably in\n\t// pixels. `getComputedStyle` may return a value with different units.\n\tconst x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;\n\tconst y = isReverse ? containerRect.top + 1 : containerRect.bottom - 1;\n\tconst testRange = scrollIfNoRange( container, isReverse, () =>\n\t\thiddenCaretRangeFromPoint( ownerDocument, x, y, container )\n\t);\n\n\tif ( ! testRange ) {\n\t\treturn false;\n\t}\n\n\tconst testRect = getRectangleFromRange( testRange );\n\n\tif ( ! testRect ) {\n\t\treturn false;\n\t}\n\n\tconst verticalSide = isReverse ? 'top' : 'bottom';\n\tconst horizontalSide = isReverseDir ? 'left' : 'right';\n\tconst verticalDiff = testRect[ verticalSide ] - rangeRect[ verticalSide ];\n\tconst horizontalDiff =\n\t\ttestRect[ horizontalSide ] - collapsedRangeRect[ horizontalSide ];\n\n\t// Allow the position to be 1px off.\n\tconst hasVerticalDiff = Math.abs( verticalDiff ) <= 1;\n\tconst hasHorizontalDiff = Math.abs( horizontalDiff ) <= 1;\n\n\treturn onlyVertical\n\t\t? hasVerticalDiff\n\t\t: hasVerticalDiff && hasHorizontalDiff;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,sBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,mBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,0BAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,kBAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,gBAAA,GAAAP,OAAA;AAVA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASQ,MAAMA,CAAEC,SAAS,EAAEC,SAAS,EAAEC,YAAY,GAAG,KAAK,EAAG;EAC5E,IACC,IAAAC,0BAAiB,EAAEH,SAAU,CAAC,IAC9B,OAAOA,SAAS,CAACI,cAAc,KAAK,QAAQ,EAC3C;IACD,IAAKJ,SAAS,CAACI,cAAc,KAAKJ,SAAS,CAACK,YAAY,EAAG;MAC1D,OAAO,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e,CAAC,IAAI,CAAC;EAEzD,OAAO5C,YAAY,GAChB6C,eAAe,GACfA,eAAe,IAAIG,iBAAiB;AACxC"}
1
+ {"version":3,"names":["_isRtl","_interopRequireDefault","require","_getRangeHeight","_getRectangleFromRange","_isSelectionForward","_hiddenCaretRangeFromPoint","_assertIsDefined","_isInputOrTextArea","_scrollIfNoRange","isEdge","container","isReverse","onlyVertical","isInputOrTextArea","selectionStart","selectionEnd","value","length","isContentEditable","ownerDocument","defaultView","assertIsDefined","selection","getSelection","rangeCount","range","getRangeAt","collapsedRange","cloneRange","isForward","isSelectionForward","isCollapsed","collapse","collapsedRangeRect","getRectangleFromRange","rangeRect","rangeHeight","getRangeHeight","height","isReverseDir","isRTL","containerRect","getBoundingClientRect","x","left","right","y","top","bottom","testRange","scrollIfNoRange","hiddenCaretRangeFromPoint","testRect","verticalSide","horizontalSide","verticalDiff","horizontalDiff","hasVerticalDiff","Math","abs","hasHorizontalDiff"],"sources":["@wordpress/dom/src/dom/is-edge.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport isRTL from './is-rtl';\nimport getRangeHeight from './get-range-height';\nimport getRectangleFromRange from './get-rectangle-from-range';\nimport isSelectionForward from './is-selection-forward';\nimport hiddenCaretRangeFromPoint from './hidden-caret-range-from-point';\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\nimport { scrollIfNoRange } from './scroll-if-no-range';\n\n/**\n * Check whether the selection is at the edge of the container. Checks for\n * horizontal position by default. Set `onlyVertical` to true to check only\n * vertically.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse Set to true to check left, false to check right.\n * @param {boolean} [onlyVertical=false] Set to true to check only vertical position.\n *\n * @return {boolean} True if at the edge, false if not.\n */\nexport default function isEdge( container, isReverse, onlyVertical = false ) {\n\tif (\n\t\tisInputOrTextArea( container ) &&\n\t\ttypeof container.selectionStart === 'number'\n\t) {\n\t\tif ( container.selectionStart !== container.selectionEnd ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( isReverse ) {\n\t\t\treturn container.selectionStart === 0;\n\t\t}\n\n\t\treturn container.value.length === container.selectionStart;\n\t}\n\n\tif ( ! ( /** @type {HTMLElement} */ ( container ).isContentEditable ) ) {\n\t\treturn true;\n\t}\n\n\tconst { ownerDocument } = container;\n\tconst { defaultView } = ownerDocument;\n\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\n\tif ( ! selection || ! selection.rangeCount ) {\n\t\treturn false;\n\t}\n\n\tconst range = selection.getRangeAt( 0 );\n\tconst collapsedRange = range.cloneRange();\n\tconst isForward = isSelectionForward( selection );\n\tconst isCollapsed = selection.isCollapsed;\n\n\t// Collapse in direction of selection.\n\tif ( ! isCollapsed ) {\n\t\tcollapsedRange.collapse( ! isForward );\n\t}\n\n\tconst collapsedRangeRect = getRectangleFromRange( collapsedRange );\n\tconst rangeRect = getRectangleFromRange( range );\n\n\tif ( ! collapsedRangeRect || ! rangeRect ) {\n\t\treturn false;\n\t}\n\n\t// Only consider the multiline selection at the edge if the direction is\n\t// towards the edge. The selection is multiline if it is taller than the\n\t// collapsed selection.\n\tconst rangeHeight = getRangeHeight( range );\n\tif (\n\t\t! isCollapsed &&\n\t\trangeHeight &&\n\t\trangeHeight > collapsedRangeRect.height &&\n\t\tisForward === isReverse\n\t) {\n\t\treturn false;\n\t}\n\n\t// In the case of RTL scripts, the horizontal edge is at the opposite side.\n\tconst isReverseDir = isRTL( container ) ? ! isReverse : isReverse;\n\tconst containerRect = container.getBoundingClientRect();\n\n\t// To check if a selection is at the edge, we insert a test selection at the\n\t// edge of the container and check if the selections have the same vertical\n\t// or horizontal position. If they do, the selection is at the edge.\n\t// This method proves to be better than a DOM-based calculation for the\n\t// horizontal edge, since it ignores empty textnodes and a trailing line\n\t// break element. In other words, we need to check visual positioning, not\n\t// DOM positioning.\n\t// It also proves better than using the computed style for the vertical\n\t// edge, because we cannot know the padding and line height reliably in\n\t// pixels. `getComputedStyle` may return a value with different units.\n\tconst x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;\n\tconst y = isReverse ? containerRect.top + 1 : containerRect.bottom - 1;\n\tconst testRange = scrollIfNoRange( container, isReverse, () =>\n\t\thiddenCaretRangeFromPoint( ownerDocument, x, y, container )\n\t);\n\n\tif ( ! testRange ) {\n\t\treturn false;\n\t}\n\n\tconst testRect = getRectangleFromRange( testRange );\n\n\tif ( ! testRect ) {\n\t\treturn false;\n\t}\n\n\tconst verticalSide = isReverse ? 'top' : 'bottom';\n\tconst horizontalSide = isReverseDir ? 'left' : 'right';\n\tconst verticalDiff = testRect[ verticalSide ] - rangeRect[ verticalSide ];\n\tconst horizontalDiff =\n\t\ttestRect[ horizontalSide ] - collapsedRangeRect[ horizontalSide ];\n\n\t// Allow the position to be 1px off.\n\tconst hasVerticalDiff = Math.abs( verticalDiff ) <= 1;\n\tconst hasHorizontalDiff = Math.abs( horizontalDiff ) <= 1;\n\n\treturn onlyVertical\n\t\t? hasVerticalDiff\n\t\t: hasVerticalDiff && hasHorizontalDiff;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,sBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,mBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,0BAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,kBAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,gBAAA,GAAAP,OAAA;AAVA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASQ,MAAMA,CAAEC,SAAS,EAAEC,SAAS,EAAEC,YAAY,GAAG,KAAK,EAAG;EAC5E,IACC,IAAAC,0BAAiB,EAAEH,SAAU,CAAC,I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;EACA,MAAMG,eAAe,GAAGC,IAAI,CAACC,GAAG,CAAEJ,YAAa,CAAC,IAAI,CAAC;EACrD,MAAMK,iBAAiB,GAAGF,IAAI,CAACC,GAAG,CAAEH,cAAe,CAAC,IAAI,CAAC;EAEzD,OAAO5C,YAAY,GAChB6C,eAAe,GACfA,eAAe,IAAIG,iBAAiB;AACxC"}
@@ -24,8 +24,7 @@ function isEmpty(element) {
24
24
  } else if (!element.hasChildNodes()) {
25
25
  return true;
26
26
  }
27
- return (/** @type {Element[]} */Array.from(element.childNodes).every(isEmpty)
28
- );
27
+ return /** @type {Element[]} */Array.from(element.childNodes).every(isEmpty);
29
28
  default:
30
29
  return true;
31
30
  }
@@ -1 +1 @@
1
- {"version":3,"names":["isEmpty","element","nodeType","TEXT_NODE","test","nodeValue","ELEMENT_NODE","hasAttributes","hasChildNodes","Array","from","childNodes","every"],"sources":["@wordpress/dom/src/dom/is-empty.js"],"sourcesContent":["/**\n * Recursively checks if an element is empty. An element is not empty if it\n * contains text or contains elements with attributes such as images.\n *\n * @param {Element} element The element to check.\n *\n * @return {boolean} Whether or not the element is empty.\n */\nexport default function isEmpty( element ) {\n\tswitch ( element.nodeType ) {\n\t\tcase element.TEXT_NODE:\n\t\t\t// We cannot use \\s since it includes special spaces which we want\n\t\t\t// to preserve.\n\t\t\treturn /^[ \\f\\n\\r\\t\\v\\u00a0]*$/.test( element.nodeValue || '' );\n\t\tcase element.ELEMENT_NODE:\n\t\t\tif ( element.hasAttributes() ) {\n\t\t\t\treturn false;\n\t\t\t} else if ( ! element.hasChildNodes() ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn /** @type {Element[]} */ (\n\t\t\t\tArray.from( element.childNodes )\n\t\t\t).every( isEmpty );\n\t\tdefault:\n\t\t\treturn true;\n\t}\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,OAAOA,CAAEC,OAAO,EAAG;EAC1C,QAASA,OAAO,CAACC,QAAQ;IACxB,KAAKD,OAAO,CAACE,SAAS;MACrB;MACA;MACA,OAAO,wBAAwB,CAACC,IAAI,CAAEH,OAAO,CAACI,SAAS,IAAI,EAAG,CAAC;IAChE,KAAKJ,OAAO,CAACK,YAAY;MACxB,IAAKL,OAAO,CAACM,aAAa,CAAC,CAAC,EAAG;QAC9B,OAAO,KAAK;MACb,CAAC,MAAM,IAAK,CAAEN,OAAO,CAACO,aAAa,CAAC,CAAC,EAAG;QACvC,OAAO,IAAI;MACZ;MAEA,OAAO,yBACNC,KAAK,CAACC,IAAI,CAAET,OAAO,CAACU,UAAW,CAAC,CAC/BC,KAAK,CAAEZ,OAAQ;MAAC;IACnB;MACC,OAAO,IAAI;EACb;AACD"}
1
+ {"version":3,"names":["isEmpty","element","nodeType","TEXT_NODE","test","nodeValue","ELEMENT_NODE","hasAttributes","hasChildNodes","Array","from","childNodes","every"],"sources":["@wordpress/dom/src/dom/is-empty.js"],"sourcesContent":["/**\n * Recursively checks if an element is empty. An element is not empty if it\n * contains text or contains elements with attributes such as images.\n *\n * @param {Element} element The element to check.\n *\n * @return {boolean} Whether or not the element is empty.\n */\nexport default function isEmpty( element ) {\n\tswitch ( element.nodeType ) {\n\t\tcase element.TEXT_NODE:\n\t\t\t// We cannot use \\s since it includes special spaces which we want\n\t\t\t// to preserve.\n\t\t\treturn /^[ \\f\\n\\r\\t\\v\\u00a0]*$/.test( element.nodeValue || '' );\n\t\tcase element.ELEMENT_NODE:\n\t\t\tif ( element.hasAttributes() ) {\n\t\t\t\treturn false;\n\t\t\t} else if ( ! element.hasChildNodes() ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn /** @type {Element[]} */ (\n\t\t\t\tArray.from( element.childNodes )\n\t\t\t).every( isEmpty );\n\t\tdefault:\n\t\t\treturn true;\n\t}\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,OAAOA,CAAEC,OAAO,EAAG;EAC1C,QAASA,OAAO,CAACC,QAAQ;IACxB,KAAKD,OAAO,CAACE,SAAS;MACrB;MACA;MACA,OAAO,wBAAwB,CAACC,IAAI,CAAEH,OAAO,CAACI,SAAS,IAAI,EAAG,CAAC;IAChE,KAAKJ,OAAO,CAACK,YAAY;MACxB,IAAKL,OAAO,CAACM,aAAa,CAAC,CAAC,EAAG;QAC9B,OAAO,KAAK;MACb,CAAC,MAAM,IAAK,CAAEN,OAAO,CAACO,aAAa,CAAC,CAAC,EAAG;QACvC,OAAO,IAAI;MACZ;MAEA,OAAO,wBACNC,KAAK,CAACC,IAAI,CAAET,OAAO,CAACU,UAAW,CAAC,CAC/BC,KAAK,CAAEZ,OAAQ,CAAC;IACnB;MACC,OAAO,IAAI;EACb;AACD"}
package/build/index.js CHANGED
@@ -45,8 +45,8 @@ Object.keys(_dataTransfer).forEach(function (key) {
45
45
  }
46
46
  });
47
47
  });
48
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
49
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
48
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
49
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
50
50
  /**
51
51
  * Internal dependencies
52
52
  */
@@ -55,9 +55,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
55
55
  * Object grouping `focusable` and `tabbable` utils
56
56
  * under the keys with the same name.
57
57
  */
58
- const focus = {
58
+ const focus = exports.focus = {
59
59
  focusable,
60
60
  tabbable
61
61
  };
62
- exports.focus = focus;
63
62
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["focusable","_interopRequireWildcard","require","tabbable","_dom","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_phrasingContent","_dataTransfer","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","newObj","hasPropertyDescriptor","getOwnPropertyDescriptor","desc","set","focus"],"sources":["@wordpress/dom/src/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport * as focusable from './focusable';\nimport * as tabbable from './tabbable';\n\n/**\n * Object grouping `focusable` and `tabbable` utils\n * under the keys with the same name.\n */\nexport const focus = { focusable, tabbable };\n\nexport * from './dom';\nexport * from './phrasing-content';\nexport * from './data-transfer';\n"],"mappings":";;;;;;;;;AAGA,IAAAA,SAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,uBAAA,CAAAC,OAAA;A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AdhC;AACA;AACA;;AAIA;AACA;AACA;AACA;AACO,MAAMK,KAAK,GAAG;EAAElC,SAAS;EAAEG;AAAS,CAAC;AAACU,OAAA,CAAAqB,KAAA,GAAAA,KAAA"}
1
+ {"version":3,"names":["focusable","_interopRequireWildcard","require","tabbable","_dom","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_phrasingContent","_dataTransfer","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","n","__proto__","a","getOwnPropertyDescriptor","u","i","set","focus"],"sources":["@wordpress/dom/src/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport * as focusable from './focusable';\nimport * as tabbable from './tabbable';\n\n/**\n * Object grouping `focusable` and `tabbable` utils\n * under the keys with the same name.\n */\nexport const focus = { focusable, tabbable };\n\nexport * from './dom';\nexport * from './phrasing-content';\nexport * from './data-transfer';\n"],"mappings":";;;;;;;;;AAGA,IAAAA,SAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,uBAAA,CAAAC,OAAA;AAQA,IAAAE,IAAA,GAAAF,OAAA;AAAAG,MAAA,CAAAC,IAAA,CAAAF,IAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,IAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,IAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,gBAAA,GAAAf,OAAA;AAAAG,MAAA,CAAAC,IAAA,CAAAW,gBAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,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CAAAN,CAAA,UAAAG,CAAA,CAAAP,GAAA,CAAAI,CAAA,OAAAO,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAxB,MAAA,CAAAS,cAAA,IAAAT,MAAA,CAAAyB,wBAAA,WAAAC,CAAA,IAAAX,CAAA,oBAAAW,CAAA,IAAA1B,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAS,CAAA,EAAAW,CAAA,SAAAC,CAAA,GAAAH,CAAA,GAAAxB,MAAA,CAAAyB,wBAAA,CAAAV,CAAA,EAAAW,CAAA,UAAAC,CAAA,KAAAA,CAAA,CAAAhB,GAAA,IAAAgB,CAAA,CAAAC,GAAA,IAAA5B,MAAA,CAAAS,cAAA,CAAAa,CAAA,EAAAI,CAAA,EAAAC,CAAA,IAAAL,CAAA,CAAAI,CAAA,IAAAX,CAAA,CAAAW,CAAA,YAAAJ,CAAA,CAAAF,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAU,GAAA,CAAAb,CAAA,EAAAO,CAAA,GAAAA,CAAA;AAdhC;AACA;AACA;;AAIA;AACA;AACA;AACA;AACO,MAAMO,KAAK,GAAArB,OAAA,CAAAqB,KAAA,GAAG;EAAElC,SAAS;EAAEG;AAAS,CAAC"}
@@ -34,7 +34,6 @@ export default function getOffsetParent(node) {
34
34
  }
35
35
 
36
36
  // offsetParent is undocumented/draft.
37
- return (/** @type {Node & { offsetParent: Node }} */closestElement.offsetParent
38
- );
37
+ return /** @type {Node & { offsetParent: Node }} */closestElement.offsetParent;
39
38
  }
40
39
  //# sourceMappingURL=get-offset-parent.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getComputedStyle","getOffsetParent","node","closestElement","parentNode","nodeType","ELEMENT_NODE","position","offsetParent"],"sources":["@wordpress/dom/src/dom/get-offset-parent.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Returns the closest positioned element, or null under any of the conditions\n * of the offsetParent specification. Unlike offsetParent, this function is not\n * limited to HTMLElement and accepts any Node (e.g. Node.TEXT_NODE).\n *\n * @see https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetparent\n *\n * @param {Node} node Node from which to find offset parent.\n *\n * @return {Node | null} Offset parent.\n */\nexport default function getOffsetParent( node ) {\n\t// Cannot retrieve computed style or offset parent only anything other than\n\t// an element node, so find the closest element node.\n\tlet closestElement;\n\twhile ( ( closestElement = /** @type {Node} */ ( node.parentNode ) ) ) {\n\t\tif ( closestElement.nodeType === closestElement.ELEMENT_NODE ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( ! closestElement ) {\n\t\treturn null;\n\t}\n\n\t// If the closest element is already positioned, return it, as offsetParent\n\t// does not otherwise consider the node itself.\n\tif (\n\t\tgetComputedStyle( /** @type {Element} */ ( closestElement ) )\n\t\t\t.position !== 'static'\n\t) {\n\t\treturn closestElement;\n\t}\n\n\t// offsetParent is undocumented/draft.\n\treturn /** @type {Node & { offsetParent: Node }} */ ( closestElement )\n\t\t.offsetParent;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,gBAAgB,MAAM,sBAAsB;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,eAAeA,CAAEC,IAAI,EAAG;EAC/C;EACA;EACA,IAAIC,cAAc;EAClB,OAAUA,cAAc,GAAG,mBAAsBD,IAAI,CAACE,UAAY,EAAK;IACtE,IAAKD,cAAc,CAACE,QAAQ,KAAKF,cAAc,CAACG,YAAY,EAAG;MAC9D;IACD;EACD;EAEA,IAAK,CAAEH,cAAc,EAAG;IACvB,OAAO,IAAI;EACZ;;EAEA;EACA;EACA,IACCH,gBAAgB,EAAE,sBAAyBG,cAAiB,CAAC,CAC3DI,QAAQ,KAAK,QAAQ,EACtB;IACD,OAAOJ,cAAc;EACtB;;EAEA;EACA,OAAO,6CAA+CA,cAAc,CAClEK;EAAY;AACf"}
1
+ {"version":3,"names":["getComputedStyle","getOffsetParent","node","closestElement","parentNode","nodeType","ELEMENT_NODE","position","offsetParent"],"sources":["@wordpress/dom/src/dom/get-offset-parent.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Returns the closest positioned element, or null under any of the conditions\n * of the offsetParent specification. Unlike offsetParent, this function is not\n * limited to HTMLElement and accepts any Node (e.g. Node.TEXT_NODE).\n *\n * @see https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetparent\n *\n * @param {Node} node Node from which to find offset parent.\n *\n * @return {Node | null} Offset parent.\n */\nexport default function getOffsetParent( node ) {\n\t// Cannot retrieve computed style or offset parent only anything other than\n\t// an element node, so find the closest element node.\n\tlet closestElement;\n\twhile ( ( closestElement = /** @type {Node} */ ( node.parentNode ) ) ) {\n\t\tif ( closestElement.nodeType === closestElement.ELEMENT_NODE ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( ! closestElement ) {\n\t\treturn null;\n\t}\n\n\t// If the closest element is already positioned, return it, as offsetParent\n\t// does not otherwise consider the node itself.\n\tif (\n\t\tgetComputedStyle( /** @type {Element} */ ( closestElement ) )\n\t\t\t.position !== 'static'\n\t) {\n\t\treturn closestElement;\n\t}\n\n\t// offsetParent is undocumented/draft.\n\treturn /** @type {Node & { offsetParent: Node }} */ ( closestElement )\n\t\t.offsetParent;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,gBAAgB,MAAM,sBAAsB;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,eAAeA,CAAEC,IAAI,EAAG;EAC/C;EACA;EACA,IAAIC,cAAc;EAClB,OAAUA,cAAc,GAAG,mBAAsBD,IAAI,CAACE,UAAY,EAAK;IACtE,IAAKD,cAAc,CAACE,QAAQ,KAAKF,cAAc,CAACG,YAAY,EAAG;MAC9D;IACD;EACD;EAEA,IAAK,CAAEH,cAAc,EAAG;IACvB,OAAO,IAAI;EACZ;;EAEA;EACA;EACA,IACCH,gBAAgB,EAAE,sBAAyBG,cAAiB,CAAC,CAC3DI,QAAQ,KAAK,QAAQ,EACtB;IACD,OAAOJ,cAAc;EACtB;;EAEA;EACA,OAAO,4CAA+CA,cAAc,CAClEK,YAAY;AACf"}
@@ -31,7 +31,7 @@ export default function isEdge(container, isReverse, onlyVertical = false) {
31
31
  }
32
32
  return container.value.length === container.selectionStart;
33
33
  }
34
- if (! /** @type {HTMLElement} */container.isContentEditable) {
34
+ if (!( /** @type {HTMLElement} */container.isContentEditable)) {
35
35
  return true;
36
36
  }
37
37
  const {
@@ -1 +1 @@
1
- {"version":3,"names":["isRTL","getRangeHeight","getRectangleFromRange","isSelectionForward","hiddenCaretRangeFromPoint","assertIsDefined","isInputOrTextArea","scrollIfNoRange","isEdge","container","isReverse","onlyVertical","selectionStart","selectionEnd","value","length","isContentEditable","ownerDocument","defaultView","selection","getSelection","rangeCount","range","getRangeAt","collapsedRange","cloneRange","isForward","isCollapsed","collapse","collapsedRangeRect","rangeRect","rangeHeight","height","isReverseDir","containerRect","getBoundingClientRect","x","left","right","y","top","bottom","testRange","testRect","verticalSide","horizontalSide","verticalDiff","horizontalDiff","hasVerticalDiff","Math","abs","hasHorizontalDiff"],"sources":["@wordpress/dom/src/dom/is-edge.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport isRTL from './is-rtl';\nimport getRangeHeight from './get-range-height';\nimport getRectangleFromRange from './get-rectangle-from-range';\nimport isSelectionForward from './is-selection-forward';\nimport hiddenCaretRangeFromPoint from './hidden-caret-range-from-point';\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\nimport { scrollIfNoRange } from './scroll-if-no-range';\n\n/**\n * Check whether the selection is at the edge of the container. Checks for\n * horizontal position by default. Set `onlyVertical` to true to check only\n * vertically.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse Set to true to check left, false to check right.\n * @param {boolean} [onlyVertical=false] Set to true to check only vertical position.\n *\n * @return {boolean} True if at the edge, false if not.\n */\nexport default function isEdge( container, isReverse, onlyVertical = false ) {\n\tif (\n\t\tisInputOrTextArea( container ) &&\n\t\ttypeof container.selectionStart === 'number'\n\t) {\n\t\tif ( container.selectionStart !== container.selectionEnd ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( isReverse ) {\n\t\t\treturn container.selectionStart === 0;\n\t\t}\n\n\t\treturn container.value.length === container.selectionStart;\n\t}\n\n\tif ( ! ( /** @type {HTMLElement} */ ( container ).isContentEditable ) ) {\n\t\treturn true;\n\t}\n\n\tconst { ownerDocument } = container;\n\tconst { defaultView } = ownerDocument;\n\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\n\tif ( ! selection || ! selection.rangeCount ) {\n\t\treturn false;\n\t}\n\n\tconst range = selection.getRangeAt( 0 );\n\tconst collapsedRange = range.cloneRange();\n\tconst isForward = isSelectionForward( selection );\n\tconst isCollapsed = selection.isCollapsed;\n\n\t// Collapse in direction of selection.\n\tif ( ! isCollapsed ) {\n\t\tcollapsedRange.collapse( ! isForward );\n\t}\n\n\tconst collapsedRangeRect = getRectangleFromRange( collapsedRange );\n\tconst rangeRect = getRectangleFromRange( range );\n\n\tif ( ! collapsedRangeRect || ! rangeRect ) {\n\t\treturn false;\n\t}\n\n\t// Only consider the multiline selection at the edge if the direction is\n\t// towards the edge. The selection is multiline if it is taller than the\n\t// collapsed selection.\n\tconst rangeHeight = getRangeHeight( range );\n\tif (\n\t\t! isCollapsed &&\n\t\trangeHeight &&\n\t\trangeHeight > collapsedRangeRect.height &&\n\t\tisForward === isReverse\n\t) {\n\t\treturn false;\n\t}\n\n\t// In the case of RTL scripts, the horizontal edge is at the opposite side.\n\tconst isReverseDir = isRTL( container ) ? ! isReverse : isReverse;\n\tconst containerRect = container.getBoundingClientRect();\n\n\t// To check if a selection is at the edge, we insert a test selection at the\n\t// edge of the container and check if the selections have the same vertical\n\t// or horizontal position. If they do, the selection is at the edge.\n\t// This method proves to be better than a DOM-based calculation for the\n\t// horizontal edge, since it ignores empty textnodes and a trailing line\n\t// break element. In other words, we need to check visual positioning, not\n\t// DOM positioning.\n\t// It also proves better than using the computed style for the vertical\n\t// edge, because we cannot know the padding and line height reliably in\n\t// pixels. `getComputedStyle` may return a value with different units.\n\tconst x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;\n\tconst y = isReverse ? containerRect.top + 1 : containerRect.bottom - 1;\n\tconst testRange = scrollIfNoRange( container, isReverse, () =>\n\t\thiddenCaretRangeFromPoint( ownerDocument, x, y, container )\n\t);\n\n\tif ( ! testRange ) {\n\t\treturn false;\n\t}\n\n\tconst testRect = getRectangleFromRange( testRange );\n\n\tif ( ! testRect ) {\n\t\treturn false;\n\t}\n\n\tconst verticalSide = isReverse ? 'top' : 'bottom';\n\tconst horizontalSide = isReverseDir ? 'left' : 'right';\n\tconst verticalDiff = testRect[ verticalSide ] - rangeRect[ verticalSide ];\n\tconst horizontalDiff =\n\t\ttestRect[ horizontalSide ] - collapsedRangeRect[ horizontalSide ];\n\n\t// Allow the position to be 1px off.\n\tconst hasVerticalDiff = Math.abs( verticalDiff ) <= 1;\n\tconst hasHorizontalDiff = Math.abs( horizontalDiff ) <= 1;\n\n\treturn onlyVertical\n\t\t? hasVerticalDiff\n\t\t: hasVerticalDiff && hasHorizontalDiff;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,UAAU;AAC5B,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,kBAAkB,MAAM,wBAAwB;AACvD,OAAOC,yBAAyB,MAAM,iCAAiC;AACvE,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,OAAOC,iBAAiB,MAAM,yBAAyB;AACvD,SAASC,eAAe,QAAQ,sBAAsB;;AAEtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,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,CAAE,GAAGhB,kBAAkB,CAAEgB,cAAc,CAAE;;EAElE;EACA,MAAMG,eAAe,GAAGC,IAAI,CAACC,GAAG,CAAEJ,YAAa,CAAC,IAAI,CAAC;EACrD,MAAMK,iBAAiB,GAAGF,IAAI,CAACC,GAAG,CAAEH,cAAe,CAAC,IAAI,CAAC;EAEzD,OAAOpC,YAAY,GAChBqC,eAAe,GACfA,eAAe,IAAIG,iBAAiB;AACxC"}
1
+ {"version":3,"names":["isRTL","getRangeHeight","getRectangleFromRange","isSelectionForward","hiddenCaretRangeFromPoint","assertIsDefined","isInputOrTextArea","scrollIfNoRange","isEdge","container","isReverse","onlyVertical","selectionStart","selectionEnd","value","length","isContentEditable","ownerDocument","defaultView","selection","getSelection","rangeCount","range","getRangeAt","collapsedRange","cloneRange","isForward","isCollapsed","collapse","collapsedRangeRect","rangeRect","rangeHeight","height","isReverseDir","containerRect","getBoundingClientRect","x","left","right","y","top","bottom","testRange","testRect","verticalSide","horizontalSide","verticalDiff","horizontalDiff","hasVerticalDiff","Math","abs","hasHorizontalDiff"],"sources":["@wordpress/dom/src/dom/is-edge.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport isRTL from './is-rtl';\nimport getRangeHeight from './get-range-height';\nimport getRectangleFromRange from './get-rectangle-from-range';\nimport isSelectionForward from './is-selection-forward';\nimport hiddenCaretRangeFromPoint from './hidden-caret-range-from-point';\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\nimport { scrollIfNoRange } from './scroll-if-no-range';\n\n/**\n * Check whether the selection is at the edge of the container. Checks for\n * horizontal position by default. Set `onlyVertical` to true to check only\n * vertically.\n *\n * @param {HTMLElement} container Focusable element.\n * @param {boolean} isReverse Set to true to check left, false to check right.\n * @param {boolean} [onlyVertical=false] Set to true to check only vertical position.\n *\n * @return {boolean} True if at the edge, false if not.\n */\nexport default function isEdge( container, isReverse, onlyVertical = false ) {\n\tif (\n\t\tisInputOrTextArea( container ) &&\n\t\ttypeof container.selectionStart === 'number'\n\t) {\n\t\tif ( container.selectionStart !== container.selectionEnd ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( isReverse ) {\n\t\t\treturn container.selectionStart === 0;\n\t\t}\n\n\t\treturn container.value.length === container.selectionStart;\n\t}\n\n\tif ( ! ( /** @type {HTMLElement} */ ( container ).isContentEditable ) ) {\n\t\treturn true;\n\t}\n\n\tconst { ownerDocument } = container;\n\tconst { defaultView } = ownerDocument;\n\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\n\tif ( ! selection || ! selection.rangeCount ) {\n\t\treturn false;\n\t}\n\n\tconst range = selection.getRangeAt( 0 );\n\tconst collapsedRange = range.cloneRange();\n\tconst isForward = isSelectionForward( selection );\n\tconst isCollapsed = selection.isCollapsed;\n\n\t// Collapse in direction of selection.\n\tif ( ! isCollapsed ) {\n\t\tcollapsedRange.collapse( ! isForward );\n\t}\n\n\tconst collapsedRangeRect = getRectangleFromRange( collapsedRange );\n\tconst rangeRect = getRectangleFromRange( range );\n\n\tif ( ! collapsedRangeRect || ! rangeRect ) {\n\t\treturn false;\n\t}\n\n\t// Only consider the multiline selection at the edge if the direction is\n\t// towards the edge. The selection is multiline if it is taller than the\n\t// collapsed selection.\n\tconst rangeHeight = getRangeHeight( range );\n\tif (\n\t\t! isCollapsed &&\n\t\trangeHeight &&\n\t\trangeHeight > collapsedRangeRect.height &&\n\t\tisForward === isReverse\n\t) {\n\t\treturn false;\n\t}\n\n\t// In the case of RTL scripts, the horizontal edge is at the opposite side.\n\tconst isReverseDir = isRTL( container ) ? ! isReverse : isReverse;\n\tconst containerRect = container.getBoundingClientRect();\n\n\t// To check if a selection is at the edge, we insert a test selection at the\n\t// edge of the container and check if the selections have the same vertical\n\t// or horizontal position. If they do, the selection is at the edge.\n\t// This method proves to be better than a DOM-based calculation for the\n\t// horizontal edge, since it ignores empty textnodes and a trailing line\n\t// break element. In other words, we need to check visual positioning, not\n\t// DOM positioning.\n\t// It also proves better than using the computed style for the vertical\n\t// edge, because we cannot know the padding and line height reliably in\n\t// pixels. `getComputedStyle` may return a value with different units.\n\tconst x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;\n\tconst y = isReverse ? containerRect.top + 1 : containerRect.bottom - 1;\n\tconst testRange = scrollIfNoRange( container, isReverse, () =>\n\t\thiddenCaretRangeFromPoint( ownerDocument, x, y, container )\n\t);\n\n\tif ( ! testRange ) {\n\t\treturn false;\n\t}\n\n\tconst testRect = getRectangleFromRange( testRange );\n\n\tif ( ! testRect ) {\n\t\treturn false;\n\t}\n\n\tconst verticalSide = isReverse ? 'top' : 'bottom';\n\tconst horizontalSide = isReverseDir ? 'left' : 'right';\n\tconst verticalDiff = testRect[ verticalSide ] - rangeRect[ verticalSide ];\n\tconst horizontalDiff =\n\t\ttestRect[ horizontalSide ] - collapsedRangeRect[ horizontalSide ];\n\n\t// Allow the position to be 1px off.\n\tconst hasVerticalDiff = Math.abs( verticalDiff ) <= 1;\n\tconst hasHorizontalDiff = Math.abs( horizontalDiff ) <= 1;\n\n\treturn onlyVertical\n\t\t? hasVerticalDiff\n\t\t: hasVerticalDiff && hasHorizontalDiff;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,UAAU;AAC5B,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,kBAAkB,MAAM,wBAAwB;AACvD,OAAOC,yBAAyB,MAAM,iCAAiC;AACvE,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,OAAOC,iBAAiB,MAAM,yBAAyB;AACvD,SAASC,eAAe,QAAQ,sBAAsB;;AAEtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,MAAMA,CAAEC,SAAS,EAAEC,SAAS,EAAEC,YAAY,GAAG,KAAK,EAAG;EAC5E,IACCL,iBAAiB,CAAEG,SAAU,CAAC,IAC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CAAC,IAAI,CAAC;EACrD,MAAMK,iBAAiB,GAAGF,IAAI,CAACC,GAAG,CAAEH,cAAe,CAAC,IAAI,CAAC;EAEzD,OAAOpC,YAAY,GAChBqC,eAAe,GACfA,eAAe,IAAIG,iBAAiB;AACxC"}
@@ -18,8 +18,7 @@ export default function isEmpty(element) {
18
18
  } else if (!element.hasChildNodes()) {
19
19
  return true;
20
20
  }
21
- return (/** @type {Element[]} */Array.from(element.childNodes).every(isEmpty)
22
- );
21
+ return /** @type {Element[]} */Array.from(element.childNodes).every(isEmpty);
23
22
  default:
24
23
  return true;
25
24
  }
@@ -1 +1 @@
1
- {"version":3,"names":["isEmpty","element","nodeType","TEXT_NODE","test","nodeValue","ELEMENT_NODE","hasAttributes","hasChildNodes","Array","from","childNodes","every"],"sources":["@wordpress/dom/src/dom/is-empty.js"],"sourcesContent":["/**\n * Recursively checks if an element is empty. An element is not empty if it\n * contains text or contains elements with attributes such as images.\n *\n * @param {Element} element The element to check.\n *\n * @return {boolean} Whether or not the element is empty.\n */\nexport default function isEmpty( element ) {\n\tswitch ( element.nodeType ) {\n\t\tcase element.TEXT_NODE:\n\t\t\t// We cannot use \\s since it includes special spaces which we want\n\t\t\t// to preserve.\n\t\t\treturn /^[ \\f\\n\\r\\t\\v\\u00a0]*$/.test( element.nodeValue || '' );\n\t\tcase element.ELEMENT_NODE:\n\t\t\tif ( element.hasAttributes() ) {\n\t\t\t\treturn false;\n\t\t\t} else if ( ! element.hasChildNodes() ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn /** @type {Element[]} */ (\n\t\t\t\tArray.from( element.childNodes )\n\t\t\t).every( isEmpty );\n\t\tdefault:\n\t\t\treturn true;\n\t}\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,OAAOA,CAAEC,OAAO,EAAG;EAC1C,QAASA,OAAO,CAACC,QAAQ;IACxB,KAAKD,OAAO,CAACE,SAAS;MACrB;MACA;MACA,OAAO,wBAAwB,CAACC,IAAI,CAAEH,OAAO,CAACI,SAAS,IAAI,EAAG,CAAC;IAChE,KAAKJ,OAAO,CAACK,YAAY;MACxB,IAAKL,OAAO,CAACM,aAAa,CAAC,CAAC,EAAG;QAC9B,OAAO,KAAK;MACb,CAAC,MAAM,IAAK,CAAEN,OAAO,CAACO,aAAa,CAAC,CAAC,EAAG;QACvC,OAAO,IAAI;MACZ;MAEA,OAAO,yBACNC,KAAK,CAACC,IAAI,CAAET,OAAO,CAACU,UAAW,CAAC,CAC/BC,KAAK,CAAEZ,OAAQ;MAAC;IACnB;MACC,OAAO,IAAI;EACb;AACD"}
1
+ {"version":3,"names":["isEmpty","element","nodeType","TEXT_NODE","test","nodeValue","ELEMENT_NODE","hasAttributes","hasChildNodes","Array","from","childNodes","every"],"sources":["@wordpress/dom/src/dom/is-empty.js"],"sourcesContent":["/**\n * Recursively checks if an element is empty. An element is not empty if it\n * contains text or contains elements with attributes such as images.\n *\n * @param {Element} element The element to check.\n *\n * @return {boolean} Whether or not the element is empty.\n */\nexport default function isEmpty( element ) {\n\tswitch ( element.nodeType ) {\n\t\tcase element.TEXT_NODE:\n\t\t\t// We cannot use \\s since it includes special spaces which we want\n\t\t\t// to preserve.\n\t\t\treturn /^[ \\f\\n\\r\\t\\v\\u00a0]*$/.test( element.nodeValue || '' );\n\t\tcase element.ELEMENT_NODE:\n\t\t\tif ( element.hasAttributes() ) {\n\t\t\t\treturn false;\n\t\t\t} else if ( ! element.hasChildNodes() ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn /** @type {Element[]} */ (\n\t\t\t\tArray.from( element.childNodes )\n\t\t\t).every( isEmpty );\n\t\tdefault:\n\t\t\treturn true;\n\t}\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,OAAOA,CAAEC,OAAO,EAAG;EAC1C,QAASA,OAAO,CAACC,QAAQ;IACxB,KAAKD,OAAO,CAACE,SAAS;MACrB;MACA;MACA,OAAO,wBAAwB,CAACC,IAAI,CAAEH,OAAO,CAACI,SAAS,IAAI,EAAG,CAAC;IAChE,KAAKJ,OAAO,CAACK,YAAY;MACxB,IAAKL,OAAO,CAACM,aAAa,CAAC,CAAC,EAAG;QAC9B,OAAO,KAAK;MACb,CAAC,MAAM,IAAK,CAAEN,OAAO,CAACO,aAAa,CAAC,CAAC,EAAG;QACvC,OAAO,IAAI;MACZ;MAEA,OAAO,wBACNC,KAAK,CAACC,IAAI,CAAET,OAAO,CAACU,UAAW,CAAC,CAC/BC,KAAK,CAAEZ,OAAQ,CAAC;IACnB;MACC,OAAO,IAAI;EACb;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/dom",
3
- "version": "3.50.0",
3
+ "version": "3.51.0",
4
4
  "description": "DOM utilities module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -29,10 +29,10 @@
29
29
  "sideEffects": false,
30
30
  "dependencies": {
31
31
  "@babel/runtime": "^7.16.0",
32
- "@wordpress/deprecated": "^3.50.0"
32
+ "@wordpress/deprecated": "^3.51.0"
33
33
  },
34
34
  "publishConfig": {
35
35
  "access": "public"
36
36
  },
37
- "gitHead": "45de2cb4212fed7f2763e95f10300d1ff9d0ec08"
37
+ "gitHead": "eb796371e9630636a4a8837033807b0c4a06ed67"
38
38
  }