@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
@@ -1,27 +1,42 @@
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 replace_exports = {};
30
+ __export(replace_exports, {
31
+ default: () => replace
6
32
  });
7
- exports.default = replace;
8
- var _assertIsDefined = require("../utils/assert-is-defined");
9
- var _insertAfter = _interopRequireDefault(require("./insert-after"));
10
- var _remove = _interopRequireDefault(require("./remove"));
11
- /**
12
- * Internal dependencies
13
- */
14
-
15
- /**
16
- * Given two DOM nodes, replaces the former with the latter in the DOM.
17
- *
18
- * @param {Element} processedNode Node to be removed.
19
- * @param {Element} newNode Node to be inserted in its place.
20
- * @return {void}
21
- */
33
+ module.exports = __toCommonJS(replace_exports);
34
+ var import_assert_is_defined = require("../utils/assert-is-defined");
35
+ var import_insert_after = __toESM(require("./insert-after"));
36
+ var import_remove = __toESM(require("./remove"));
22
37
  function replace(processedNode, newNode) {
23
- (0, _assertIsDefined.assertIsDefined)(processedNode.parentNode, 'processedNode.parentNode');
24
- (0, _insertAfter.default)(newNode, processedNode.parentNode);
25
- (0, _remove.default)(processedNode);
38
+ (0, import_assert_is_defined.assertIsDefined)(processedNode.parentNode, "processedNode.parentNode");
39
+ (0, import_insert_after.default)(newNode, processedNode.parentNode);
40
+ (0, import_remove.default)(processedNode);
26
41
  }
27
- //# sourceMappingURL=replace.js.map
42
+ //# sourceMappingURL=replace.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_assertIsDefined","require","_insertAfter","_interopRequireDefault","_remove","replace","processedNode","newNode","assertIsDefined","parentNode","insertAfter","remove"],"sources":["@wordpress/dom/src/dom/replace.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport insertAfter from './insert-after';\nimport remove from './remove';\n\n/**\n * Given two DOM nodes, replaces the former with the latter in the DOM.\n *\n * @param {Element} processedNode Node to be removed.\n * @param {Element} newNode Node to be inserted in its place.\n * @return {void}\n */\nexport default function replace( processedNode, newNode ) {\n\tassertIsDefined( processedNode.parentNode, 'processedNode.parentNode' );\n\tinsertAfter( newNode, processedNode.parentNode );\n\tremove( processedNode );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAD,sBAAA,CAAAF,OAAA;AALA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASI,OAAOA,CAAEC,aAAa,EAAEC,OAAO,EAAG;EACzD,IAAAC,gCAAe,EAAEF,aAAa,CAACG,UAAU,EAAE,0BAA2B,CAAC;EACvE,IAAAC,oBAAW,EAAEH,OAAO,EAAED,aAAa,CAACG,UAAW,CAAC;EAChD,IAAAE,eAAM,EAAEL,aAAc,CAAC;AACxB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/replace.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport insertAfter from './insert-after';\nimport remove from './remove';\n\n/**\n * Given two DOM nodes, replaces the former with the latter in the DOM.\n *\n * @param {Element} processedNode Node to be removed.\n * @param {Element} newNode Node to be inserted in its place.\n * @return {void}\n */\nexport default function replace( processedNode, newNode ) {\n\tassertIsDefined( processedNode.parentNode, 'processedNode.parentNode' );\n\tinsertAfter( newNode, processedNode.parentNode );\n\tremove( processedNode );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,+BAAgC;AAChC,0BAAwB;AACxB,oBAAmB;AASJ,SAAR,QAA0B,eAAe,SAAU;AACzD,gDAAiB,cAAc,YAAY,0BAA2B;AACtE,0BAAAA,SAAa,SAAS,cAAc,UAAW;AAC/C,oBAAAC,SAAQ,aAAc;AACvB;",
6
+ "names": ["insertAfter", "remove"]
7
+ }
@@ -1,40 +1,51 @@
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 safe_html_exports = {};
30
+ __export(safe_html_exports, {
31
+ default: () => safeHTML
6
32
  });
