@wordpress/dom 4.31.1-next.f56bd8138.0 → 4.32.1-next.47f435fc9.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.
Files changed (186) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/data-transfer.js +30 -18
  3. package/build/data-transfer.js.map +7 -1
  4. package/build/dom/caret-range-from-point.js +22 -25
  5. package/build/dom/caret-range-from-point.js.map +7 -1
  6. package/build/dom/clean-node-list.js +122 -129
  7. package/build/dom/clean-node-list.js.map +7 -1
  8. package/build/dom/compute-caret-rect.js +36 -21
  9. package/build/dom/compute-caret-rect.js.map +7 -1
  10. package/build/dom/document-has-selection.js +36 -22
  11. package/build/dom/document-has-selection.js.map +7 -1
  12. package/build/dom/document-has-text-selection.js +25 -23
  13. package/build/dom/document-has-text-selection.js.map +7 -1
  14. package/build/dom/document-has-uncollapsed-selection.js +35 -22
  15. package/build/dom/document-has-uncollapsed-selection.js.map +7 -1
  16. package/build/dom/get-computed-style.js +27 -17
  17. package/build/dom/get-computed-style.js.map +7 -1
  18. package/build/dom/get-offset-parent.js +43 -32
  19. package/build/dom/get-offset-parent.js.map +7 -1
  20. package/build/dom/get-range-height.js +24 -18
  21. package/build/dom/get-range-height.js.map +7 -1
  22. package/build/dom/get-rectangle-from-range.js +47 -68
  23. package/build/dom/get-rectangle-from-range.js.map +7 -1
  24. package/build/dom/get-scroll-container.js +44 -37
  25. package/build/dom/get-scroll-container.js.map +7 -1
  26. package/build/dom/hidden-caret-range-from-point.js +39 -33
  27. package/build/dom/hidden-caret-range-from-point.js.map +7 -1
  28. package/build/dom/index.js +116 -195
  29. package/build/dom/index.js.map +7 -1
  30. package/build/dom/input-field-has-uncollapsed-selection.js +40 -42
  31. package/build/dom/input-field-has-uncollapsed-selection.js.map +7 -1
  32. package/build/dom/insert-after.js +24 -19
  33. package/build/dom/insert-after.js.map +7 -1
  34. package/build/dom/is-edge.js +57 -67
  35. package/build/dom/is-edge.js.map +7 -1
  36. package/build/dom/is-element.js +22 -11
  37. package/build/dom/is-element.js.map +7 -1
  38. package/build/dom/is-empty.js +27 -17
  39. package/build/dom/is-empty.js.map +7 -1
  40. package/build/dom/is-entirely-selected.js +46 -50
  41. package/build/dom/is-entirely-selected.js.map +7 -1
  42. package/build/dom/is-form-element.js +36 -24
  43. package/build/dom/is-form-element.js.map +7 -1
  44. package/build/dom/is-horizontal-edge.js +34 -20
  45. package/build/dom/is-horizontal-edge.js.map +7 -1
  46. package/build/dom/is-html-input-element.js +23 -12
  47. package/build/dom/is-html-input-element.js.map +7 -1
  48. package/build/dom/is-input-or-text-area.js +23 -12
  49. package/build/dom/is-input-or-text-area.js.map +7 -1
  50. package/build/dom/is-number-input.js +38 -29
  51. package/build/dom/is-number-input.js.map +7 -1
  52. package/build/dom/is-rtl.js +34 -19
  53. package/build/dom/is-rtl.js.map +7 -1
  54. package/build/dom/is-selection-forward.js +26 -40
  55. package/build/dom/is-selection-forward.js.map +7 -1
  56. package/build/dom/is-text-field.js +49 -24
  57. package/build/dom/is-text-field.js.map +7 -1
  58. package/build/dom/is-vertical-edge.js +34 -20
  59. package/build/dom/is-vertical-edge.js.map +7 -1
  60. package/build/dom/place-caret-at-edge.js +52 -55
  61. package/build/dom/place-caret-at-edge.js.map +7 -1
  62. package/build/dom/place-caret-at-horizontal-edge.js +34 -18
  63. package/build/dom/place-caret-at-horizontal-edge.js.map +7 -1
  64. package/build/dom/place-caret-at-vertical-edge.js +34 -19
  65. package/build/dom/place-caret-at-vertical-edge.js.map +7 -1
  66. package/build/dom/remove-invalid-html.js +35 -22
  67. package/build/dom/remove-invalid-html.js.map +7 -1
  68. package/build/dom/remove.js +24 -17
  69. package/build/dom/remove.js.map +7 -1
  70. package/build/dom/replace-tag.js +24 -19
  71. package/build/dom/replace-tag.js.map +7 -1
  72. package/build/dom/replace.js +38 -23
  73. package/build/dom/replace.js.map +7 -1
  74. package/build/dom/safe-html.js +39 -28
  75. package/build/dom/safe-html.js.map +7 -1
  76. package/build/dom/scroll-if-no-range.js +26 -18
  77. package/build/dom/scroll-if-no-range.js.map +7 -1
  78. package/build/dom/strip-html.js +36 -23
  79. package/build/dom/strip-html.js.map +7 -1
  80. package/build/dom/unwrap.js +24 -18
  81. package/build/dom/unwrap.js.map +7 -1
  82. package/build/dom/wrap.js +24 -17
  83. package/build/dom/wrap.js.map +7 -1
  84. package/build/focusable.js +52 -85
  85. package/build/focusable.js.map +7 -1
  86. package/build/index.js +44 -58
  87. package/build/index.js.map +7 -1
  88. package/build/phrasing-content.js +88 -128
  89. package/build/phrasing-content.js.map +7 -1
  90. package/build/tabbable.js +52 -137
  91. package/build/tabbable.js.map +7 -1
  92. package/build/utils/assert-is-defined.js +30 -7
  93. package/build/utils/assert-is-defined.js.map +7 -1
  94. package/build-module/data-transfer.js +9 -15
  95. package/build-module/data-transfer.js.map +7 -1
  96. package/build-module/dom/caret-range-from-point.js +5 -22
  97. package/build-module/dom/caret-range-from-point.js.map +7 -1
  98. package/build-module/dom/clean-node-list.js +94 -123
  99. package/build-module/dom/clean-node-list.js.map +7 -1
  100. package/build-module/dom/compute-caret-rect.js +8 -16
  101. package/build-module/dom/compute-caret-rect.js.map +7 -1
  102. package/build-module/dom/document-has-selection.js +8 -17
  103. package/build-module/dom/document-has-selection.js.map +7 -1
  104. package/build-module/dom/document-has-text-selection.js +8 -20
  105. package/build-module/dom/document-has-text-selection.js.map +7 -1
  106. package/build-module/dom/document-has-uncollapsed-selection.js +7 -17
  107. package/build-module/dom/document-has-uncollapsed-selection.js.map +7 -1
  108. package/build-module/dom/get-computed-style.js +10 -14
  109. package/build-module/dom/get-computed-style.js.map +7 -1
  110. package/build-module/dom/get-offset-parent.js +16 -28
  111. package/build-module/dom/get-offset-parent.js.map +7 -1
  112. package/build-module/dom/get-range-height.js +7 -15
  113. package/build-module/dom/get-range-height.js.map +7 -1
  114. package/build-module/dom/get-rectangle-from-range.js +30 -65
  115. package/build-module/dom/get-rectangle-from-range.js.map +7 -1
  116. package/build-module/dom/get-scroll-container.js +16 -32
  117. package/build-module/dom/get-scroll-container.js.map +7 -1
  118. package/build-module/dom/hidden-caret-range-from-point.js +11 -28
  119. package/build-module/dom/hidden-caret-range-from-point.js.map +7 -1
  120. package/build-module/dom/index.js +57 -28
  121. package/build-module/dom/index.js.map +7 -1
  122. package/build-module/dom/input-field-has-uncollapsed-selection.js +12 -37
  123. package/build-module/dom/input-field-has-uncollapsed-selection.js.map +7 -1
  124. package/build-module/dom/insert-after.js +7 -16
  125. package/build-module/dom/insert-after.js.map +7 -1
  126. package/build-module/dom/is-edge.js +24 -57
  127. package/build-module/dom/is-edge.js.map +7 -1
  128. package/build-module/dom/is-element.js +5 -8
  129. package/build-module/dom/is-element.js.map +7 -1
  130. package/build-module/dom/is-empty.js +10 -14
  131. package/build-module/dom/is-empty.js.map +7 -1
  132. package/build-module/dom/is-entirely-selected.js +18 -45
  133. package/build-module/dom/is-entirely-selected.js.map +7 -1
  134. package/build-module/dom/is-form-element.js +8 -19
  135. package/build-module/dom/is-form-element.js.map +7 -1
  136. package/build-module/dom/is-horizontal-edge.js +6 -15
  137. package/build-module/dom/is-horizontal-edge.js.map +7 -1
  138. package/build-module/dom/is-html-input-element.js +6 -9
  139. package/build-module/dom/is-html-input-element.js.map +7 -1
  140. package/build-module/dom/is-input-or-text-area.js +6 -9
  141. package/build-module/dom/is-input-or-text-area.js.map +7 -1
  142. package/build-module/dom/is-number-input.js +11 -25
  143. package/build-module/dom/is-number-input.js.map +7 -1
  144. package/build-module/dom/is-rtl.js +7 -15
  145. package/build-module/dom/is-rtl.js.map +7 -1
  146. package/build-module/dom/is-selection-forward.js +9 -37
  147. package/build-module/dom/is-selection-forward.js.map +7 -1
  148. package/build-module/dom/is-text-field.js +22 -20
  149. package/build-module/dom/is-text-field.js.map +7 -1
  150. package/build-module/dom/is-vertical-edge.js +6 -15
  151. package/build-module/dom/is-vertical-edge.js.map +7 -1
  152. package/build-module/dom/place-caret-at-edge.js +22 -48
  153. package/build-module/dom/place-caret-at-edge.js.map +7 -1
  154. package/build-module/dom/place-caret-at-horizontal-edge.js +7 -14
  155. package/build-module/dom/place-caret-at-horizontal-edge.js.map +7 -1
  156. package/build-module/dom/place-caret-at-vertical-edge.js +6 -14
  157. package/build-module/dom/place-caret-at-vertical-edge.js.map +7 -1
  158. package/build-module/dom/remove-invalid-html.js +7 -17
  159. package/build-module/dom/remove-invalid-html.js.map +7 -1
  160. package/build-module/dom/remove.js +7 -14
  161. package/build-module/dom/remove.js.map +7 -1
  162. package/build-module/dom/replace-tag.js +7 -16
  163. package/build-module/dom/replace-tag.js.map +7 -1
  164. package/build-module/dom/replace.js +9 -17
  165. package/build-module/dom/replace.js.map +7 -1
  166. package/build-module/dom/safe-html.js +11 -23
  167. package/build-module/dom/safe-html.js.map +7 -1
  168. package/build-module/dom/scroll-if-no-range.js +5 -15
  169. package/build-module/dom/scroll-if-no-range.js.map +7 -1
  170. package/build-module/dom/strip-html.js +8 -18
  171. package/build-module/dom/strip-html.js.map +7 -1
  172. package/build-module/dom/unwrap.js +7 -15
  173. package/build-module/dom/unwrap.js.map +7 -1
  174. package/build-module/dom/wrap.js +7 -14
  175. package/build-module/dom/wrap.js.map +7 -1
  176. package/build-module/focusable.js +30 -81
  177. package/build-module/focusable.js.map +7 -1
  178. package/build-module/index.js +9 -17
  179. package/build-module/index.js.map +7 -1
  180. package/build-module/phrasing-content.js +67 -125
  181. package/build-module/phrasing-content.js.map +7 -1
  182. package/build-module/tabbable.js +30 -133
  183. package/build-module/tabbable.js.map +7 -1
  184. package/build-module/utils/assert-is-defined.js +9 -4
  185. package/build-module/utils/assert-is-defined.js.map +7 -1
  186. package/package.json +11 -4
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.32.0 (2025-10-01)
6
+
5
7
  ## 4.31.0 (2025-09-17)
