@wordpress/dom 4.32.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 (185) hide show
  1. package/build/data-transfer.js +30 -18
  2. package/build/data-transfer.js.map +7 -1
  3. package/build/dom/caret-range-from-point.js +22 -25
  4. package/build/dom/caret-range-from-point.js.map +7 -1
  5. package/build/dom/clean-node-list.js +122 -129
  6. package/build/dom/clean-node-list.js.map +7 -1
  7. package/build/dom/compute-caret-rect.js +36 -21
  8. package/build/dom/compute-caret-rect.js.map +7 -1
  9. package/build/dom/document-has-selection.js +36 -22
  10. package/build/dom/document-has-selection.js.map +7 -1
  11. package/build/dom/document-has-text-selection.js +25 -23
  12. package/build/dom/document-has-text-selection.js.map +7 -1
  13. package/build/dom/document-has-uncollapsed-selection.js +35 -22
  14. package/build/dom/document-has-uncollapsed-selection.js.map +7 -1
  15. package/build/dom/get-computed-style.js +27 -17
  16. package/build/dom/get-computed-style.js.map +7 -1
  17. package/build/dom/get-offset-parent.js +43 -32
  18. package/build/dom/get-offset-parent.js.map +7 -1
  19. package/build/dom/get-range-height.js +24 -18
  20. package/build/dom/get-range-height.js.map +7 -1
  21. package/build/dom/get-rectangle-from-range.js +47 -68
  22. package/build/dom/get-rectangle-from-range.js.map +7 -1
  23. package/build/dom/get-scroll-container.js +44 -37
  24. package/build/dom/get-scroll-container.js.map +7 -1
  25. package/build/dom/hidden-caret-range-from-point.js +39 -33
  26. package/build/dom/hidden-caret-range-from-point.js.map +7 -1
  27. package/build/dom/index.js +116 -195
  28. package/build/dom/index.js.map +7 -1
  29. package/build/dom/input-field-has-uncollapsed-selection.js +40 -42
  30. package/build/dom/input-field-has-uncollapsed-selection.js.map +7 -1
  31. package/build/dom/insert-after.js +24 -19
  32. package/build/dom/insert-after.js.map +7 -1
  33. package/build/dom/is-edge.js +57 -67
  34. package/build/dom/is-edge.js.map +7 -1
  35. package/build/dom/is-element.js +22 -11
  36. package/build/dom/is-element.js.map +7 -1
  37. package/build/dom/is-empty.js +27 -17
  38. package/build/dom/is-empty.js.map +7 -1
  39. package/build/dom/is-entirely-selected.js +46 -50
  40. package/build/dom/is-entirely-selected.js.map +7 -1
  41. package/build/dom/is-form-element.js +36 -24
  42. package/build/dom/is-form-element.js.map +7 -1
  43. package/build/dom/is-horizontal-edge.js +34 -20
  44. package/build/dom/is-horizontal-edge.js.map +7 -1
  45. package/build/dom/is-html-input-element.js +23 -12
  46. package/build/dom/is-html-input-element.js.map +7 -1
  47. package/build/dom/is-input-or-text-area.js +23 -12
  48. package/build/dom/is-input-or-text-area.js.map +7 -1
  49. package/build/dom/is-number-input.js +38 -29
  50. package/build/dom/is-number-input.js.map +7 -1
  51. package/build/dom/is-rtl.js +34 -19
  52. package/build/dom/is-rtl.js.map +7 -1
  53. package/build/dom/is-selection-forward.js +26 -40
  54. package/build/dom/is-selection-forward.js.map +7 -1
  55. package/build/dom/is-text-field.js +49 -24
  56. package/build/dom/is-text-field.js.map +7 -1
  57. package/build/dom/is-vertical-edge.js +34 -20
  58. package/build/dom/is-vertical-edge.js.map +7 -1
  59. package/build/dom/place-caret-at-edge.js +52 -55
  60. package/build/dom/place-caret-at-edge.js.map +7 -1
  61. package/build/dom/place-caret-at-horizontal-edge.js +34 -18
  62. package/build/dom/place-caret-at-horizontal-edge.js.map +7 -1
  63. package/build/dom/place-caret-at-vertical-edge.js +34 -19
  64. package/build/dom/place-caret-at-vertical-edge.js.map +7 -1
  65. package/build/dom/remove-invalid-html.js +35 -22
  66. package/build/dom/remove-invalid-html.js.map +7 -1
  67. package/build/dom/remove.js +24 -17
  68. package/build/dom/remove.js.map +7 -1
  69. package/build/dom/replace-tag.js +24 -19
  70. package/build/dom/replace-tag.js.map +7 -1
  71. package/build/dom/replace.js +38 -23
  72. package/build/dom/replace.js.map +7 -1
  73. package/build/dom/safe-html.js +39 -28
  74. package/build/dom/safe-html.js.map +7 -1
  75. package/build/dom/scroll-if-no-range.js +26 -18
  76. package/build/dom/scroll-if-no-range.js.map +7 -1
  77. package/build/dom/strip-html.js +36 -23
  78. package/build/dom/strip-html.js.map +7 -1
  79. package/build/dom/unwrap.js +24 -18
  80. package/build/dom/unwrap.js.map +7 -1
  81. package/build/dom/wrap.js +24 -17
  82. package/build/dom/wrap.js.map +7 -1
  83. package/build/focusable.js +52 -85
  84. package/build/focusable.js.map +7 -1
  85. package/build/index.js +44 -58
  86. package/build/index.js.map +7 -1
  87. package/build/phrasing-content.js +88 -128
  88. package/build/phrasing-content.js.map +7 -1
  89. package/build/tabbable.js +52 -137
  90. package/build/tabbable.js.map +7 -1
  91. package/build/utils/assert-is-defined.js +30 -7
  92. package/build/utils/assert-is-defined.js.map +7 -1
  93. package/build-module/data-transfer.js +9 -15
  94. package/build-module/data-transfer.js.map +7 -1
  95. package/build-module/dom/caret-range-from-point.js +5 -22
  96. package/build-module/dom/caret-range-from-point.js.map +7 -1
  97. package/build-module/dom/clean-node-list.js +94 -123
  98. package/build-module/dom/clean-node-list.js.map +7 -1
  99. package/build-module/dom/compute-caret-rect.js +8 -16
  100. package/build-module/dom/compute-caret-rect.js.map +7 -1
  101. package/build-module/dom/document-has-selection.js +8 -17
  102. package/build-module/dom/document-has-selection.js.map +7 -1
  103. package/build-module/dom/document-has-text-selection.js +8 -20
  104. package/build-module/dom/document-has-text-selection.js.map +7 -1
  105. package/build-module/dom/document-has-uncollapsed-selection.js +7 -17
  106. package/build-module/dom/document-has-uncollapsed-selection.js.map +7 -1
  107. package/build-module/dom/get-computed-style.js +10 -14
  108. package/build-module/dom/get-computed-style.js.map +7 -1
  109. package/build-module/dom/get-offset-parent.js +16 -28
  110. package/build-module/dom/get-offset-parent.js.map +7 -1
  111. package/build-module/dom/get-range-height.js +7 -15
  112. package/build-module/dom/get-range-height.js.map +7 -1
  113. package/build-module/dom/get-rectangle-from-range.js +30 -65
  114. package/build-module/dom/get-rectangle-from-range.js.map +7 -1
  115. package/build-module/dom/get-scroll-container.js +16 -32
  116. package/build-module/dom/get-scroll-container.js.map +7 -1
  117. package/build-module/dom/hidden-caret-range-from-point.js +11 -28
  118. package/build-module/dom/hidden-caret-range-from-point.js.map +7 -1
  119. package/build-module/dom/index.js +57 -28
  120. package/build-module/dom/index.js.map +7 -1
  121. package/build-module/dom/input-field-has-uncollapsed-selection.js +12 -37
  122. package/build-module/dom/input-field-has-uncollapsed-selection.js.map +7 -1
  123. package/build-module/dom/insert-after.js +7 -16
  124. package/build-module/dom/insert-after.js.map +7 -1
  125. package/build-module/dom/is-edge.js +24 -57
  126. package/build-module/dom/is-edge.js.map +7 -1
  127. package/build-module/dom/is-element.js +5 -8
  128. package/build-module/dom/is-element.js.map +7 -1
  129. package/build-module/dom/is-empty.js +10 -14
  130. package/build-module/dom/is-empty.js.map +7 -1
  131. package/build-module/dom/is-entirely-selected.js +18 -45
  132. package/build-module/dom/is-entirely-selected.js.map +7 -1
  133. package/build-module/dom/is-form-element.js +8 -19
  134. package/build-module/dom/is-form-element.js.map +7 -1
  135. package/build-module/dom/is-horizontal-edge.js +6 -15
  136. package/build-module/dom/is-horizontal-edge.js.map +7 -1
  137. package/build-module/dom/is-html-input-element.js +6 -9
  138. package/build-module/dom/is-html-input-element.js.map +7 -1
  139. package/build-module/dom/is-input-or-text-area.js +6 -9
  140. package/build-module/dom/is-input-or-text-area.js.map +7 -1
  141. package/build-module/dom/is-number-input.js +11 -25
  142. package/build-module/dom/is-number-input.js.map +7 -1
  143. package/build-module/dom/is-rtl.js +7 -15
  144. package/build-module/dom/is-rtl.js.map +7 -1
  145. package/build-module/dom/is-selection-forward.js +9 -37
  146. package/build-module/dom/is-selection-forward.js.map +7 -1
  147. package/build-module/dom/is-text-field.js +22 -20
  148. package/build-module/dom/is-text-field.js.map +7 -1
  149. package/build-module/dom/is-vertical-edge.js +6 -15
  150. package/build-module/dom/is-vertical-edge.js.map +7 -1
  151. package/build-module/dom/place-caret-at-edge.js +22 -48
  152. package/build-module/dom/place-caret-at-edge.js.map +7 -1
  153. package/build-module/dom/place-caret-at-horizontal-edge.js +7 -14
  154. package/build-module/dom/place-caret-at-horizontal-edge.js.map +7 -1
  155. package/build-module/dom/place-caret-at-vertical-edge.js +6 -14
  156. package/build-module/dom/place-caret-at-vertical-edge.js.map +7 -1
  157. package/build-module/dom/remove-invalid-html.js +7 -17
  158. package/build-module/dom/remove-invalid-html.js.map +7 -1
  159. package/build-module/dom/remove.js +7 -14
  160. package/build-module/dom/remove.js.map +7 -1
  161. package/build-module/dom/replace-tag.js +7 -16
  162. package/build-module/dom/replace-tag.js.map +7 -1
  163. package/build-module/dom/replace.js +9 -17
  164. package/build-module/dom/replace.js.map +7 -1
  165. package/build-module/dom/safe-html.js +11 -23
  166. package/build-module/dom/safe-html.js.map +7 -1
  167. package/build-module/dom/scroll-if-no-range.js +5 -15
  168. package/build-module/dom/scroll-if-no-range.js.map +7 -1
  169. package/build-module/dom/strip-html.js +8 -18
  170. package/build-module/dom/strip-html.js.map +7 -1
  171. package/build-module/dom/unwrap.js +7 -15
  172. package/build-module/dom/unwrap.js.map +7 -1
  173. package/build-module/dom/wrap.js +7 -14
  174. package/build-module/dom/wrap.js.map +7 -1
  175. package/build-module/focusable.js +30 -81
  176. package/build-module/focusable.js.map +7 -1
  177. package/build-module/index.js +9 -17
  178. package/build-module/index.js.map +7 -1
  179. package/build-module/phrasing-content.js +67 -125
  180. package/build-module/phrasing-content.js.map +7 -1
  181. package/build-module/tabbable.js +30 -133
  182. package/build-module/tabbable.js.map +7 -1
  183. package/build-module/utils/assert-is-defined.js +9 -4
  184. package/build-module/utils/assert-is-defined.js.map +7 -1
  185. package/package.json +11 -4