7
- exports.default = safeHTML;
8
- var _remove = _interopRequireDefault(require("./remove"));
9
- /**
10
- * Internal dependencies
11
- */
12
-
13
- /**
14
- * Strips scripts and on* attributes from HTML.
15
- *
16
- * @param {string} html HTML to sanitize.
17
- *
18
- * @return {string} The sanitized HTML.
19
- */
33
+ module.exports = __toCommonJS(safe_html_exports);
34
+ var import_remove = __toESM(require("./remove"));
20
35
  function safeHTML(html) {
21
- const {
22
- body
23
- } = document.implementation.createHTMLDocument('');
36
+ const { body } = document.implementation.createHTMLDocument("");
24
37
  body.innerHTML = html;
25
- const elements = body.getElementsByTagName('*');
38
+ const elements = body.getElementsByTagName("*");
26
39
  let elementIndex = elements.length;
27
40
  while (elementIndex--) {
28
41
  const element = elements[elementIndex];
29
- if (element.tagName === 'SCRIPT') {
30
- (0, _remove.default)(element);
42
+ if (element.tagName === "SCRIPT") {
43
+ (0, import_remove.default)(element);
31
44
  } else {
32
45
  let attributeIndex = element.attributes.length;
33
46
  while (attributeIndex--) {
34
- const {
35
- name: key
36
- } = element.attributes[attributeIndex];
37
- if (key.startsWith('on')) {
47
+ const { name: key } = element.attributes[attributeIndex];
48
+ if (key.startsWith("on")) {
38
49
  element.removeAttribute(key);
39
50
  }
40
51
  }
@@ -42,4 +53,4 @@ function safeHTML(html) {
42
53
  }
43
54
  return body.innerHTML;
44
55
  }
45
- //# sourceMappingURL=safe-html.js.map
56
+ //# sourceMappingURL=safe-html.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_remove","_interopRequireDefault","require","safeHTML","html","body","document","implementation","createHTMLDocument","innerHTML","elements","getElementsByTagName","elementIndex","length","element","tagName","remove","attributeIndex","attributes","name","key","startsWith","removeAttribute"],"sources":["@wordpress/dom/src/dom/safe-html.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport remove from './remove';\n\n/**\n * Strips scripts and on* attributes from HTML.\n *\n * @param {string} html HTML to sanitize.\n *\n * @return {string} The sanitized HTML.\n */\nexport default function safeHTML( html ) {\n\tconst { body } = document.implementation.createHTMLDocument( '' );\n\tbody.innerHTML = html;\n\tconst elements = body.getElementsByTagName( '*' );\n\tlet elementIndex = elements.length;\n\n\twhile ( elementIndex-- ) {\n\t\tconst element = elements[ elementIndex ];\n\n\t\tif ( element.tagName === 'SCRIPT' ) {\n\t\t\tremove( element );\n\t\t} else {\n\t\t\tlet attributeIndex = element.attributes.length;\n\n\t\t\twhile ( attributeIndex-- ) {\n\t\t\t\tconst { name: key } = element.attributes[ attributeIndex ];\n\n\t\t\t\tif ( key.startsWith( 'on' ) ) {\n\t\t\t\t\telement.removeAttribute( key );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn body.innerHTML;\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,QAAQA,CAAEC,IAAI,EAAG;EACxC,MAAM;IAAEC;EAAK,CAAC,GAAGC,QAAQ,CAACC,cAAc,CAACC,kBAAkB,CAAE,EAAG,CAAC;EACjEH,IAAI,CAACI,SAAS,GAAGL,IAAI;EACrB,MAAMM,QAAQ,GAAGL,IAAI,CAACM,oBAAoB,CAAE,GAAI,CAAC;EACjD,IAAIC,YAAY,GAAGF,QAAQ,CAACG,MAAM;EAElC,OAAQD,YAAY,EAAE,EAAG;IACxB,MAAME,OAAO,GAAGJ,QAAQ,CAAEE,YAAY,CAAE;IAExC,IAAKE,OAAO,CAACC,OAAO,KAAK,QAAQ,EAAG;MACnC,IAAAC,eAAM,EAAEF,OAAQ,CAAC;IAClB,CAAC,MAAM;MACN,IAAIG,cAAc,GAAGH,OAAO,CAACI,UAAU,CAACL,MAAM;MAE9C,OAAQI,cAAc,EAAE,EAAG;QAC1B,MAAM;UAAEE,IAAI,EAAEC;QAAI,CAAC,GAAGN,OAAO,CAACI,UAAU,CAAED,cAAc,CAAE;QAE1D,IAAKG,GAAG,CAACC,UAAU,CAAE,IAAK,CAAC,EAAG;UAC7BP,OAAO,CAACQ,eAAe,CAAEF,GAAI,CAAC;QAC/B;MACD;IACD;EACD;EAEA,OAAOf,IAAI,CAACI,SAAS;AACtB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/safe-html.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport remove from './remove';\n\n/**\n * Strips scripts and on* attributes from HTML.\n *\n * @param {string} html HTML to sanitize.\n *\n * @return {string} The sanitized HTML.\n */\nexport default function safeHTML( html ) {\n\tconst { body } = document.implementation.createHTMLDocument( '' );\n\tbody.innerHTML = html;\n\tconst elements = body.getElementsByTagName( '*' );\n\tlet elementIndex = elements.length;\n\n\twhile ( elementIndex-- ) {\n\t\tconst element = elements[ elementIndex ];\n\n\t\tif ( element.tagName === 'SCRIPT' ) {\n\t\t\tremove( element );\n\t\t} else {\n\t\t\tlet attributeIndex = element.attributes.length;\n\n\t\t\twhile ( attributeIndex-- ) {\n\t\t\t\tconst { name: key } = element.attributes[ attributeIndex ];\n\n\t\t\t\tif ( key.startsWith( 'on' ) ) {\n\t\t\t\t\telement.removeAttribute( key );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn body.innerHTML;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAmB;AASJ,SAAR,SAA2B,MAAO;AACxC,QAAM,EAAE,KAAK,IAAI,SAAS,eAAe,mBAAoB,EAAG;AAChE,OAAK,YAAY;AACjB,QAAM,WAAW,KAAK,qBAAsB,GAAI;AAChD,MAAI,eAAe,SAAS;AAE5B,SAAQ,gBAAiB;AACxB,UAAM,UAAU,SAAU,YAAa;AAEvC,QAAK,QAAQ,YAAY,UAAW;AACnC,wBAAAA,SAAQ,OAAQ;AAAA,IACjB,OAAO;AACN,UAAI,iBAAiB,QAAQ,WAAW;AAExC,aAAQ,kBAAmB;AAC1B,cAAM,EAAE,MAAM,IAAI,IAAI,QAAQ,WAAY,cAAe;AAEzD,YAAK,IAAI,WAAY,IAAK,GAAI;AAC7B,kBAAQ,gBAAiB,GAAI;AAAA,QAC9B;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAEA,SAAO,KAAK;AACb;",
6
+ "names": ["remove"]
7
+ }
@@ -1,24 +1,28 @@
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 scroll_if_no_range_exports = {};
20
+ __export(scroll_if_no_range_exports, {
21
+ scrollIfNoRange: () => scrollIfNoRange
5
22
  });
6
- exports.scrollIfNoRange = scrollIfNoRange;
7
- /**
8
- * If no range range can be created or it is outside the container, the element
9
- * may be out of view, so scroll it into view and try again.
10
- *
11
- * @param {HTMLElement} container The container to scroll.
12
- * @param {boolean} alignToTop True to align to top, false to bottom.
13
- * @param {Function} callback The callback to create the range.
14
- *
15
- * @return {?Range} The range returned by the callback.
16
- */
23
+ module.exports = __toCommonJS(scroll_if_no_range_exports);
17
24
  function scrollIfNoRange(container, alignToTop, callback) {
18
25
  let range = callback();
19
-
20
- // If no range range can be created or it is outside the container, the
21
- // element may be out of view.
22
26
  if (!range || !range.startContainer || !container.contains(range.startContainer)) {
23
27
  container.scrollIntoView(alignToTop);
24
28
  range = callback();
@@ -28,4 +32,8 @@ function scrollIfNoRange(container, alignToTop, callback) {
28
32
  }
29
33
  return range;
30
34
  }
31
- //# sourceMappingURL=scroll-if-no-range.js.map
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ scrollIfNoRange
38
+ });
39
+ //# sourceMappingURL=scroll-if-no-range.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["scrollIfNoRange","container","alignToTop","callback","range","startContainer","contains","scrollIntoView"],"sources":["@wordpress/dom/src/dom/scroll-if-no-range.js"],"sourcesContent":["/**\n * If no range range can be created or it is outside the container, the element\n * may be out of view, so scroll it into view and try again.\n *\n * @param {HTMLElement} container The container to scroll.\n * @param {boolean} alignToTop True to align to top, false to bottom.\n * @param {Function} callback The callback to create the range.\n *\n * @return {?Range} The range returned by the callback.\n */\nexport function scrollIfNoRange( container, alignToTop, callback ) {\n\tlet range = callback();\n\n\t// If no range range can be created or it is outside the container, the\n\t// element may be out of view.\n\tif (\n\t\t! range ||\n\t\t! range.startContainer ||\n\t\t! container.contains( range.startContainer )\n\t) {\n\t\tcontainer.scrollIntoView( alignToTop );\n\t\trange = callback();\n\n\t\tif (\n\t\t\t! range ||\n\t\t\t! range.startContainer ||\n\t\t\t! container.contains( range.startContainer )\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\treturn range;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAeA,CAAEC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,EAAG;EAClE,IAAIC,KAAK,GAAGD,QAAQ,CAAC,CAAC;;EAEtB;EACA;EACA,IACC,CAAEC,KAAK,IACP,CAAEA,KAAK,CAACC,cAAc,IACtB,CAAEJ,SAAS,CAACK,QAAQ,CAAEF,KAAK,CAACC,cAAe,CAAC,EAC3C;IACDJ,SAAS,CAACM,cAAc,CAAEL,UAAW,CAAC;IACtCE,KAAK,GAAGD,QAAQ,CAAC,CAAC;IAElB,IACC,CAAEC,KAAK,IACP,CAAEA,KAAK,CAACC,cAAc,IACtB,CAAEJ,SAAS,CAACK,QAAQ,CAAEF,KAAK,CAACC,cAAe,CAAC,EAC3C;MACD,OAAO,IAAI;IACZ;EACD;EAEA,OAAOD,KAAK;AACb","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/scroll-if-no-range.js"],
4
+ "sourcesContent": ["/**\n * If no range range can be created or it is outside the container, the element\n * may be out of view, so scroll it into view and try again.\n *\n * @param {HTMLElement} container The container to scroll.\n * @param {boolean} alignToTop True to align to top, false to bottom.\n * @param {Function} callback The callback to create the range.\n *\n * @return {?Range} The range returned by the callback.\n */\nexport function scrollIfNoRange( container, alignToTop, callback ) {\n\tlet range = callback();\n\n\t// If no range range can be created or it is outside the container, the\n\t// element may be out of view.\n\tif (\n\t\t! range ||\n\t\t! range.startContainer ||\n\t\t! container.contains( range.startContainer )\n\t) {\n\t\tcontainer.scrollIntoView( alignToTop );\n\t\trange = callback();\n\n\t\tif (\n\t\t\t! range ||\n\t\t\t! range.startContainer ||\n\t\t\t! container.contains( range.startContainer )\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\treturn range;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,SAAS,gBAAiB,WAAW,YAAY,UAAW;AAClE,MAAI,QAAQ,SAAS;AAIrB,MACC,CAAE,SACF,CAAE,MAAM,kBACR,CAAE,UAAU,SAAU,MAAM,cAAe,GAC1C;AACD,cAAU,eAAgB,UAAW;AACrC,YAAQ,SAAS;AAEjB,QACC,CAAE,SACF,CAAE,MAAM,kBACR,CAAE,UAAU,SAAU,MAAM,cAAe,GAC1C;AACD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -1,28 +1,41 @@
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 strip_html_exports = {};
30
+ __export(strip_html_exports, {
31
+ default: () => stripHTML
6
32
  });
7
- exports.default = stripHTML;
8
- var _safeHtml = _interopRequireDefault(require("./safe-html"));
9
- /**
10
- * Internal dependencies
11
- */
12
-
13
- /**
14
- * Removes any HTML tags from the provided string.
15
- *
16
- * @param {string} html The string containing html.
17
- *
18
- * @return {string} The text content with any html removed.
19
- */
33
+ module.exports = __toCommonJS(strip_html_exports);
34
+ var import_safe_html = __toESM(require("./safe-html"));
20
35
  function stripHTML(html) {
21
- // Remove any script tags or on* attributes otherwise their *contents* will be left
22
- // in place following removal of HTML tags.
23
- html = (0, _safeHtml.default)(html);
24
- const doc = document.implementation.createHTMLDocument('');
36
+ html = (0, import_safe_html.default)(html);
37
+ const doc = document.implementation.createHTMLDocument("");
25
38
  doc.body.innerHTML = html;
26
- return doc.body.textContent || '';
39
+ return doc.body.textContent || "";
27
40
  }
28
- //# sourceMappingURL=strip-html.js.map
41
+ //# sourceMappingURL=strip-html.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_safeHtml","_interopRequireDefault","require","stripHTML","html","safeHTML","doc","document","implementation","createHTMLDocument","body","innerHTML","textContent"],"sources":["@wordpress/dom/src/dom/strip-html.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport safeHTML from './safe-html';\n\n/**\n * Removes any HTML tags from the provided string.\n *\n * @param {string} html The string containing html.\n *\n * @return {string} The text content with any html removed.\n */\nexport default function stripHTML( html ) {\n\t// Remove any script tags or on* attributes otherwise their *contents* will be left\n\t// in place following removal of HTML tags.\n\thtml = safeHTML( html );\n\n\tconst doc = document.implementation.createHTMLDocument( '' );\n\tdoc.body.innerHTML = html;\n\treturn doc.body.textContent || '';\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,SAASA,CAAEC,IAAI,EAAG;EACzC;EACA;EACAA,IAAI,GAAG,IAAAC,iBAAQ,EAAED,IAAK,CAAC;EAEvB,MAAME,GAAG,GAAGC,QAAQ,CAACC,cAAc,CAACC,kBAAkB,CAAE,EAAG,CAAC;EAC5DH,GAAG,CAACI,IAAI,CAACC,SAAS,GAAGP,IAAI;EACzB,OAAOE,GAAG,CAACI,IAAI,CAACE,WAAW,IAAI,EAAE;AAClC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/strip-html.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport safeHTML from './safe-html';\n\n/**\n * Removes any HTML tags from the provided string.\n *\n * @param {string} html The string containing html.\n *\n * @return {string} The text content with any html removed.\n */\nexport default function stripHTML( html ) {\n\t// Remove any script tags or on* attributes otherwise their *contents* will be left\n\t// in place following removal of HTML tags.\n\thtml = safeHTML( html );\n\n\tconst doc = document.implementation.createHTMLDocument( '' );\n\tdoc.body.innerHTML = html;\n\treturn doc.body.textContent || '';\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAqB;AASN,SAAR,UAA4B,MAAO;AAGzC,aAAO,iBAAAA,SAAU,IAAK;AAEtB,QAAM,MAAM,SAAS,eAAe,mBAAoB,EAAG;AAC3D,MAAI,KAAK,YAAY;AACrB,SAAO,IAAI,KAAK,eAAe;AAChC;",
6
+ "names": ["safeHTML"]
7
+ }
@@ -1,27 +1,33 @@
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 unwrap_exports = {};
20
+ __export(unwrap_exports, {
21
+ default: () => unwrap
5
22
  });
6
- exports.default = unwrap;
7
- var _assertIsDefined = require("../utils/assert-is-defined");
8
- /**
9
- * Internal dependencies
10
- */
11
-
12
- /**
13
- * Unwrap the given node. This means any child nodes are moved to the parent.
14
- *
15
- * @param {Node} node The node to unwrap.
16
- *
17
- * @return {void}
18
- */
23
+ module.exports = __toCommonJS(unwrap_exports);
24
+ var import_assert_is_defined = require("../utils/assert-is-defined");
19
25
  function unwrap(node) {
20
26
  const parent = node.parentNode;
21
- (0, _assertIsDefined.assertIsDefined)(parent, 'node.parentNode');
27
+ (0, import_assert_is_defined.assertIsDefined)(parent, "node.parentNode");
22
28
  while (node.firstChild) {
23
29
  parent.insertBefore(node.firstChild, node);
24
30
  }
25
31
  parent.removeChild(node);
26
32
  }
27
- //# sourceMappingURL=unwrap.js.map
33
+ //# sourceMappingURL=unwrap.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_assertIsDefined","require","unwrap","node","parent","parentNode","assertIsDefined","firstChild","insertBefore","removeChild"],"sources":["@wordpress/dom/src/dom/unwrap.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Unwrap the given node. This means any child nodes are moved to the parent.\n *\n * @param {Node} node The node to unwrap.\n *\n * @return {void}\n */\nexport default function unwrap( node ) {\n\tconst parent = node.parentNode;\n\n\tassertIsDefined( parent, 'node.parentNode' );\n\n\twhile ( node.firstChild ) {\n\t\tparent.insertBefore( node.firstChild, node );\n\t}\n\n\tparent.removeChild( node );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,gBAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,MAAMA,CAAEC,IAAI,EAAG;EACtC,MAAMC,MAAM,GAAGD,IAAI,CAACE,UAAU;EAE9B,IAAAC,gCAAe,EAAEF,MAAM,EAAE,iBAAkB,CAAC;EAE5C,OAAQD,IAAI,CAACI,UAAU,EAAG;IACzBH,MAAM,CAACI,YAAY,CAAEL,IAAI,CAACI,UAAU,EAAEJ,IAAK,CAAC;EAC7C;EAEAC,MAAM,CAACK,WAAW,CAAEN,IAAK,CAAC;AAC3B","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/unwrap.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Unwrap the given node. This means any child nodes are moved to the parent.\n *\n * @param {Node} node The node to unwrap.\n *\n * @return {void}\n */\nexport default function unwrap( node ) {\n\tconst parent = node.parentNode;\n\n\tassertIsDefined( parent, 'node.parentNode' );\n\n\twhile ( node.firstChild ) {\n\t\tparent.insertBefore( node.firstChild, node );\n\t}\n\n\tparent.removeChild( node );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,+BAAgC;AASjB,SAAR,OAAyB,MAAO;AACtC,QAAM,SAAS,KAAK;AAEpB,gDAAiB,QAAQ,iBAAkB;AAE3C,SAAQ,KAAK,YAAa;AACzB,WAAO,aAAc,KAAK,YAAY,IAAK;AAAA,EAC5C;AAEA,SAAO,YAAa,IAAK;AAC1B;",
6
+ "names": []
7
+ }
package/build/dom/wrap.js CHANGED
@@ -1,23 +1,30 @@
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 wrap_exports = {};
20
+ __export(wrap_exports, {
21
+ default: () => wrap
5
22
  });
6
- exports.default = wrap;
7
- var _assertIsDefined = require("../utils/assert-is-defined");
8
- /**
9
- * Internal dependencies
10
- */
11
-
12
- /**
13
- * Wraps the given node with a new node with the given tag name.
14
- *
15
- * @param {Element} newNode The node to insert.
16
- * @param {Element} referenceNode The node to wrap.
17
- */
23
+ module.exports = __toCommonJS(wrap_exports);
24
+ var import_assert_is_defined = require("../utils/assert-is-defined");
18
25
  function wrap(newNode, referenceNode) {
19
- (0, _assertIsDefined.assertIsDefined)(referenceNode.parentNode, 'referenceNode.parentNode');
26
+ (0, import_assert_is_defined.assertIsDefined)(referenceNode.parentNode, "referenceNode.parentNode");
20
27
  referenceNode.parentNode.insertBefore(newNode, referenceNode);
21
28
  newNode.appendChild(referenceNode);
22
29
  }
23
- //# sourceMappingURL=wrap.js.map
30
+ //# sourceMappingURL=wrap.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["_assertIsDefined","require","wrap","newNode","referenceNode","assertIsDefined","parentNode","insertBefore","appendChild"],"sources":["@wordpress/dom/src/dom/wrap.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Wraps the given node with a new node with the given tag name.\n *\n * @param {Element} newNode The node to insert.\n * @param {Element} referenceNode The node to wrap.\n */\nexport default function wrap( newNode, referenceNode ) {\n\tassertIsDefined( referenceNode.parentNode, 'referenceNode.parentNode' );\n\treferenceNode.parentNode.insertBefore( newNode, referenceNode );\n\tnewNode.appendChild( referenceNode );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,gBAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,IAAIA,CAAEC,OAAO,EAAEC,aAAa,EAAG;EACtD,IAAAC,gCAAe,EAAED,aAAa,CAACE,UAAU,EAAE,0BAA2B,CAAC;EACvEF,aAAa,CAACE,UAAU,CAACC,YAAY,CAAEJ,OAAO,EAAEC,aAAc,CAAC;EAC/DD,OAAO,CAACK,WAAW,CAAEJ,aAAc,CAAC;AACrC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/wrap.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Wraps the given node with a new node with the given tag name.\n *\n * @param {Element} newNode The node to insert.\n * @param {Element} referenceNode The node to wrap.\n */\nexport default function wrap( newNode, referenceNode ) {\n\tassertIsDefined( referenceNode.parentNode, 'referenceNode.parentNode' );\n\treferenceNode.parentNode.insertBefore( newNode, referenceNode );\n\tnewNode.appendChild( referenceNode );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,+BAAgC;AAQjB,SAAR,KAAuB,SAAS,eAAgB;AACtD,gDAAiB,cAAc,YAAY,0BAA2B;AACtE,gBAAc,WAAW,aAAc,SAAS,aAAc;AAC9D,UAAQ,YAAa,aAAc;AACpC;",
6
+ "names": []
7
+ }
@@ -1,106 +1,73 @@
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 focusable_exports = {};
20
+ __export(focusable_exports, {
21
+ find: () => find
5
22
  });