6
8
 
7
9
  ## 4.30.0 (2025-09-03)
@@ -1,28 +1,40 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var data_transfer_exports = {};
20
+ __export(data_transfer_exports, {
21
+ getFilesFromDataTransfer: () => getFilesFromDataTransfer
5
22
  });
6
- exports.getFilesFromDataTransfer = getFilesFromDataTransfer;
7
- /**
8
- * Gets all files from a DataTransfer object.
9
- *
10
- * @param {DataTransfer} dataTransfer DataTransfer object to inspect.
11
- *
12
- * @return {File[]} An array containing all files.
13
- */
23
+ module.exports = __toCommonJS(data_transfer_exports);
14
24
  function getFilesFromDataTransfer(dataTransfer) {
15
25
  const files = Array.from(dataTransfer.files);
16
- Array.from(dataTransfer.items).forEach(item => {
26
+ Array.from(dataTransfer.items).forEach((item) => {
17
27
  const file = item.getAsFile();
18
- if (file && !files.find(({
19
- name,
20
- type,
21
- size
22
- }) => name === file.name && type === file.type && size === file.size)) {
28
+ if (file && !files.find(
29
+ ({ name, type, size }) => name === file.name && type === file.type && size === file.size
30
+ )) {
23
31
  files.push(file);
24
32
  }
25
33
  });
26
34
  return files;
27
35
  }
28
- //# sourceMappingURL=data-transfer.js.map
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ getFilesFromDataTransfer
39
+ });
40
+ //# sourceMappingURL=data-transfer.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["getFilesFromDataTransfer","dataTransfer","files","Array","from","items","forEach","item","file","getAsFile","find","name","type","size","push"],"sources":["@wordpress/dom/src/data-transfer.js"],"sourcesContent":["/**\n * Gets all files from a DataTransfer object.\n *\n * @param {DataTransfer} dataTransfer DataTransfer object to inspect.\n *\n * @return {File[]} An array containing all files.\n */\nexport function getFilesFromDataTransfer( dataTransfer ) {\n\tconst files = Array.from( dataTransfer.files );\n\n\tArray.from( dataTransfer.items ).forEach( ( item ) => {\n\t\tconst file = item.getAsFile();\n\n\t\tif (\n\t\t\tfile &&\n\t\t\t! files.find(\n\t\t\t\t( { name, type, size } ) =>\n\t\t\t\t\tname === file.name &&\n\t\t\t\t\ttype === file.type &&\n\t\t\t\t\tsize === file.size\n\t\t\t)\n\t\t) {\n\t\t\tfiles.push( file );\n\t\t}\n\t} );\n\n\treturn files;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,wBAAwBA,CAAEC,YAAY,EAAG;EACxD,MAAMC,KAAK,GAAGC,KAAK,CAACC,IAAI,CAAEH,YAAY,CAACC,KAAM,CAAC;EAE9CC,KAAK,CAACC,IAAI,CAAEH,YAAY,CAACI,KAAM,CAAC,CAACC,OAAO,CAAIC,IAAI,IAAM;IACrD,MAAMC,IAAI,GAAGD,IAAI,CAACE,SAAS,CAAC,CAAC;IAE7B,IACCD,IAAI,IACJ,CAAEN,KAAK,CAACQ,IAAI,CACX,CAAE;MAAEC,IAAI;MAAEC,IAAI;MAAEC;IAAK,CAAC,KACrBF,IAAI,KAAKH,IAAI,CAACG,IAAI,IAClBC,IAAI,KAAKJ,IAAI,CAACI,IAAI,IAClBC,IAAI,KAAKL,IAAI,CAACK,IAChB,CAAC,EACA;MACDX,KAAK,CAACY,IAAI,CAAEN,IAAK,CAAC;IACnB;EACD,CAAE,CAAC;EAEH,OAAON,KAAK;AACb","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/data-transfer.js"],
4
+ "sourcesContent": ["/**\n * Gets all files from a DataTransfer object.\n *\n * @param {DataTransfer} dataTransfer DataTransfer object to inspect.\n *\n * @return {File[]} An array containing all files.\n */\nexport function getFilesFromDataTransfer( dataTransfer ) {\n\tconst files = Array.from( dataTransfer.files );\n\n\tArray.from( dataTransfer.items ).forEach( ( item ) => {\n\t\tconst file = item.getAsFile();\n\n\t\tif (\n\t\t\tfile &&\n\t\t\t! files.find(\n\t\t\t\t( { name, type, size } ) =>\n\t\t\t\t\tname === file.name &&\n\t\t\t\t\ttype === file.type &&\n\t\t\t\t\tsize === file.size\n\t\t\t)\n\t\t) {\n\t\t\tfiles.push( file );\n\t\t}\n\t} );\n\n\treturn files;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,yBAA0B,cAAe;AACxD,QAAM,QAAQ,MAAM,KAAM,aAAa,KAAM;AAE7C,QAAM,KAAM,aAAa,KAAM,EAAE,QAAS,CAAE,SAAU;AACrD,UAAM,OAAO,KAAK,UAAU;AAE5B,QACC,QACA,CAAE,MAAM;AAAA,MACP,CAAE,EAAE,MAAM,MAAM,KAAK,MACpB,SAAS,KAAK,QACd,SAAS,KAAK,QACd,SAAS,KAAK;AAAA,IAChB,GACC;AACD,YAAM,KAAM,IAAK;AAAA,IAClB;AAAA,EACD,CAAE;AAEF,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -1,21 +1,26 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var caret_range_from_point_exports = {};
20
+ __export(caret_range_from_point_exports, {
21
+ default: () => caretRangeFromPoint
5
22
  });
6
- exports.default = caretRangeFromPoint;
7
- /**
8
- * Polyfill.
9
- * Get a collapsed range for a given point.
10
- *
11
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint
12
- *
13
- * @param {DocumentMaybeWithCaretPositionFromPoint} doc The document of the range.
14
- * @param {number} x Horizontal position within the current viewport.
15
- * @param {number} y Vertical position within the current viewport.
16
- *
17
- * @return {Range | null} The best range for the given point.
18
- */
23
+ module.exports = __toCommonJS(caret_range_from_point_exports);
19
24
  function caretRangeFromPoint(doc, x, y) {
20
25
  if (doc.caretRangeFromPoint) {
21
26
  return doc.caretRangeFromPoint(x, y);
@@ -24,9 +29,6 @@ function caretRangeFromPoint(doc, x, y) {
24
29
  return null;
25
30
  }
26
31
  const point = doc.caretPositionFromPoint(x, y);
27
-
28
- // If x or y are negative, outside viewport, or there is no text entry node.
29
- // https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint
30
32
  if (!point) {
31
33
  return null;
32
34
  }
@@ -35,9 +37,4 @@ function caretRangeFromPoint(doc, x, y) {
35
37
  range.collapse(true);
36
38
  return range;
37
39
  }
38
-
39
- /**
40
- * @typedef {{caretPositionFromPoint?: (x: number, y: number)=> CaretPosition | null} & Document } DocumentMaybeWithCaretPositionFromPoint
41
- * @typedef {{ readonly offset: number; readonly offsetNode: Node; getClientRect(): DOMRect | null; }} CaretPosition
42
- */
43
- //# sourceMappingURL=caret-range-from-point.js.map
40
+ //# sourceMappingURL=caret-range-from-point.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["caretRangeFromPoint","doc","x","y","caretPositionFromPoint","point","range","createRange","setStart","offsetNode","offset","collapse"],"sources":["@wordpress/dom/src/dom/caret-range-from-point.js"],"sourcesContent":["/**\n * Polyfill.\n * Get a collapsed range for a given point.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint\n *\n * @param {DocumentMaybeWithCaretPositionFromPoint} doc The document of the range.\n * @param {number} x Horizontal position within the current viewport.\n * @param {number} y Vertical position within the current viewport.\n *\n * @return {Range | null} The best range for the given point.\n */\nexport default function caretRangeFromPoint( doc, x, y ) {\n\tif ( doc.caretRangeFromPoint ) {\n\t\treturn doc.caretRangeFromPoint( x, y );\n\t}\n\n\tif ( ! doc.caretPositionFromPoint ) {\n\t\treturn null;\n\t}\n\n\tconst point = doc.caretPositionFromPoint( x, y );\n\n\t// If x or y are negative, outside viewport, or there is no text entry node.\n\t// https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint\n\tif ( ! point ) {\n\t\treturn null;\n\t}\n\n\tconst range = doc.createRange();\n\n\trange.setStart( point.offsetNode, point.offset );\n\trange.collapse( true );\n\n\treturn range;\n}\n\n/**\n * @typedef {{caretPositionFromPoint?: (x: number, y: number)=> CaretPosition | null} & Document } DocumentMaybeWithCaretPositionFromPoint\n * @typedef {{ readonly offset: number; readonly offsetNode: Node; getClientRect(): DOMRect | null; }} CaretPosition\n */\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,mBAAmBA,CAAEC,GAAG,EAAEC,CAAC,EAAEC,CAAC,EAAG;EACxD,IAAKF,GAAG,CAACD,mBAAmB,EAAG;IAC9B,OAAOC,GAAG,CAACD,mBAAmB,CAAEE,CAAC,EAAEC,CAAE,CAAC;EACvC;EAEA,IAAK,CAAEF,GAAG,CAACG,sBAAsB,EAAG;IACnC,OAAO,IAAI;EACZ;EAEA,MAAMC,KAAK,GAAGJ,GAAG,CAACG,sBAAsB,CAAEF,CAAC,EAAEC,CAAE,CAAC;;EAEhD;EACA;EACA,IAAK,CAAEE,KAAK,EAAG;IACd,OAAO,IAAI;EACZ;EAEA,MAAMC,KAAK,GAAGL,GAAG,CAACM,WAAW,CAAC,CAAC;EAE/BD,KAAK,CAACE,QAAQ,CAAEH,KAAK,CAACI,UAAU,EAAEJ,KAAK,CAACK,MAAO,CAAC;EAChDJ,KAAK,CAACK,QAAQ,CAAE,IAAK,CAAC;EAEtB,OAAOL,KAAK;AACb;;AAEA;AACA;AACA;AACA","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/caret-range-from-point.js"],
4
+ "sourcesContent": ["/**\n * Polyfill.\n * Get a collapsed range for a given point.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint\n *\n * @param {DocumentMaybeWithCaretPositionFromPoint} doc The document of the range.\n * @param {number} x Horizontal position within the current viewport.\n * @param {number} y Vertical position within the current viewport.\n *\n * @return {Range | null} The best range for the given point.\n */\nexport default function caretRangeFromPoint( doc, x, y ) {\n\tif ( doc.caretRangeFromPoint ) {\n\t\treturn doc.caretRangeFromPoint( x, y );\n\t}\n\n\tif ( ! doc.caretPositionFromPoint ) {\n\t\treturn null;\n\t}\n\n\tconst point = doc.caretPositionFromPoint( x, y );\n\n\t// If x or y are negative, outside viewport, or there is no text entry node.\n\t// https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint\n\tif ( ! point ) {\n\t\treturn null;\n\t}\n\n\tconst range = doc.createRange();\n\n\trange.setStart( point.offsetNode, point.offset );\n\trange.collapse( true );\n\n\treturn range;\n}\n\n/**\n * @typedef {{caretPositionFromPoint?: (x: number, y: number)=> CaretPosition | null} & Document } DocumentMaybeWithCaretPositionFromPoint\n * @typedef {{ readonly offset: number; readonly offsetNode: Node; getClientRect(): DOMRect | null; }} CaretPosition\n */\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAYe,SAAR,oBAAsC,KAAK,GAAG,GAAI;AACxD,MAAK,IAAI,qBAAsB;AAC9B,WAAO,IAAI,oBAAqB,GAAG,CAAE;AAAA,EACtC;AAEA,MAAK,CAAE,IAAI,wBAAyB;AACnC,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,IAAI,uBAAwB,GAAG,CAAE;AAI/C,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,IAAI,YAAY;AAE9B,QAAM,SAAU,MAAM,YAAY,MAAM,MAAO;AAC/C,QAAM,SAAU,IAAK;AAErB,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -1,145 +1,138 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var clean_node_list_exports = {};
30
+ __export(clean_node_list_exports, {
31
+ default: () => cleanNodeList
6
32
  });
7
- exports.default = cleanNodeList;
8
- var _isEmpty = _interopRequireDefault(require("./is-empty"));
9
- var _remove = _interopRequireDefault(require("./remove"));
10
- var _unwrap = _interopRequireDefault(require("./unwrap"));
11
- var _phrasingContent = require("../phrasing-content");
12
- var _insertAfter = _interopRequireDefault(require("./insert-after"));
13
- var _isElement = _interopRequireDefault(require("./is-element"));
14
- /**
15
- * Internal dependencies
16
- */
17
-
18
- const noop = () => {};
19
-
20
- /* eslint-disable jsdoc/valid-types */
21
- /**
22
- * @typedef SchemaItem
23
- * @property {string[]} [attributes] Attributes.
24
- * @property {(string | RegExp)[]} [classes] Classnames or RegExp to test against.
25
- * @property {'*' | { [tag: string]: SchemaItem }} [children] Child schemas.
26
- * @property {string[]} [require] Selectors to test required children against. Leave empty or undefined if there are no requirements.
27
- * @property {boolean} allowEmpty Whether to allow nodes without children.
28
- * @property {(node: Node) => boolean} [isMatch] Function to test whether a node is a match. If left undefined any node will be assumed to match.
29
- */
30
-
31
- /** @typedef {{ [tag: string]: SchemaItem }} Schema */
32
- /* eslint-enable jsdoc/valid-types */
33
-
34
- /**
35
- * Given a schema, unwraps or removes nodes, attributes and classes on a node
36
- * list.
37
- *
38
- * @param {NodeList} nodeList The nodeList to filter.
39
- * @param {Document} doc The document of the nodeList.
40
- * @param {Schema} schema An array of functions that can mutate with the provided node.
41
- * @param {boolean} inline Whether to clean for inline mode.
42
- */
33
+ module.exports = __toCommonJS(clean_node_list_exports);
34
+ var import_is_empty = __toESM(require("./is-empty"));
35
+ var import_remove = __toESM(require("./remove"));
36
+ var import_unwrap = __toESM(require("./unwrap"));
37
+ var import_phrasing_content = require("../phrasing-content");
38
+ var import_insert_after = __toESM(require("./insert-after"));
39
+ var import_is_element = __toESM(require("./is-element"));
40
+ const noop = () => {
41
+ };
43
42
  function cleanNodeList(nodeList, doc, schema, inline) {
44
- Array.from(nodeList).forEach((/** @type {Node & { nextElementSibling?: unknown }} */node) => {
45
- const tag = node.nodeName.toLowerCase();
46
-
47
- // It's a valid child, if the tag exists in the schema without an isMatch
48
- // function, or with an isMatch function that matches the node.
49
- if (schema.hasOwnProperty(tag) && (!schema[tag].isMatch || schema[tag].isMatch?.(node))) {
50
- if ((0, _isElement.default)(node)) {
51
- const {
52
- attributes = [],
53
- classes = [],
54
- children,
55
- require = [],
56
- allowEmpty
57
- } = schema[tag];
58
-
59
- // If the node is empty and it's supposed to have children,
60
- // remove the node.
61
- if (children && !allowEmpty && (0, _isEmpty.default)(node)) {
62
- (0, _remove.default)(node);
63
- return;
64
- }
65
- if (node.hasAttributes()) {
66
- // Strip invalid attributes.
67
- Array.from(node.attributes).forEach(({
68
- name
69
- }) => {
70
- if (name !== 'class' && !attributes.includes(name)) {
71
- node.removeAttribute(name);
72
- }
73
- });
74
-
75
- // Strip invalid classes.
76
- // In jsdom-jscore, 'node.classList' can be undefined.
77
- // TODO: Explore patching this in jsdom-jscore.
78
- if (node.classList && node.classList.length) {
79
- const mattchers = classes.map(item => {
80
- if (item === '*') {
81
- // Keep all classes.
82
- return () => true;
83
- } else if (typeof item === 'string') {
84
- return (/** @type {string} */className) => className === item;
85
- } else if (item instanceof RegExp) {
86
- return (/** @type {string} */className) => item.test(className);
43
+ Array.from(nodeList).forEach(
44
+ (node) => {
45
+ const tag = node.nodeName.toLowerCase();
46
+ if (schema.hasOwnProperty(tag) && (!schema[tag].isMatch || schema[tag].isMatch?.(node))) {
47
+ if ((0, import_is_element.default)(node)) {
48
+ const {
49
+ attributes = [],
50
+ classes = [],
51
+ children,
52
+ require: require2 = [],
53
+ allowEmpty
54
+ } = schema[tag];
55
+ if (children && !allowEmpty && (0, import_is_empty.default)(node)) {
56
+ (0, import_remove.default)(node);
57
+ return;
58
+ }
59
+ if (node.hasAttributes()) {
60
+ Array.from(node.attributes).forEach(({ name }) => {
61
+ if (name !== "class" && !attributes.includes(name)) {
62
+ node.removeAttribute(name);
87
63
  }
88
- return noop;
89
64
  });
90
- Array.from(node.classList).forEach(name => {
91
- if (!mattchers.some(isMatch => isMatch(name))) {
92
- node.classList.remove(name);
65
+ if (node.classList && node.classList.length) {
66
+ const mattchers = classes.map((item) => {
67
+ if (item === "*") {
68
+ return () => true;
69
+ } else if (typeof item === "string") {
70
+ return (className) => className === item;
71
+ } else if (item instanceof RegExp) {
72
+ return (className) => item.test(className);
73
+ }
74
+ return noop;
75
+ });
76
+ Array.from(node.classList).forEach((name) => {
77
+ if (!mattchers.some(
78
+ (isMatch) => isMatch(name)
79
+ )) {
80
+ node.classList.remove(name);
81
+ }
82
+ });
83
+ if (!node.classList.length) {
84
+ node.removeAttribute("class");
93
85
  }
94
- });
95
- if (!node.classList.length) {
96
- node.removeAttribute('class');
97
86
  }
98
87
  }
99
- }
100
- if (node.hasChildNodes()) {
101
- // Do not filter any content.
102
- if (children === '*') {
103
- return;
104
- }
105
-
106
- // Continue if the node is supposed to have children.
107
- if (children) {
108
- // If a parent requires certain children, but it does
109
- // not have them, drop the parent and continue.
110
- if (require.length && !node.querySelector(require.join(','))) {
111
- cleanNodeList(node.childNodes, doc, schema, inline);
112
- (0, _unwrap.default)(node);
113
- // If the node is at the top, phrasing content, and
114
- // contains children that are block content, unwrap
115
- // the node because it is invalid.
116
- } else if (node.parentNode && node.parentNode.nodeName === 'BODY' && (0, _phrasingContent.isPhrasingContent)(node)) {
117
- cleanNodeList(node.childNodes, doc, schema, inline);
118
- if (Array.from(node.childNodes).some(child => !(0, _phrasingContent.isPhrasingContent)(child))) {
119
- (0, _unwrap.default)(node);
88
+ if (node.hasChildNodes()) {
89
+ if (children === "*") {
90
+ return;
91
+ }
92
+ if (children) {
93
+ if (require2.length && !node.querySelector(require2.join(","))) {
94
+ cleanNodeList(
95
+ node.childNodes,
96
+ doc,
97
+ schema,
98
+ inline
99
+ );
100
+ (0, import_unwrap.default)(node);
101
+ } else if (node.parentNode && node.parentNode.nodeName === "BODY" && (0, import_phrasing_content.isPhrasingContent)(node)) {
102
+ cleanNodeList(
103
+ node.childNodes,
104
+ doc,
105
+ schema,
106
+ inline
107
+ );
108
+ if (Array.from(node.childNodes).some(
109
+ (child) => !(0, import_phrasing_content.isPhrasingContent)(child)
110
+ )) {
111
+ (0, import_unwrap.default)(node);
112
+ }
113
+ } else {
114
+ cleanNodeList(
115
+ node.childNodes,
116
+ doc,
117
+ children,
118
+ inline
119
+ );
120
120
  }
121
121
  } else {
122
- cleanNodeList(node.childNodes, doc, children, inline);
123
- }
124
- // Remove children if the node is not supposed to have any.
125
- } else {
126
- while (node.firstChild) {
127
- (0, _remove.default)(node.firstChild);
122
+ while (node.firstChild) {
123
+ (0, import_remove.default)(node.firstChild);
124
+ }
128
125
  }
129
126
  }
130
127
  }
128
+ } else {
129
+ cleanNodeList(node.childNodes, doc, schema, inline);
130
+ if (inline && !(0, import_phrasing_content.isPhrasingContent)(node) && node.nextElementSibling) {
131
+ (0, import_insert_after.default)(doc.createElement("br"), node);
132
+ }
133
+ (0, import_unwrap.default)(node);
131
134
  }
132
- // Invalid child. Continue with schema at the same place and unwrap.
133
- } else {
134
- cleanNodeList(node.childNodes, doc, schema, inline);
135
-
136
- // For inline mode, insert a line break when unwrapping nodes that
137
- // are not phrasing content.
138
- if (inline && !(0, _phrasingContent.isPhrasingContent)(node) && node.nextElementSibling) {
139
- (0, _insertAfter.default)(doc.createElement('br'), node);
140
- }
141
- (0, _unwrap.default)(node);
142
135
  }
143
- });
136
+ );
144
137
  }
145
- //# sourceMappingURL=clean-node-list.js.map
138
+ //# sourceMappingURL=clean-node-list.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_isEmpty","_interopRequireDefault","require","_remove","_unwrap","_phrasingContent","_insertAfter","_isElement","noop","cleanNodeList","nodeList","doc","schema","inline","Array","from","forEach","node","tag","nodeName","toLowerCase","hasOwnProperty","isMatch","isElement","attributes","classes","children","allowEmpty","isEmpty","remove","hasAttributes","name","includes","removeAttribute","classList","length","mattchers","map","item","className","RegExp","test","some","hasChildNodes","querySelector","join","childNodes","unwrap","parentNode","isPhrasingContent","child","firstChild","nextElementSibling","insertAfter","createElement"],"sources":["@wordpress/dom/src/dom/clean-node-list.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport isEmpty from './is-empty';\nimport remove from './remove';\nimport unwrap from './unwrap';\nimport { isPhrasingContent } from '../phrasing-content';\nimport insertAfter from './insert-after';\nimport isElement from './is-element';\n\nconst noop = () => {};\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @typedef SchemaItem\n * @property {string[]} [attributes] Attributes.\n * @property {(string | RegExp)[]} [classes] Classnames or RegExp to test against.\n * @property {'*' | { [tag: string]: SchemaItem }} [children] Child schemas.\n * @property {string[]} [require] Selectors to test required children against. Leave empty or undefined if there are no requirements.\n * @property {boolean} allowEmpty Whether to allow nodes without children.\n * @property {(node: Node) => boolean} [isMatch] Function to test whether a node is a match. If left undefined any node will be assumed to match.\n */\n\n/** @typedef {{ [tag: string]: SchemaItem }} Schema */\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * Given a schema, unwraps or removes nodes, attributes and classes on a node\n * list.\n *\n * @param {NodeList} nodeList The nodeList to filter.\n * @param {Document} doc The document of the nodeList.\n * @param {Schema} schema An array of functions that can mutate with the provided node.\n * @param {boolean} inline Whether to clean for inline mode.\n */\nexport default function cleanNodeList( nodeList, doc, schema, inline ) {\n\tArray.from( nodeList ).forEach(\n\t\t( /** @type {Node & { nextElementSibling?: unknown }} */ node ) => {\n\t\t\tconst tag = node.nodeName.toLowerCase();\n\n\t\t\t// It's a valid child, if the tag exists in the schema without an isMatch\n\t\t\t// function, or with an isMatch function that matches the node.\n\t\t\tif (\n\t\t\t\tschema.hasOwnProperty( tag ) &&\n\t\t\t\t( ! schema[ tag ].isMatch || schema[ tag ].isMatch?.( node ) )\n\t\t\t) {\n\t\t\t\tif ( isElement( node ) ) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tattributes = [],\n\t\t\t\t\t\tclasses = [],\n\t\t\t\t\t\tchildren,\n\t\t\t\t\t\trequire = [],\n\t\t\t\t\t\tallowEmpty,\n\t\t\t\t\t} = schema[ tag ];\n\n\t\t\t\t\t// If the node is empty and it's supposed to have children,\n\t\t\t\t\t// remove the node.\n\t\t\t\t\tif ( children && ! allowEmpty && isEmpty( node ) ) {\n\t\t\t\t\t\tremove( node );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasAttributes() ) {\n\t\t\t\t\t\t// Strip invalid attributes.\n\t\t\t\t\t\tArray.from( node.attributes ).forEach( ( { name } ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tname !== 'class' &&\n\t\t\t\t\t\t\t\t! attributes.includes( name )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( name );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t// Strip invalid classes.\n\t\t\t\t\t\t// In jsdom-jscore, 'node.classList' can be undefined.\n\t\t\t\t\t\t// TODO: Explore patching this in jsdom-jscore.\n\t\t\t\t\t\tif ( node.classList && node.classList.length ) {\n\t\t\t\t\t\t\tconst mattchers = classes.map( ( item ) => {\n\t\t\t\t\t\t\t\tif ( item === '*' ) {\n\t\t\t\t\t\t\t\t\t// Keep all classes.\n\t\t\t\t\t\t\t\t\treturn () => true;\n\t\t\t\t\t\t\t\t} else if ( typeof item === 'string' ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ className\n\t\t\t\t\t\t\t\t\t) => className === item;\n\t\t\t\t\t\t\t\t} else if ( item instanceof RegExp ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ className\n\t\t\t\t\t\t\t\t\t) => item.test( className );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn noop;\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tArray.from( node.classList ).forEach( ( name ) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! mattchers.some( ( isMatch ) =>\n\t\t\t\t\t\t\t\t\t\tisMatch( name )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tnode.classList.remove( name );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tif ( ! node.classList.length ) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( 'class' );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasChildNodes() ) {\n\t\t\t\t\t\t// Do not filter any content.\n\t\t\t\t\t\tif ( children === '*' ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Continue if the node is supposed to have children.\n\t\t\t\t\t\tif ( children ) {\n\t\t\t\t\t\t\t// If a parent requires certain children, but it does\n\t\t\t\t\t\t\t// not have them, drop the parent and continue.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\trequire.length &&\n\t\t\t\t\t\t\t\t! node.querySelector( require.join( ',' ) )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t// If the node is at the top, phrasing content, and\n\t\t\t\t\t\t\t\t// contains children that are block content, unwrap\n\t\t\t\t\t\t\t\t// the node because it is invalid.\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\tnode.parentNode &&\n\t\t\t\t\t\t\t\tnode.parentNode.nodeName === 'BODY' &&\n\t\t\t\t\t\t\t\tisPhrasingContent( node )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tArray.from( node.childNodes ).some(\n\t\t\t\t\t\t\t\t\t\t( child ) =>\n\t\t\t\t\t\t\t\t\t\t\t! isPhrasingContent( child )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Remove children if the node is not supposed to have any.\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twhile ( node.firstChild ) {\n\t\t\t\t\t\t\t\tremove( node.firstChild );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Invalid child. Continue with schema at the same place and unwrap.\n\t\t\t} else {\n\t\t\t\tcleanNodeList( node.childNodes, doc, schema, inline );\n\n\t\t\t\t// For inline mode, insert a line break when unwrapping nodes that\n\t\t\t\t// are not phrasing content.\n\t\t\t\tif (\n\t\t\t\t\tinline &&\n\t\t\t\t\t! isPhrasingContent( node ) &&\n\t\t\t\t\tnode.nextElementSibling\n\t\t\t\t) {\n\t\t\t\t\tinsertAfter( doc.createElement( 'br' ), node );\n\t\t\t\t}\n\n\t\t\t\tunwrap( node );\n\t\t\t}\n\t\t}\n\t);\n}\n"],"mappings":"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","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/clean-node-list.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport isEmpty from './is-empty';\nimport remove from './remove';\nimport unwrap from './unwrap';\nimport { isPhrasingContent } from '../phrasing-content';\nimport insertAfter from './insert-after';\nimport isElement from './is-element';\n\nconst noop = () => {};\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @typedef SchemaItem\n * @property {string[]} [attributes] Attributes.\n * @property {(string | RegExp)[]} [classes] Classnames or RegExp to test against.\n * @property {'*' | { [tag: string]: SchemaItem }} [children] Child schemas.\n * @property {string[]} [require] Selectors to test required children against. Leave empty or undefined if there are no requirements.\n * @property {boolean} allowEmpty Whether to allow nodes without children.\n * @property {(node: Node) => boolean} [isMatch] Function to test whether a node is a match. If left undefined any node will be assumed to match.\n */\n\n/** @typedef {{ [tag: string]: SchemaItem }} Schema */\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * Given a schema, unwraps or removes nodes, attributes and classes on a node\n * list.\n *\n * @param {NodeList} nodeList The nodeList to filter.\n * @param {Document} doc The document of the nodeList.\n * @param {Schema} schema An array of functions that can mutate with the provided node.\n * @param {boolean} inline Whether to clean for inline mode.\n */\nexport default function cleanNodeList( nodeList, doc, schema, inline ) {\n\tArray.from( nodeList ).forEach(\n\t\t( /** @type {Node & { nextElementSibling?: unknown }} */ node ) => {\n\t\t\tconst tag = node.nodeName.toLowerCase();\n\n\t\t\t// It's a valid child, if the tag exists in the schema without an isMatch\n\t\t\t// function, or with an isMatch function that matches the node.\n\t\t\tif (\n\t\t\t\tschema.hasOwnProperty( tag ) &&\n\t\t\t\t( ! schema[ tag ].isMatch || schema[ tag ].isMatch?.( node ) )\n\t\t\t) {\n\t\t\t\tif ( isElement( node ) ) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tattributes = [],\n\t\t\t\t\t\tclasses = [],\n\t\t\t\t\t\tchildren,\n\t\t\t\t\t\trequire = [],\n\t\t\t\t\t\tallowEmpty,\n\t\t\t\t\t} = schema[ tag ];\n\n\t\t\t\t\t// If the node is empty and it's supposed to have children,\n\t\t\t\t\t// remove the node.\n\t\t\t\t\tif ( children && ! allowEmpty && isEmpty( node ) ) {\n\t\t\t\t\t\tremove( node );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasAttributes() ) {\n\t\t\t\t\t\t// Strip invalid attributes.\n\t\t\t\t\t\tArray.from( node.attributes ).forEach( ( { name } ) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tname !== 'class' &&\n\t\t\t\t\t\t\t\t! attributes.includes( name )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( name );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t// Strip invalid classes.\n\t\t\t\t\t\t// In jsdom-jscore, 'node.classList' can be undefined.\n\t\t\t\t\t\t// TODO: Explore patching this in jsdom-jscore.\n\t\t\t\t\t\tif ( node.classList && node.classList.length ) {\n\t\t\t\t\t\t\tconst mattchers = classes.map( ( item ) => {\n\t\t\t\t\t\t\t\tif ( item === '*' ) {\n\t\t\t\t\t\t\t\t\t// Keep all classes.\n\t\t\t\t\t\t\t\t\treturn () => true;\n\t\t\t\t\t\t\t\t} else if ( typeof item === 'string' ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ className\n\t\t\t\t\t\t\t\t\t) => className === item;\n\t\t\t\t\t\t\t\t} else if ( item instanceof RegExp ) {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t/** @type {string} */ className\n\t\t\t\t\t\t\t\t\t) => item.test( className );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\treturn noop;\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tArray.from( node.classList ).forEach( ( name ) => {\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\t! mattchers.some( ( isMatch ) =>\n\t\t\t\t\t\t\t\t\t\tisMatch( name )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tnode.classList.remove( name );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\tif ( ! node.classList.length ) {\n\t\t\t\t\t\t\t\tnode.removeAttribute( 'class' );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( node.hasChildNodes() ) {\n\t\t\t\t\t\t// Do not filter any content.\n\t\t\t\t\t\tif ( children === '*' ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Continue if the node is supposed to have children.\n\t\t\t\t\t\tif ( children ) {\n\t\t\t\t\t\t\t// If a parent requires certain children, but it does\n\t\t\t\t\t\t\t// not have them, drop the parent and continue.\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\trequire.length &&\n\t\t\t\t\t\t\t\t! node.querySelector( require.join( ',' ) )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t// If the node is at the top, phrasing content, and\n\t\t\t\t\t\t\t\t// contains children that are block content, unwrap\n\t\t\t\t\t\t\t\t// the node because it is invalid.\n\t\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t\tnode.parentNode &&\n\t\t\t\t\t\t\t\tnode.parentNode.nodeName === 'BODY' &&\n\t\t\t\t\t\t\t\tisPhrasingContent( node )\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t\tArray.from( node.childNodes ).some(\n\t\t\t\t\t\t\t\t\t\t( child ) =>\n\t\t\t\t\t\t\t\t\t\t\t! isPhrasingContent( child )\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t\tunwrap( node );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tcleanNodeList(\n\t\t\t\t\t\t\t\t\tnode.childNodes,\n\t\t\t\t\t\t\t\t\tdoc,\n\t\t\t\t\t\t\t\t\tchildren,\n\t\t\t\t\t\t\t\t\tinline\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Remove children if the node is not supposed to have any.\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\twhile ( node.firstChild ) {\n\t\t\t\t\t\t\t\tremove( node.firstChild );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// Invalid child. Continue with schema at the same place and unwrap.\n\t\t\t} else {\n\t\t\t\tcleanNodeList( node.childNodes, doc, schema, inline );\n\n\t\t\t\t// For inline mode, insert a line break when unwrapping nodes that\n\t\t\t\t// are not phrasing content.\n\t\t\t\tif (\n\t\t\t\t\tinline &&\n\t\t\t\t\t! isPhrasingContent( node ) &&\n\t\t\t\t\tnode.nextElementSibling\n\t\t\t\t) {\n\t\t\t\t\tinsertAfter( doc.createElement( 'br' ), node );\n\t\t\t\t}\n\n\t\t\t\tunwrap( node );\n\t\t\t}\n\t\t}\n\t);\n}\n"],
5
+ "mappings": "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",
6
+ "names": ["isElement", "require", "isEmpty", "remove", "unwrap", "insertAfter"]
7
+ }
@@ -1,30 +1,45 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var compute_caret_rect_exports = {};
30
+ __export(compute_caret_rect_exports, {
31
+ default: () => computeCaretRect
6
32
  });
7
- exports.default = computeCaretRect;
8
- var _getRectangleFromRange = _interopRequireDefault(require("./get-rectangle-from-range"));
9
- var _assertIsDefined = require("../utils/assert-is-defined");
10
- /**
11
- * Internal dependencies
12
- */
13
-
14
- /**
15
- * Get the rectangle for the selection in a container.
16
- *
17
- * @param {Window} win The window of the selection.
18
- *
19
- * @return {DOMRect | null} The rectangle.
20
- */
33
+ module.exports = __toCommonJS(compute_caret_rect_exports);
34
+ var import_get_rectangle_from_range = __toESM(require("./get-rectangle-from-range"));
35
+ var import_assert_is_defined = require("../utils/assert-is-defined");
21
36
  function computeCaretRect(win) {
22
37
  const selection = win.getSelection();
23
- (0, _assertIsDefined.assertIsDefined)(selection, 'selection');
38
+ (0, import_assert_is_defined.assertIsDefined)(selection, "selection");
24
39
  const range = selection.rangeCount ? selection.getRangeAt(0) : null;
25
40
  if (!range) {
26
41
  return null;
27
42
  }
28
- return (0, _getRectangleFromRange.default)(range);
43
+ return (0, import_get_rectangle_from_range.default)(range);
29
44
  }
30
- //# sourceMappingURL=compute-caret-rect.js.map
45
+ //# sourceMappingURL=compute-caret-rect.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_getRectangleFromRange","_interopRequireDefault","require","_assertIsDefined","computeCaretRect","win","selection","getSelection","assertIsDefined","range","rangeCount","getRangeAt","getRectangleFromRange"],"sources":["@wordpress/dom/src/dom/compute-caret-rect.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport getRectangleFromRange from './get-rectangle-from-range';\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Get the rectangle for the selection in a container.\n *\n * @param {Window} win The window of the selection.\n *\n * @return {DOMRect | null} The rectangle.\n */\nexport default function computeCaretRect( win ) {\n\tconst selection = win.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tconst range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;\n\n\tif ( ! range ) {\n\t\treturn null;\n\t}\n\n\treturn getRectangleFromRange( range );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,gBAAgBA,CAAEC,GAAG,EAAG;EAC/C,MAAMC,SAAS,GAAGD,GAAG,CAACE,YAAY,CAAC,CAAC;EACpC,IAAAC,gCAAe,EAAEF,SAAS,EAAE,WAAY,CAAC;EACzC,MAAMG,KAAK,GAAGH,SAAS,CAACI,UAAU,GAAGJ,SAAS,CAACK,UAAU,CAAE,CAAE,CAAC,GAAG,IAAI;EAErE,IAAK,CAAEF,KAAK,EAAG;IACd,OAAO,IAAI;EACZ;EAEA,OAAO,IAAAG,8BAAqB,EAAEH,KAAM,CAAC;AACtC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/compute-caret-rect.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport getRectangleFromRange from './get-rectangle-from-range';\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Get the rectangle for the selection in a container.\n *\n * @param {Window} win The window of the selection.\n *\n * @return {DOMRect | null} The rectangle.\n */\nexport default function computeCaretRect( win ) {\n\tconst selection = win.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tconst range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;\n\n\tif ( ! range ) {\n\t\treturn null;\n\t}\n\n\treturn getRectangleFromRange( range );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sCAAkC;AAClC,+BAAgC;AASjB,SAAR,iBAAmC,KAAM;AAC/C,QAAM,YAAY,IAAI,aAAa;AACnC,gDAAiB,WAAW,WAAY;AACxC,QAAM,QAAQ,UAAU,aAAa,UAAU,WAAY,CAAE,IAAI;AAEjE,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AAEA,aAAO,gCAAAA,SAAuB,KAAM;AACrC;",
6
+ "names": ["getRectangleFromRange"]
7
+ }
@@ -1,26 +1,40 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var document_has_selection_exports = {};
30
+ __export(document_has_selection_exports, {
31
+ default: () => documentHasSelection
6
32
  });
7
- exports.default = documentHasSelection;
8
- var _isTextField = _interopRequireDefault(require("./is-text-field"));
9
- var _isHtmlInputElement = _interopRequireDefault(require("./is-html-input-element"));
10
- var _documentHasTextSelection = _interopRequireDefault(require("./document-has-text-selection"));
11
- /**
12
- * Internal dependencies
13
- */
14
-
15
- /**
16
- * Check whether the current document has a selection. This includes focus in
17
- * input fields, textareas, and general rich-text selection.
18
- *
19
- * @param {Document} doc The document to check.
20
- *
21
- * @return {boolean} True if there is selection, false if not.
22
- */
33
+ module.exports = __toCommonJS(document_has_selection_exports);
34
+ var import_is_text_field = __toESM(require("./is-text-field"));
35
+ var import_is_html_input_element = __toESM(require("./is-html-input-element"));
36
+ var import_document_has_text_selection = __toESM(require("./document-has-text-selection"));
23
37
  function documentHasSelection(doc) {
24
- return !!doc.activeElement && ((0, _isHtmlInputElement.default)(doc.activeElement) || (0, _isTextField.default)(doc.activeElement) || (0, _documentHasTextSelection.default)(doc));
38
+ return !!doc.activeElement && ((0, import_is_html_input_element.default)(doc.activeElement) || (0, import_is_text_field.default)(doc.activeElement) || (0, import_document_has_text_selection.default)(doc));
25
39
  }
26
- //# sourceMappingURL=document-has-selection.js.map
40
+ //# sourceMappingURL=document-has-selection.js.map