@@ -1,137 +1,108 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import isEmpty from './is-empty';
5
- import remove from './remove';
6
- import unwrap from './unwrap';
7
- import { isPhrasingContent } from '../phrasing-content';
8
- import insertAfter from './insert-after';
9
- import isElement from './is-element';
10
- const noop = () => {};
11
-
12
- /* eslint-disable jsdoc/valid-types */
13
- /**
14
- * @typedef SchemaItem
15
- * @property {string[]} [attributes] Attributes.
16
- * @property {(string | RegExp)[]} [classes] Classnames or RegExp to test against.
17
- * @property {'*' | { [tag: string]: SchemaItem }} [children] Child schemas.
18
- * @property {string[]} [require] Selectors to test required children against. Leave empty or undefined if there are no requirements.
19
- * @property {boolean} allowEmpty Whether to allow nodes without children.
20
- * @property {(node: Node) => boolean} [isMatch] Function to test whether a node is a match. If left undefined any node will be assumed to match.
21
- */
22
-
23
- /** @typedef {{ [tag: string]: SchemaItem }} Schema */
24
- /* eslint-enable jsdoc/valid-types */
25
-
26
- /**
27
- * Given a schema, unwraps or removes nodes, attributes and classes on a node
28
- * list.
29
- *
30
- * @param {NodeList} nodeList The nodeList to filter.
31
- * @param {Document} doc The document of the nodeList.
32
- * @param {Schema} schema An array of functions that can mutate with the provided node.
33
- * @param {boolean} inline Whether to clean for inline mode.
34
- */
35
- export default function cleanNodeList(nodeList, doc, schema, inline) {
36
- Array.from(nodeList).forEach((/** @type {Node & { nextElementSibling?: unknown }} */node) => {
37
- const tag = node.nodeName.toLowerCase();
38
-
39
- // It's a valid child, if the tag exists in the schema without an isMatch
40
- // function, or with an isMatch function that matches the node.
41
- if (schema.hasOwnProperty(tag) && (!schema[tag].isMatch || schema[tag].isMatch?.(node))) {
42
- if (isElement(node)) {
43
- const {
44
- attributes = [],
45
- classes = [],
46
- children,
47
- require = [],
48
- allowEmpty
49
- } = schema[tag];
50
-
51
- // If the node is empty and it's supposed to have children,
52
- // remove the node.
53
- if (children && !allowEmpty && isEmpty(node)) {
54
- remove(node);
55
- return;
56
- }
57
- if (node.hasAttributes()) {
58
- // Strip invalid attributes.
59
- Array.from(node.attributes).forEach(({
60
- name
61
- }) => {
62
- if (name !== 'class' && !attributes.includes(name)) {
63
- node.removeAttribute(name);
64
- }
65
- });
66
-
67
- // Strip invalid classes.
68
- // In jsdom-jscore, 'node.classList' can be undefined.
69
- // TODO: Explore patching this in jsdom-jscore.
70
- if (node.classList && node.classList.length) {
71
- const mattchers = classes.map(item => {
72
- if (item === '*') {
73
- // Keep all classes.
74
- return () => true;
75
- } else if (typeof item === 'string') {
76
- return (/** @type {string} */className) => className === item;
77
- } else if (item instanceof RegExp) {
78
- return (/** @type {string} */className) => item.test(className);
1
+ import isEmpty from "./is-empty";
2
+ import remove from "./remove";
3
+ import unwrap from "./unwrap";
4
+ import { isPhrasingContent } from "../phrasing-content";
5
+ import insertAfter from "./insert-after";
6
+ import isElement from "./is-element";
7
+ const noop = () => {
8
+ };
9
+ function cleanNodeList(nodeList, doc, schema, inline) {
10
+ Array.from(nodeList).forEach(
11
+ (node) => {
12
+ const tag = node.nodeName.toLowerCase();
13
+ if (schema.hasOwnProperty(tag) && (!schema[tag].isMatch || schema[tag].isMatch?.(node))) {
14
+ if (isElement(node)) {
15
+ const {
16
+ attributes = [],
17
+ classes = [],
18
+ children,
19
+ require: require2 = [],
20
+ allowEmpty
21
+ } = schema[tag];
22
+ if (children && !allowEmpty && isEmpty(node)) {
23
+ remove(node);
24
+ return;
25
+ }
26
+ if (node.hasAttributes()) {
27
+ Array.from(node.attributes).forEach(({ name }) => {
28
+ if (name !== "class" && !attributes.includes(name)) {
29
+ node.removeAttribute(name);
79
30
  }
80
- return noop;
81
31
  });
82
- Array.from(node.classList).forEach(name => {
83
- if (!mattchers.some(isMatch => isMatch(name))) {
84
- node.classList.remove(name);
32
+ if (node.classList && node.classList.length) {
33
+ const mattchers = classes.map((item) => {
34
+ if (item === "*") {
35
+ return () => true;
36
+ } else if (typeof item === "string") {
37
+ return (className) => className === item;
38
+ } else if (item instanceof RegExp) {
39
+ return (className) => item.test(className);
40
+ }
41
+ return noop;
42
+ });
43
+ Array.from(node.classList).forEach((name) => {
44
+ if (!mattchers.some(
45
+ (isMatch) => isMatch(name)
46
+ )) {
47
+ node.classList.remove(name);
48
+ }
49
+ });
50
+ if (!node.classList.length) {
51
+ node.removeAttribute("class");
85
52
  }
86
- });
87
- if (!node.classList.length) {
88
- node.removeAttribute('class');
89
53
  }
90
54
  }
91
- }
92
- if (node.hasChildNodes()) {
93
- // Do not filter any content.
94
- if (children === '*') {
95
- return;
96
- }
97
-
98
- // Continue if the node is supposed to have children.
99
- if (children) {
100
- // If a parent requires certain children, but it does
101
- // not have them, drop the parent and continue.
102
- if (require.length && !node.querySelector(require.join(','))) {
103
- cleanNodeList(node.childNodes, doc, schema, inline);
104
- unwrap(node);
105
- // If the node is at the top, phrasing content, and
106
- // contains children that are block content, unwrap
107
- // the node because it is invalid.
108
- } else if (node.parentNode && node.parentNode.nodeName === 'BODY' && isPhrasingContent(node)) {
109
- cleanNodeList(node.childNodes, doc, schema, inline);
110
- if (Array.from(node.childNodes).some(child => !isPhrasingContent(child))) {
55
+ if (node.hasChildNodes()) {
56
+ if (children === "*") {
57
+ return;
58
+ }
59
+ if (children) {
60
+ if (require2.length && !node.querySelector(require2.join(","))) {
61
+ cleanNodeList(
62
+ node.childNodes,
63
+ doc,
64
+ schema,
65
+ inline
66
+ );
111
67
  unwrap(node);
68
+ } else if (node.parentNode && node.parentNode.nodeName === "BODY" && isPhrasingContent(node)) {
69
+ cleanNodeList(
70
+ node.childNodes,
71
+ doc,
72
+ schema,
73
+ inline
74
+ );
75
+ if (Array.from(node.childNodes).some(
76
+ (child) => !isPhrasingContent(child)
77
+ )) {
78
+ unwrap(node);
79
+ }
80
+ } else {
81
+ cleanNodeList(
82
+ node.childNodes,
83
+ doc,
84
+ children,
85
+ inline
86
+ );
112
87
  }
113
88
  } else {
114
- cleanNodeList(node.childNodes, doc, children, inline);
115
- }
116
- // Remove children if the node is not supposed to have any.
117
- } else {
118
- while (node.firstChild) {
119
- remove(node.firstChild);
89
+ while (node.firstChild) {
90
+ remove(node.firstChild);
91
+ }
120
92
  }
121
93
  }
122
94
  }
95
+ } else {
96
+ cleanNodeList(node.childNodes, doc, schema, inline);
97
+ if (inline && !isPhrasingContent(node) && node.nextElementSibling) {
98
+ insertAfter(doc.createElement("br"), node);
99
+ }
100
+ unwrap(node);
123
101
  }
124
- // Invalid child. Continue with schema at the same place and unwrap.
125
- } else {
126
- cleanNodeList(node.childNodes, doc, schema, inline);
127
-
128
- // For inline mode, insert a line break when unwrapping nodes that
129
- // are not phrasing content.
130
- if (inline && !isPhrasingContent(node) && node.nextElementSibling) {
131
- insertAfter(doc.createElement('br'), node);
132
- }
133
- unwrap(node);
134
102
  }
135
- });
103
+ );
136
104
  }
137
- //# sourceMappingURL=clean-node-list.js.map
105
+ export {
106
+ cleanNodeList as default
107
+ };
108
+ //# sourceMappingURL=clean-node-list.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["isEmpty","remove","unwrap","isPhrasingContent","insertAfter","isElement","noop","cleanNodeList","nodeList","doc","schema","inline","Array","from","forEach","node","tag","nodeName","toLowerCase","hasOwnProperty","isMatch","attributes","classes","children","require","allowEmpty","hasAttributes","name","includes","removeAttribute","classList","length","mattchers","map","item","className","RegExp","test","some","hasChildNodes","querySelector","join","childNodes","parentNode","child","firstChild","nextElementSibling","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": "AAGA,OAAO,aAAa;AACpB,OAAO,YAAY;AACnB,OAAO,YAAY;AACnB,SAAS,yBAAyB;AAClC,OAAO,iBAAiB;AACxB,OAAO,eAAe;AAEtB,MAAM,OAAO,MAAM;AAAC;AAyBL,SAAR,cAAgC,UAAU,KAAK,QAAQ,QAAS;AACtE,QAAM,KAAM,QAAS,EAAE;AAAA,IACtB,CAAyD,SAAU;AAClE,YAAM,MAAM,KAAK,SAAS,YAAY;AAItC,UACC,OAAO,eAAgB,GAAI,MACzB,CAAE,OAAQ,GAAI,EAAE,WAAW,OAAQ,GAAI,EAAE,UAAW,IAAK,IAC1D;AACD,YAAK,UAAW,IAAK,GAAI;AACxB,gBAAM;AAAA,YACL,aAAa,CAAC;AAAA,YACd,UAAU,CAAC;AAAA,YACX;AAAA,YACA,SAAAA,WAAU,CAAC;AAAA,YACX;AAAA,UACD,IAAI,OAAQ,GAAI;AAIhB,cAAK,YAAY,CAAE,cAAc,QAAS,IAAK,GAAI;AAClD,mBAAQ,IAAK;AACb;AAAA,UACD;AAEA,cAAK,KAAK,cAAc,GAAI;AAE3B,kBAAM,KAAM,KAAK,UAAW,EAAE,QAAS,CAAE,EAAE,KAAK,MAAO;AACtD,kBACC,SAAS,WACT,CAAE,WAAW,SAAU,IAAK,GAC3B;AACD,qBAAK,gBAAiB,IAAK;AAAA,cAC5B;AAAA,YACD,CAAE;AAKF,gBAAK,KAAK,aAAa,KAAK,UAAU,QAAS;AAC9C,oBAAM,YAAY,QAAQ,IAAK,CAAE,SAAU;AAC1C,oBAAK,SAAS,KAAM;AAEnB,yBAAO,MAAM;AAAA,gBACd,WAAY,OAAO,SAAS,UAAW;AACtC,yBAAO,CACgB,cAClB,cAAc;AAAA,gBACpB,WAAY,gBAAgB,QAAS;AACpC,yBAAO,CACgB,cAClB,KAAK,KAAM,SAAU;AAAA,gBAC3B;AAEA,uBAAO;AAAA,cACR,CAAE;AAEF,oBAAM,KAAM,KAAK,SAAU,EAAE,QAAS,CAAE,SAAU;AACjD,oBACC,CAAE,UAAU;AAAA,kBAAM,CAAE,YACnB,QAAS,IAAK;AAAA,gBACf,GACC;AACD,uBAAK,UAAU,OAAQ,IAAK;AAAA,gBAC7B;AAAA,cACD,CAAE;AAEF,kBAAK,CAAE,KAAK,UAAU,QAAS;AAC9B,qBAAK,gBAAiB,OAAQ;AAAA,cAC/B;AAAA,YACD;AAAA,UACD;AAEA,cAAK,KAAK,cAAc,GAAI;AAE3B,gBAAK,aAAa,KAAM;AACvB;AAAA,YACD;AAGA,gBAAK,UAAW;AAGf,kBACCA,SAAQ,UACR,CAAE,KAAK,cAAeA,SAAQ,KAAM,GAAI,CAAE,GACzC;AACD;AAAA,kBACC,KAAK;AAAA,kBACL;AAAA,kBACA;AAAA,kBACA;AAAA,gBACD;AACA,uBAAQ,IAAK;AAAA,cAId,WACC,KAAK,cACL,KAAK,WAAW,aAAa,UAC7B,kBAAmB,IAAK,GACvB;AACD;AAAA,kBACC,KAAK;AAAA,kBACL;AAAA,kBACA;AAAA,kBACA;AAAA,gBACD;AAEA,oBACC,MAAM,KAAM,KAAK,UAAW,EAAE;AAAA,kBAC7B,CAAE,UACD,CAAE,kBAAmB,KAAM;AAAA,gBAC7B,GACC;AACD,yBAAQ,IAAK;AAAA,gBACd;AAAA,cACD,OAAO;AACN;AAAA,kBACC,KAAK;AAAA,kBACL;AAAA,kBACA;AAAA,kBACA;AAAA,gBACD;AAAA,cACD;AAAA,YAED,OAAO;AACN,qBAAQ,KAAK,YAAa;AACzB,uBAAQ,KAAK,UAAW;AAAA,cACzB;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,MAED,OAAO;AACN,sBAAe,KAAK,YAAY,KAAK,QAAQ,MAAO;AAIpD,YACC,UACA,CAAE,kBAAmB,IAAK,KAC1B,KAAK,oBACJ;AACD,sBAAa,IAAI,cAAe,IAAK,GAAG,IAAK;AAAA,QAC9C;AAEA,eAAQ,IAAK;AAAA,MACd;AAAA,IACD;AAAA,EACD;AACD;",
6
+ "names": ["require"]
7
+ }
@@ -1,23 +1,15 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import getRectangleFromRange from './get-rectangle-from-range';
5
- import { assertIsDefined } from '../utils/assert-is-defined';
6
-
7
- /**
8
- * Get the rectangle for the selection in a container.
9
- *
10
- * @param {Window} win The window of the selection.
11
- *
12
- * @return {DOMRect | null} The rectangle.
13
- */
14
- export default function computeCaretRect(win) {
1
+ import getRectangleFromRange from "./get-rectangle-from-range";
2
+ import { assertIsDefined } from "../utils/assert-is-defined";
3
+ function computeCaretRect(win) {
15
4
  const selection = win.getSelection();
16
- assertIsDefined(selection, 'selection');
5
+ assertIsDefined(selection, "selection");
17
6
  const range = selection.rangeCount ? selection.getRangeAt(0) : null;
18
7
  if (!range) {
19
8
  return null;
20
9
  }
21
10
  return getRectangleFromRange(range);
22
11
  }
23
- //# sourceMappingURL=compute-caret-rect.js.map
12
+ export {
13
+ computeCaretRect as default
14
+ };
15
+ //# sourceMappingURL=compute-caret-rect.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["getRectangleFromRange","assertIsDefined","computeCaretRect","win","selection","getSelection","range","rangeCount","getRangeAt"],"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":"AAAA;AACA;AACA;AACA,OAAOA,qBAAqB,MAAM,4BAA4B;AAC9D,SAASC,eAAe,QAAQ,4BAA4B;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,gBAAgBA,CAAEC,GAAG,EAAG;EAC/C,MAAMC,SAAS,GAAGD,GAAG,CAACE,YAAY,CAAC,CAAC;EACpCJ,eAAe,CAAEG,SAAS,EAAE,WAAY,CAAC;EACzC,MAAME,KAAK,GAAGF,SAAS,CAACG,UAAU,GAAGH,SAAS,CAACI,UAAU,CAAE,CAAE,CAAC,GAAG,IAAI;EAErE,IAAK,CAAEF,KAAK,EAAG;IACd,OAAO,IAAI;EACZ;EAEA,OAAON,qBAAqB,CAAEM,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": "AAGA,OAAO,2BAA2B;AAClC,SAAS,uBAAuB;AASjB,SAAR,iBAAmC,KAAM;AAC/C,QAAM,YAAY,IAAI,aAAa;AACnC,kBAAiB,WAAW,WAAY;AACxC,QAAM,QAAQ,UAAU,aAAa,UAAU,WAAY,CAAE,IAAI;AAEjE,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AAEA,SAAO,sBAAuB,KAAM;AACrC;",
6
+ "names": []
7
+ }
@@ -1,19 +1,10 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import isTextField from './is-text-field';
5
- import isHTMLInputElement from './is-html-input-element';
6
- import documentHasTextSelection from './document-has-text-selection';
7
-
8
- /**
9
- * Check whether the current document has a selection. This includes focus in
10
- * input fields, textareas, and general rich-text selection.
11
- *
12
- * @param {Document} doc The document to check.
13
- *
14
- * @return {boolean} True if there is selection, false if not.
15
- */
16
- export default function documentHasSelection(doc) {
1
+ import isTextField from "./is-text-field";
2
+ import isHTMLInputElement from "./is-html-input-element";
3
+ import documentHasTextSelection from "./document-has-text-selection";
4
+ function documentHasSelection(doc) {
17
5
  return !!doc.activeElement && (isHTMLInputElement(doc.activeElement) || isTextField(doc.activeElement) || documentHasTextSelection(doc));
18
6
  }
19
- //# sourceMappingURL=document-has-selection.js.map
7
+ export {
8
+ documentHasSelection as default
9
+ };
10
+ //# sourceMappingURL=document-has-selection.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["isTextField","isHTMLInputElement","documentHasTextSelection","documentHasSelection","doc","activeElement"],"sources":["@wordpress/dom/src/dom/document-has-selection.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport isTextField from './is-text-field';\nimport isHTMLInputElement from './is-html-input-element';\nimport documentHasTextSelection from './document-has-text-selection';\n\n/**\n * Check whether the current document has a selection. This includes focus in\n * input fields, textareas, and general rich-text selection.\n *\n * @param {Document} doc The document to check.\n *\n * @return {boolean} True if there is selection, false if not.\n */\nexport default function documentHasSelection( doc ) {\n\treturn (\n\t\t!! doc.activeElement &&\n\t\t( isHTMLInputElement( doc.activeElement ) ||\n\t\t\tisTextField( doc.activeElement ) ||\n\t\t\tdocumentHasTextSelection( doc ) )\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,WAAW,MAAM,iBAAiB;AACzC,OAAOC,kBAAkB,MAAM,yBAAyB;AACxD,OAAOC,wBAAwB,MAAM,+BAA+B;;AAEpE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,oBAAoBA,CAAEC,GAAG,EAAG;EACnD,OACC,CAAC,CAAEA,GAAG,CAACC,aAAa,KAClBJ,kBAAkB,CAAEG,GAAG,CAACC,aAAc,CAAC,IACxCL,WAAW,CAAEI,GAAG,CAACC,aAAc,CAAC,IAChCH,wBAAwB,CAAEE,GAAI,CAAC,CAAE;AAEpC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/document-has-selection.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport isTextField from './is-text-field';\nimport isHTMLInputElement from './is-html-input-element';\nimport documentHasTextSelection from './document-has-text-selection';\n\n/**\n * Check whether the current document has a selection. This includes focus in\n * input fields, textareas, and general rich-text selection.\n *\n * @param {Document} doc The document to check.\n *\n * @return {boolean} True if there is selection, false if not.\n */\nexport default function documentHasSelection( doc ) {\n\treturn (\n\t\t!! doc.activeElement &&\n\t\t( isHTMLInputElement( doc.activeElement ) ||\n\t\t\tisTextField( doc.activeElement ) ||\n\t\t\tdocumentHasTextSelection( doc ) )\n\t);\n}\n"],
5
+ "mappings": "AAGA,OAAO,iBAAiB;AACxB,OAAO,wBAAwB;AAC/B,OAAO,8BAA8B;AAUtB,SAAR,qBAAuC,KAAM;AACnD,SACC,CAAC,CAAE,IAAI,kBACL,mBAAoB,IAAI,aAAc,KACvC,YAAa,IAAI,aAAc,KAC/B,yBAA0B,GAAI;AAEjC;",
6
+ "names": []
7
+ }
@@ -1,24 +1,12 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { assertIsDefined } from '../utils/assert-is-defined';
5
-
6
- /**
7
- * Check whether the current document has selected text. This applies to ranges
8
- * of text in the document, and not selection inside `<input>` and `<textarea>`
9
- * elements.
10
- *
11
- * See: https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects.
12
- *
13
- * @param {Document} doc The document to check.
14
- *
15
- * @return {boolean} True if there is selection, false if not.
16
- */
17
- export default function documentHasTextSelection(doc) {
18
- assertIsDefined(doc.defaultView, 'doc.defaultView');
1
+ import { assertIsDefined } from "../utils/assert-is-defined";
2
+ function documentHasTextSelection(doc) {
3
+ assertIsDefined(doc.defaultView, "doc.defaultView");
19
4
  const selection = doc.defaultView.getSelection();
20
- assertIsDefined(selection, 'selection');
5
+ assertIsDefined(selection, "selection");
21
6
  const range = selection.rangeCount ? selection.getRangeAt(0) : null;
22
7
  return !!range && !range.collapsed;
23
8
  }
24
- //# sourceMappingURL=document-has-text-selection.js.map
9
+ export {
10
+ documentHasTextSelection as default
11
+ };
12
+ //# sourceMappingURL=document-has-text-selection.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["assertIsDefined","documentHasTextSelection","doc","defaultView","selection","getSelection","range","rangeCount","getRangeAt","collapsed"],"sources":["@wordpress/dom/src/dom/document-has-text-selection.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Check whether the current document has selected text. This applies to ranges\n * of text in the document, and not selection inside `<input>` and `<textarea>`\n * elements.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects.\n *\n * @param {Document} doc The document to check.\n *\n * @return {boolean} True if there is selection, false if not.\n */\nexport default function documentHasTextSelection( doc ) {\n\tassertIsDefined( doc.defaultView, 'doc.defaultView' );\n\tconst selection = doc.defaultView.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tconst range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;\n\treturn !! range && ! range.collapsed;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,4BAA4B;;AAE5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,wBAAwBA,CAAEC,GAAG,EAAG;EACvDF,eAAe,CAAEE,GAAG,CAACC,WAAW,EAAE,iBAAkB,CAAC;EACrD,MAAMC,SAAS,GAAGF,GAAG,CAACC,WAAW,CAACE,YAAY,CAAC,CAAC;EAChDL,eAAe,CAAEI,SAAS,EAAE,WAAY,CAAC;EACzC,MAAME,KAAK,GAAGF,SAAS,CAACG,UAAU,GAAGH,SAAS,CAACI,UAAU,CAAE,CAAE,CAAC,GAAG,IAAI;EACrE,OAAO,CAAC,CAAEF,KAAK,IAAI,CAAEA,KAAK,CAACG,SAAS;AACrC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/document-has-text-selection.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/**\n * Check whether the current document has selected text. This applies to ranges\n * of text in the document, and not selection inside `<input>` and `<textarea>`\n * elements.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection#Related_objects.\n *\n * @param {Document} doc The document to check.\n *\n * @return {boolean} True if there is selection, false if not.\n */\nexport default function documentHasTextSelection( doc ) {\n\tassertIsDefined( doc.defaultView, 'doc.defaultView' );\n\tconst selection = doc.defaultView.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tconst range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;\n\treturn !! range && ! range.collapsed;\n}\n"],
5
+ "mappings": "AAGA,SAAS,uBAAuB;AAajB,SAAR,yBAA2C,KAAM;AACvD,kBAAiB,IAAI,aAAa,iBAAkB;AACpD,QAAM,YAAY,IAAI,YAAY,aAAa;AAC/C,kBAAiB,WAAW,WAAY;AACxC,QAAM,QAAQ,UAAU,aAAa,UAAU,WAAY,CAAE,IAAI;AACjE,SAAO,CAAC,CAAE,SAAS,CAAE,MAAM;AAC5B;",
6
+ "names": []
7
+ }
@@ -1,19 +1,9 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import documentHasTextSelection from './document-has-text-selection';
5
- import inputFieldHasUncollapsedSelection from './input-field-has-uncollapsed-selection';
6
-
7
- /**
8
- * Check whether the current document has any sort of (uncollapsed) selection.
9
- * This includes ranges of text across elements and any selection inside
10
- * textual `<input>` and `<textarea>` elements.
11
- *
12
- * @param {Document} doc The document to check.
13
- *
14
- * @return {boolean} Whether there is any recognizable text selection in the document.
15
- */
16
- export default function documentHasUncollapsedSelection(doc) {
1
+ import documentHasTextSelection from "./document-has-text-selection";
2
+ import inputFieldHasUncollapsedSelection from "./input-field-has-uncollapsed-selection";
3
+ function documentHasUncollapsedSelection(doc) {
17
4
  return documentHasTextSelection(doc) || !!doc.activeElement && inputFieldHasUncollapsedSelection(doc.activeElement);
18
5
  }
19
- //# sourceMappingURL=document-has-uncollapsed-selection.js.map
6
+ export {
7
+ documentHasUncollapsedSelection as default
8
+ };
9
+ //# sourceMappingURL=document-has-uncollapsed-selection.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["documentHasTextSelection","inputFieldHasUncollapsedSelection","documentHasUncollapsedSelection","doc","activeElement"],"sources":["@wordpress/dom/src/dom/document-has-uncollapsed-selection.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport documentHasTextSelection from './document-has-text-selection';\nimport inputFieldHasUncollapsedSelection from './input-field-has-uncollapsed-selection';\n\n/**\n * Check whether the current document has any sort of (uncollapsed) selection.\n * This includes ranges of text across elements and any selection inside\n * textual `<input>` and `<textarea>` elements.\n *\n * @param {Document} doc The document to check.\n *\n * @return {boolean} Whether there is any recognizable text selection in the document.\n */\nexport default function documentHasUncollapsedSelection( doc ) {\n\treturn (\n\t\tdocumentHasTextSelection( doc ) ||\n\t\t( !! doc.activeElement &&\n\t\t\tinputFieldHasUncollapsedSelection( doc.activeElement ) )\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,wBAAwB,MAAM,+BAA+B;AACpE,OAAOC,iCAAiC,MAAM,yCAAyC;;AAEvF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,+BAA+BA,CAAEC,GAAG,EAAG;EAC9D,OACCH,wBAAwB,CAAEG,GAAI,CAAC,IAC7B,CAAC,CAAEA,GAAG,CAACC,aAAa,IACrBH,iCAAiC,CAAEE,GAAG,CAACC,aAAc,CAAG;AAE3D","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/document-has-uncollapsed-selection.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport documentHasTextSelection from './document-has-text-selection';\nimport inputFieldHasUncollapsedSelection from './input-field-has-uncollapsed-selection';\n\n/**\n * Check whether the current document has any sort of (uncollapsed) selection.\n * This includes ranges of text across elements and any selection inside\n * textual `<input>` and `<textarea>` elements.\n *\n * @param {Document} doc The document to check.\n *\n * @return {boolean} Whether there is any recognizable text selection in the document.\n */\nexport default function documentHasUncollapsedSelection( doc ) {\n\treturn (\n\t\tdocumentHasTextSelection( doc ) ||\n\t\t( !! doc.activeElement &&\n\t\t\tinputFieldHasUncollapsedSelection( doc.activeElement ) )\n\t);\n}\n"],
5
+ "mappings": "AAGA,OAAO,8BAA8B;AACrC,OAAO,uCAAuC;AAW/B,SAAR,gCAAkD,KAAM;AAC9D,SACC,yBAA0B,GAAI,KAC5B,CAAC,CAAE,IAAI,iBACR,kCAAmC,IAAI,aAAc;AAExD;",
6
+ "names": []
7
+ }
@@ -1,16 +1,12 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { assertIsDefined } from '../utils/assert-is-defined';
5
-
6
- /* eslint-disable jsdoc/valid-types */
7
- /**
8
- * @param {Element} element
9
- * @return {ReturnType<Window['getComputedStyle']>} The computed style for the element.
10
- */
11
- export default function getComputedStyle(element) {
12
- /* eslint-enable jsdoc/valid-types */
13
- assertIsDefined(element.ownerDocument.defaultView, 'element.ownerDocument.defaultView');
1
+ import { assertIsDefined } from "../utils/assert-is-defined";
2
+ function getComputedStyle(element) {
3
+ assertIsDefined(
4
+ element.ownerDocument.defaultView,
5
+ "element.ownerDocument.defaultView"
6
+ );
14
7
  return element.ownerDocument.defaultView.getComputedStyle(element);
15
8
  }
16
- //# sourceMappingURL=get-computed-style.js.map
9
+ export {
10
+ getComputedStyle as default
11
+ };
12
+ //# sourceMappingURL=get-computed-style.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["assertIsDefined","getComputedStyle","element","ownerDocument","defaultView"],"sources":["@wordpress/dom/src/dom/get-computed-style.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @param {Element} element\n * @return {ReturnType<Window['getComputedStyle']>} The computed style for the element.\n */\nexport default function getComputedStyle( element ) {\n\t/* eslint-enable jsdoc/valid-types */\n\tassertIsDefined(\n\t\telement.ownerDocument.defaultView,\n\t\t'element.ownerDocument.defaultView'\n\t);\n\treturn element.ownerDocument.defaultView.getComputedStyle( element );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,4BAA4B;;AAE5D;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,gBAAgBA,CAAEC,OAAO,EAAG;EACnD;EACAF,eAAe,CACdE,OAAO,CAACC,aAAa,CAACC,WAAW,EACjC,mCACD,CAAC;EACD,OAAOF,OAAO,CAACC,aAAa,CAACC,WAAW,CAACH,gBAAgB,CAAEC,OAAQ,CAAC;AACrE","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/get-computed-style.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { assertIsDefined } from '../utils/assert-is-defined';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @param {Element} element\n * @return {ReturnType<Window['getComputedStyle']>} The computed style for the element.\n */\nexport default function getComputedStyle( element ) {\n\t/* eslint-enable jsdoc/valid-types */\n\tassertIsDefined(\n\t\telement.ownerDocument.defaultView,\n\t\t'element.ownerDocument.defaultView'\n\t);\n\treturn element.ownerDocument.defaultView.getComputedStyle( element );\n}\n"],
5
+ "mappings": "AAGA,SAAS,uBAAuB;AAOjB,SAAR,iBAAmC,SAAU;AAEnD;AAAA,IACC,QAAQ,cAAc;AAAA,IACtB;AAAA,EACD;AACA,SAAO,QAAQ,cAAc,YAAY,iBAAkB,OAAQ;AACpE;",
6
+ "names": []
7
+ }
@@ -1,24 +1,8 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import getComputedStyle from './get-computed-style';
5
-
6
- /**
7
- * Returns the closest positioned element, or null under any of the conditions
8
- * of the offsetParent specification. Unlike offsetParent, this function is not
9
- * limited to HTMLElement and accepts any Node (e.g. Node.TEXT_NODE).
10
- *
11
- * @see https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetparent
12
- *
13
- * @param {Node} node Node from which to find offset parent.
14
- *
15
- * @return {Node | null} Offset parent.
16
- */
17
- export default function getOffsetParent(node) {
18
- // Cannot retrieve computed style or offset parent only anything other than
19
- // an element node, so find the closest element node.
1
+ import getComputedStyle from "./get-computed-style";
2
+ function getOffsetParent(node) {
20
3
  let closestElement;
21
- while (closestElement = /** @type {Node} */node.parentNode) {
4
+ while (closestElement = /** @type {Node} */
5
+ node.parentNode) {
22
6
  if (closestElement.nodeType === closestElement.ELEMENT_NODE) {
23
7
  break;
24
8
  }
@@ -26,14 +10,18 @@ export default function getOffsetParent(node) {
26
10
  if (!closestElement) {
27
11
  return null;
28
12
  }
29
-
30
- // If the closest element is already positioned, return it, as offsetParent
31
- // does not otherwise consider the node itself.
32
- if (getComputedStyle(/** @type {Element} */closestElement).position !== 'static') {
13
+ if (getComputedStyle(
14
+ /** @type {Element} */
15
+ closestElement
16
+ ).position !== "static") {
33
17
  return closestElement;
34
18
  }
35
-
36
- // offsetParent is undocumented/draft.
37
- return /** @type {Node & { offsetParent: Node }} */closestElement.offsetParent;
19
+ return (
20
+ /** @type {Node & { offsetParent: Node }} */
21
+ closestElement.offsetParent
22
+ );
38
23
  }
39
- //# sourceMappingURL=get-offset-parent.js.map
24
+ export {
25
+ getOffsetParent as default
26
+ };
27
+ //# sourceMappingURL=get-offset-parent.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["getComputedStyle","getOffsetParent","node","closestElement","parentNode","nodeType","ELEMENT_NODE","position","offsetParent"],"sources":["@wordpress/dom/src/dom/get-offset-parent.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Returns the closest positioned element, or null under any of the conditions\n * of the offsetParent specification. Unlike offsetParent, this function is not\n * limited to HTMLElement and accepts any Node (e.g. Node.TEXT_NODE).\n *\n * @see https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetparent\n *\n * @param {Node} node Node from which to find offset parent.\n *\n * @return {Node | null} Offset parent.\n */\nexport default function getOffsetParent( node ) {\n\t// Cannot retrieve computed style or offset parent only anything other than\n\t// an element node, so find the closest element node.\n\tlet closestElement;\n\twhile ( ( closestElement = /** @type {Node} */ ( node.parentNode ) ) ) {\n\t\tif ( closestElement.nodeType === closestElement.ELEMENT_NODE ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( ! closestElement ) {\n\t\treturn null;\n\t}\n\n\t// If the closest element is already positioned, return it, as offsetParent\n\t// does not otherwise consider the node itself.\n\tif (\n\t\tgetComputedStyle( /** @type {Element} */ ( closestElement ) )\n\t\t\t.position !== 'static'\n\t) {\n\t\treturn closestElement;\n\t}\n\n\t// offsetParent is undocumented/draft.\n\treturn /** @type {Node & { offsetParent: Node }} */ ( closestElement )\n\t\t.offsetParent;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,gBAAgB,MAAM,sBAAsB;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,eAAeA,CAAEC,IAAI,EAAG;EAC/C;EACA;EACA,IAAIC,cAAc;EAClB,OAAUA,cAAc,GAAG,mBAAsBD,IAAI,CAACE,UAAY,EAAK;IACtE,IAAKD,cAAc,CAACE,QAAQ,KAAKF,cAAc,CAACG,YAAY,EAAG;MAC9D;IACD;EACD;EAEA,IAAK,CAAEH,cAAc,EAAG;IACvB,OAAO,IAAI;EACZ;;EAEA;EACA;EACA,IACCH,gBAAgB,CAAE,sBAAyBG,cAAiB,CAAC,CAC3DI,QAAQ,KAAK,QAAQ,EACtB;IACD,OAAOJ,cAAc;EACtB;;EAEA;EACA,OAAO,4CAA+CA,cAAc,CAClEK,YAAY;AACf","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/get-offset-parent.js"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport getComputedStyle from './get-computed-style';\n\n/**\n * Returns the closest positioned element, or null under any of the conditions\n * of the offsetParent specification. Unlike offsetParent, this function is not\n * limited to HTMLElement and accepts any Node (e.g. Node.TEXT_NODE).\n *\n * @see https://drafts.csswg.org/cssom-view/#dom-htmlelement-offsetparent\n *\n * @param {Node} node Node from which to find offset parent.\n *\n * @return {Node | null} Offset parent.\n */\nexport default function getOffsetParent( node ) {\n\t// Cannot retrieve computed style or offset parent only anything other than\n\t// an element node, so find the closest element node.\n\tlet closestElement;\n\twhile ( ( closestElement = /** @type {Node} */ ( node.parentNode ) ) ) {\n\t\tif ( closestElement.nodeType === closestElement.ELEMENT_NODE ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif ( ! closestElement ) {\n\t\treturn null;\n\t}\n\n\t// If the closest element is already positioned, return it, as offsetParent\n\t// does not otherwise consider the node itself.\n\tif (\n\t\tgetComputedStyle( /** @type {Element} */ ( closestElement ) )\n\t\t\t.position !== 'static'\n\t) {\n\t\treturn closestElement;\n\t}\n\n\t// offsetParent is undocumented/draft.\n\treturn /** @type {Node & { offsetParent: Node }} */ ( closestElement )\n\t\t.offsetParent;\n}\n"],
5
+ "mappings": "AAGA,OAAO,sBAAsB;AAad,SAAR,gBAAkC,MAAO;AAG/C,MAAI;AACJ,SAAU;AAAA,EAAuC,KAAK,YAAiB;AACtE,QAAK,eAAe,aAAa,eAAe,cAAe;AAC9D;AAAA,IACD;AAAA,EACD;AAEA,MAAK,CAAE,gBAAiB;AACvB,WAAO;AAAA,EACR;AAIA,MACC;AAAA;AAAA,IAA2C;AAAA,EAAiB,EAC1D,aAAa,UACd;AACD,WAAO;AAAA,EACR;AAGA;AAAA;AAAA,IAAsD,eACpD;AAAA;AACH;",
6
+ "names": []
7
+ }
@@ -1,21 +1,13 @@
1
- /**
2
- * Gets the height of the range without ignoring zero width rectangles, which
3
- * some browsers ignore when creating a union.
4
- *
5
- * @param {Range} range The range to check.
6
- * @return {number | undefined} Height of the range or undefined if the range has no client rectangles.
7
- */
8
- export default function getRangeHeight(range) {
1
+ function getRangeHeight(range) {
9
2
  const rects = Array.from(range.getClientRects());
10
3
  if (!rects.length) {
11
4
  return;
12
5
  }
13
- const highestTop = Math.min(...rects.map(({
14
- top
15
- }) => top));
16
- const lowestBottom = Math.max(...rects.map(({
17
- bottom
18
- }) => bottom));
6
+ const highestTop = Math.min(...rects.map(({ top }) => top));
7
+ const lowestBottom = Math.max(...rects.map(({ bottom }) => bottom));
19
8
  return lowestBottom - highestTop;
20
9
  }
21
- //# sourceMappingURL=get-range-height.js.map
10
+ export {
11
+ getRangeHeight as default
12
+ };
13
+ //# sourceMappingURL=get-range-height.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["getRangeHeight","range","rects","Array","from","getClientRects","length","highestTop","Math","min","map","top","lowestBottom","max","bottom"],"sources":["@wordpress/dom/src/dom/get-range-height.js"],"sourcesContent":["/**\n * Gets the height of the range without ignoring zero width rectangles, which\n * some browsers ignore when creating a union.\n *\n * @param {Range} range The range to check.\n * @return {number | undefined} Height of the range or undefined if the range has no client rectangles.\n */\nexport default function getRangeHeight( range ) {\n\tconst rects = Array.from( range.getClientRects() );\n\n\tif ( ! rects.length ) {\n\t\treturn;\n\t}\n\n\tconst highestTop = Math.min( ...rects.map( ( { top } ) => top ) );\n\tconst lowestBottom = Math.max( ...rects.map( ( { bottom } ) => bottom ) );\n\n\treturn lowestBottom - highestTop;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,cAAcA,CAAEC,KAAK,EAAG;EAC/C,MAAMC,KAAK,GAAGC,KAAK,CAACC,IAAI,CAAEH,KAAK,CAACI,cAAc,CAAC,CAAE,CAAC;EAElD,IAAK,CAAEH,KAAK,CAACI,MAAM,EAAG;IACrB;EACD;EAEA,MAAMC,UAAU,GAAGC,IAAI,CAACC,GAAG,CAAE,GAAGP,KAAK,CAACQ,GAAG,CAAE,CAAE;IAAEC;EAAI,CAAC,KAAMA,GAAI,CAAE,CAAC;EACjE,MAAMC,YAAY,GAAGJ,IAAI,CAACK,GAAG,CAAE,GAAGX,KAAK,CAACQ,GAAG,CAAE,CAAE;IAAEI;EAAO,CAAC,KAAMA,MAAO,CAAE,CAAC;EAEzE,OAAOF,YAAY,GAAGL,UAAU;AACjC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dom/get-range-height.js"],
4
+ "sourcesContent": ["/**\n * Gets the height of the range without ignoring zero width rectangles, which\n * some browsers ignore when creating a union.\n *\n * @param {Range} range The range to check.\n * @return {number | undefined} Height of the range or undefined if the range has no client rectangles.\n */\nexport default function getRangeHeight( range ) {\n\tconst rects = Array.from( range.getClientRects() );\n\n\tif ( ! rects.length ) {\n\t\treturn;\n\t}\n\n\tconst highestTop = Math.min( ...rects.map( ( { top } ) => top ) );\n\tconst lowestBottom = Math.max( ...rects.map( ( { bottom } ) => bottom ) );\n\n\treturn lowestBottom - highestTop;\n}\n"],
5
+ "mappings": "AAOe,SAAR,eAAiC,OAAQ;AAC/C,QAAM,QAAQ,MAAM,KAAM,MAAM,eAAe,CAAE;AAEjD,MAAK,CAAE,MAAM,QAAS;AACrB;AAAA,EACD;AAEA,QAAM,aAAa,KAAK,IAAK,GAAG,MAAM,IAAK,CAAE,EAAE,IAAI,MAAO,GAAI,CAAE;AAChE,QAAM,eAAe,KAAK,IAAK,GAAG,MAAM,IAAK,CAAE,EAAE,OAAO,MAAO,MAAO,CAAE;AAExE,SAAO,eAAe;AACvB;",
6
+ "names": []
7
+ }