6
- exports.find = find;
7
- /**
8
- * References:
9
- *
10
- * Focusable:
11
- * - https://www.w3.org/TR/html5/editing.html#focus-management
12
- *
13
- * Sequential focus navigation:
14
- * - https://www.w3.org/TR/html5/editing.html#sequential-focus-navigation-and-the-tabindex-attribute
15
- *
16
- * Disabled elements:
17
- * - https://www.w3.org/TR/html5/disabled-elements.html#disabled-elements
18
- *
19
- * getClientRects algorithm (requiring layout box):
20
- * - https://www.w3.org/TR/cssom-view-1/#extension-to-the-element-interface
21
- *
22
- * AREA elements associated with an IMG:
23
- * - https://w3c.github.io/html/editing.html#data-model
24
- */
25
-
26
- /**
27
- * Returns a CSS selector used to query for focusable elements.
28
- *
29
- * @param {boolean} sequential If set, only query elements that are sequentially
30
- * focusable. Non-interactive elements with a
31
- * negative `tabindex` are focusable but not
32
- * sequentially focusable.
33
- * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute
34
- *
35
- * @return {string} CSS selector.
36
- */
23
+ module.exports = __toCommonJS(focusable_exports);
37
24
  function buildSelector(sequential) {
38
- return [sequential ? '[tabindex]:not([tabindex^="-"])' : '[tabindex]', 'a[href]', 'button:not([disabled])', 'input:not([type="hidden"]):not([disabled])', 'select:not([disabled])', 'textarea:not([disabled])', 'iframe:not([tabindex^="-"])', 'object', 'embed', 'summary', 'area[href]', '[contenteditable]:not([contenteditable=false])'].join(',');
25
+ return [
26
+ sequential ? '[tabindex]:not([tabindex^="-"])' : "[tabindex]",
27
+ "a[href]",
28
+ "button:not([disabled])",
29
+ 'input:not([type="hidden"]):not([disabled])',
30
+ "select:not([disabled])",
31
+ "textarea:not([disabled])",
32
+ 'iframe:not([tabindex^="-"])',
33
+ "object",
34
+ "embed",
35
+ "summary",
36
+ "area[href]",
37
+ "[contenteditable]:not([contenteditable=false])"
38
+ ].join(",");
39
39
  }
40
-
41
- /**
42
- * Returns true if the specified element is visible (i.e. neither display: none
43
- * nor visibility: hidden).
44
- *
45
- * @param {HTMLElement} element DOM element to test.
46
- *
47
- * @return {boolean} Whether element is visible.
48
- */
49
40
  function isVisible(element) {
50
41
  return element.offsetWidth > 0 || element.offsetHeight > 0 || element.getClientRects().length > 0;
51
42
  }
52
-
53
- /**
54
- * Returns true if the specified area element is a valid focusable element, or
55
- * false otherwise. Area is only focusable if within a map where a named map
56
- * referenced by an image somewhere in the document.
57
- *
58
- * @param {HTMLAreaElement} element DOM area element to test.
59
- *
60
- * @return {boolean} Whether area element is valid for focus.
61
- */
62
43
  function isValidFocusableArea(element) {
63
- /** @type {HTMLMapElement | null} */
64
- const map = element.closest('map[name]');
44
+ const map = element.closest("map[name]");
65
45
  if (!map) {
66
46
  return false;
67
47
  }
68
-
69
- /** @type {HTMLImageElement | null} */
70
- const img = element.ownerDocument.querySelector('img[usemap="#' + map.name + '"]');
48
+ const img = element.ownerDocument.querySelector(
49
+ 'img[usemap="#' + map.name + '"]'
50
+ );
71
51
  return !!img && isVisible(img);
72
52
  }
73
-
74
- /**
75
- * Returns all focusable elements within a given context.
76
- *
77
- * @param {Element} context Element in which to search.
78
- * @param {Object} options
79
- * @param {boolean} [options.sequential] If set, only return elements that are
80
- * sequentially focusable.
81
- * Non-interactive elements with a
82
- * negative `tabindex` are focusable but
83
- * not sequentially focusable.
84
- * https://html.spec.whatwg.org/multipage/interaction.html#the-tabindex-attribute
85
- *
86
- * @return {HTMLElement[]} Focusable elements.
87
- */
88
- function find(context, {
89
- sequential = false
90
- } = {}) {
91
- /** @type {NodeListOf<HTMLElement>} */
53
+ function find(context, { sequential = false } = {}) {
92
54
  const elements = context.querySelectorAll(buildSelector(sequential));
93
- return Array.from(elements).filter(element => {
55
+ return Array.from(elements).filter((element) => {
94
56
  if (!isVisible(element)) {
95
57
  return false;
96
58
  }
97
- const {
98
- nodeName
99
- } = element;
100
- if ('AREA' === nodeName) {
101
- return isValidFocusableArea(/** @type {HTMLAreaElement} */element);
59
+ const { nodeName } = element;
60
+ if ("AREA" === nodeName) {
61
+ return isValidFocusableArea(
62
+ /** @type {HTMLAreaElement} */
63
+ element
64
+ );
102
65
  }
103
66
  return true;
104
67
  });
105
68
  }
106
- //# sourceMappingURL=focusable.js.map
69
+ // Annotate the CommonJS export names for ESM import in node:
70
+ 0 && (module.exports = {
71
+ find
72
+ });
73
+ //# sourceMappingURL=focusable.js.map