@wordpress/dom 5.0.0 → 5.1.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 (210) hide show
  1. package/README.md +1 -1
  2. package/build/data-transfer.cjs +20 -38
  3. package/build/data-transfer.cjs.map +1 -7
  4. package/build/dom/caret-range-from-point.cjs +31 -38
  5. package/build/dom/caret-range-from-point.cjs.map +1 -7
  6. package/build/dom/clean-node-list.cjs +87 -132
  7. package/build/dom/clean-node-list.cjs.map +1 -7
  8. package/build/dom/compute-caret-rect.cjs +35 -35
  9. package/build/dom/compute-caret-rect.cjs.map +1 -7
  10. package/build/dom/document-has-selection.cjs +35 -30
  11. package/build/dom/document-has-selection.cjs.map +1 -7
  12. package/build/dom/document-has-text-selection.cjs +24 -30
  13. package/build/dom/document-has-text-selection.cjs.map +1 -7
  14. package/build/dom/document-has-uncollapsed-selection.cjs +34 -29
  15. package/build/dom/document-has-uncollapsed-selection.cjs.map +1 -7
  16. package/build/dom/get-computed-style.cjs +14 -30
  17. package/build/dom/get-computed-style.cjs.map +1 -7
  18. package/build/dom/get-offset-parent.cjs +40 -39
  19. package/build/dom/get-offset-parent.cjs.map +1 -7
  20. package/build/dom/get-range-height.cjs +18 -31
  21. package/build/dom/get-range-height.cjs.map +1 -7
  22. package/build/dom/get-rectangle-from-range.cjs +82 -128
  23. package/build/dom/get-rectangle-from-range.cjs.map +1 -7
  24. package/build/dom/get-scroll-container.cjs +46 -50
  25. package/build/dom/get-scroll-container.cjs.map +1 -7
  26. package/build/dom/hidden-caret-range-from-point.cjs +48 -42
  27. package/build/dom/hidden-caret-range-from-point.cjs.map +1 -7
  28. package/build/dom/index.cjs +233 -110
  29. package/build/dom/input-field-has-uncollapsed-selection.cjs +48 -43
  30. package/build/dom/input-field-has-uncollapsed-selection.cjs.map +1 -7
  31. package/build/dom/insert-after.cjs +17 -27
  32. package/build/dom/insert-after.cjs.map +1 -7
  33. package/build/dom/is-edge.cjs +82 -97
  34. package/build/dom/is-edge.cjs.map +1 -7
  35. package/build/dom/is-element.cjs +12 -25
  36. package/build/dom/is-element.cjs.map +1 -7
  37. package/build/dom/is-empty.cjs +23 -37
  38. package/build/dom/is-empty.cjs.map +1 -7
  39. package/build/dom/is-entirely-selected.cjs +70 -67
  40. package/build/dom/is-entirely-selected.cjs.map +1 -7
  41. package/build/dom/is-form-element.cjs +33 -33
  42. package/build/dom/is-form-element.cjs.map +1 -7
  43. package/build/dom/is-horizontal-edge.cjs +31 -28
  44. package/build/dom/is-horizontal-edge.cjs.map +1 -7
  45. package/build/dom/is-html-input-element.cjs +12 -25
  46. package/build/dom/is-html-input-element.cjs.map +1 -7
  47. package/build/dom/is-input-or-text-area.cjs +12 -25
  48. package/build/dom/is-input-or-text-area.cjs.map +1 -7
  49. package/build/dom/is-number-input.cjs +36 -33
  50. package/build/dom/is-number-input.cjs.map +1 -7
  51. package/build/dom/is-rtl.cjs +30 -28
  52. package/build/dom/is-rtl.cjs.map +1 -7
  53. package/build/dom/is-selection-forward.cjs +26 -39
  54. package/build/dom/is-selection-forward.cjs.map +1 -7
  55. package/build/dom/is-text-field.cjs +45 -42
  56. package/build/dom/is-text-field.cjs.map +1 -7
  57. package/build/dom/is-vertical-edge.cjs +31 -28
  58. package/build/dom/is-vertical-edge.cjs.map +1 -7
  59. package/build/dom/place-caret-at-edge.cjs +75 -78
  60. package/build/dom/place-caret-at-edge.cjs.map +1 -7
  61. package/build/dom/place-caret-at-horizontal-edge.cjs +29 -28
  62. package/build/dom/place-caret-at-horizontal-edge.cjs.map +1 -7
  63. package/build/dom/place-caret-at-vertical-edge.cjs +30 -28
  64. package/build/dom/place-caret-at-vertical-edge.cjs.map +1 -7
  65. package/build/dom/remove-invalid-html.cjs +35 -31
  66. package/build/dom/remove-invalid-html.cjs.map +1 -7
  67. package/build/dom/remove.cjs +15 -27
  68. package/build/dom/remove.cjs.map +1 -7
  69. package/build/dom/replace-tag.cjs +21 -32
  70. package/build/dom/replace-tag.cjs.map +1 -7
  71. package/build/dom/replace.cjs +34 -32
  72. package/build/dom/replace.cjs.map +1 -7
  73. package/build/dom/safe-html.cjs +45 -46
  74. package/build/dom/safe-html.cjs.map +1 -7
  75. package/build/dom/scroll-if-no-range.cjs +24 -37
  76. package/build/dom/scroll-if-no-range.cjs.map +1 -7
  77. package/build/dom/strip-html.cjs +33 -31
  78. package/build/dom/strip-html.cjs.map +1 -7
  79. package/build/dom/types.cjs +4 -18
  80. package/build/dom/unwrap.cjs +17 -31
  81. package/build/dom/unwrap.cjs.map +1 -7
  82. package/build/dom/wrap.cjs +17 -28
  83. package/build/dom/wrap.cjs.map +1 -7
  84. package/build/focusable.cjs +99 -76
  85. package/build/focusable.cjs.map +1 -7
  86. package/build/index.cjs +57 -38
  87. package/build/index.cjs.map +1 -7
  88. package/build/phrasing-content.cjs +163 -159
  89. package/build/phrasing-content.cjs.map +1 -7
  90. package/build/tabbable.cjs +123 -78
  91. package/build/tabbable.cjs.map +1 -7
  92. package/build/types.cjs +4 -18
  93. package/build/utils/assert-is-defined.cjs +8 -33
  94. package/build/utils/assert-is-defined.cjs.map +1 -7
  95. package/build-module/data-transfer.mjs +16 -14
  96. package/build-module/data-transfer.mjs.map +1 -7
  97. package/build-module/dom/caret-range-from-point.mjs +27 -18
  98. package/build-module/dom/caret-range-from-point.mjs.map +1 -7
  99. package/build-module/dom/clean-node-list.mjs +60 -105
  100. package/build-module/dom/clean-node-list.mjs.map +1 -7
  101. package/build-module/dom/compute-caret-rect.mjs +16 -12
  102. package/build-module/dom/compute-caret-rect.mjs.map +1 -7
  103. package/build-module/dom/document-has-selection.mjs +13 -6
  104. package/build-module/dom/document-has-selection.mjs.map +1 -7
  105. package/build-module/dom/document-has-text-selection.mjs +20 -10
  106. package/build-module/dom/document-has-text-selection.mjs.map +1 -7
  107. package/build-module/dom/document-has-uncollapsed-selection.mjs +14 -6
  108. package/build-module/dom/document-has-uncollapsed-selection.mjs.map +1 -7
  109. package/build-module/dom/get-computed-style.mjs +10 -10
  110. package/build-module/dom/get-computed-style.mjs.map +1 -7
  111. package/build-module/dom/get-offset-parent.mjs +20 -16
  112. package/build-module/dom/get-offset-parent.mjs.map +1 -7
  113. package/build-module/dom/get-range-height.mjs +14 -11
  114. package/build-module/dom/get-range-height.mjs.map +1 -7
  115. package/build-module/dom/get-rectangle-from-range.mjs +78 -108
  116. package/build-module/dom/get-rectangle-from-range.mjs.map +1 -7
  117. package/build-module/dom/get-scroll-container.mjs +28 -28
  118. package/build-module/dom/get-scroll-container.mjs.map +1 -7
  119. package/build-module/dom/hidden-caret-range-from-point.mjs +28 -19
  120. package/build-module/dom/hidden-caret-range-from-point.mjs.map +1 -7
  121. package/build-module/dom/index.mjs +28 -58
  122. package/build-module/dom/input-field-has-uncollapsed-selection.mjs +28 -20
  123. package/build-module/dom/input-field-has-uncollapsed-selection.mjs.map +1 -7
  124. package/build-module/dom/insert-after.mjs +13 -7
  125. package/build-module/dom/insert-after.mjs.map +1 -7
  126. package/build-module/dom/is-edge.mjs +53 -69
  127. package/build-module/dom/is-edge.mjs.map +1 -7
  128. package/build-module/dom/is-element.mjs +8 -5
  129. package/build-module/dom/is-element.mjs.map +1 -7
  130. package/build-module/dom/is-empty.mjs +19 -17
  131. package/build-module/dom/is-empty.mjs.map +1 -7
  132. package/build-module/dom/is-entirely-selected.mjs +51 -44
  133. package/build-module/dom/is-entirely-selected.mjs.map +1 -7
  134. package/build-module/dom/is-form-element.mjs +15 -11
  135. package/build-module/dom/is-form-element.mjs.map +1 -7
  136. package/build-module/dom/is-horizontal-edge.mjs +13 -6
  137. package/build-module/dom/is-horizontal-edge.mjs.map +1 -7
  138. package/build-module/dom/is-html-input-element.mjs +8 -5
  139. package/build-module/dom/is-html-input-element.mjs.map +1 -7
  140. package/build-module/dom/is-input-or-text-area.mjs +8 -5
  141. package/build-module/dom/is-input-or-text-area.mjs.map +1 -7
  142. package/build-module/dom/is-number-input.mjs +16 -10
  143. package/build-module/dom/is-number-input.mjs.map +1 -7
  144. package/build-module/dom/is-rtl.mjs +12 -6
  145. package/build-module/dom/is-rtl.mjs.map +1 -7
  146. package/build-module/dom/is-selection-forward.mjs +22 -19
  147. package/build-module/dom/is-selection-forward.mjs.map +1 -7
  148. package/build-module/dom/is-text-field.mjs +27 -20
  149. package/build-module/dom/is-text-field.mjs.map +1 -7
  150. package/build-module/dom/is-vertical-edge.mjs +13 -6
  151. package/build-module/dom/is-vertical-edge.mjs.map +1 -7
  152. package/build-module/dom/place-caret-at-edge.mjs +51 -52
  153. package/build-module/dom/place-caret-at-edge.mjs.map +1 -7
  154. package/build-module/dom/place-caret-at-horizontal-edge.mjs +11 -6
  155. package/build-module/dom/place-caret-at-horizontal-edge.mjs.map +1 -7
  156. package/build-module/dom/place-caret-at-vertical-edge.mjs +12 -6
  157. package/build-module/dom/place-caret-at-vertical-edge.mjs.map +1 -7
  158. package/build-module/dom/remove-invalid-html.mjs +17 -9
  159. package/build-module/dom/remove-invalid-html.mjs.map +1 -7
  160. package/build-module/dom/remove.mjs +11 -7
  161. package/build-module/dom/remove.mjs.map +1 -7
  162. package/build-module/dom/replace-tag.mjs +17 -12
  163. package/build-module/dom/replace-tag.mjs.map +1 -7
  164. package/build-module/dom/replace.mjs +13 -8
  165. package/build-module/dom/replace.mjs.map +1 -7
  166. package/build-module/dom/safe-html.mjs +27 -24
  167. package/build-module/dom/safe-html.mjs.map +1 -7
  168. package/build-module/dom/scroll-if-no-range.mjs +20 -13
  169. package/build-module/dom/scroll-if-no-range.mjs.map +1 -7
  170. package/build-module/dom/strip-html.mjs +15 -9
  171. package/build-module/dom/strip-html.mjs.map +1 -7
  172. package/build-module/dom/types.mjs +0 -1
  173. package/build-module/dom/unwrap.mjs +13 -11
  174. package/build-module/dom/unwrap.mjs.map +1 -7
  175. package/build-module/dom/wrap.mjs +13 -8
  176. package/build-module/dom/wrap.mjs.map +1 -7
  177. package/build-module/focusable.mjs +95 -52
  178. package/build-module/focusable.mjs.map +1 -7
  179. package/build-module/index.mjs +11 -5
  180. package/build-module/index.mjs.map +1 -7
  181. package/build-module/phrasing-content.mjs +157 -133
  182. package/build-module/phrasing-content.mjs.map +1 -7
  183. package/build-module/tabbable.mjs +116 -51
  184. package/build-module/tabbable.mjs.map +1 -7
  185. package/build-module/types.mjs +0 -1
  186. package/build-module/utils/assert-is-defined.mjs +4 -9
  187. package/build-module/utils/assert-is-defined.mjs.map +1 -7
  188. package/build-types/dom/clean-node-list.d.ts +2 -2
  189. package/build-types/dom/clean-node-list.d.ts.map +1 -1
  190. package/build-types/dom/is-edge.d.ts.map +1 -1
  191. package/build-types/dom/remove-invalid-html.d.ts +4 -4
  192. package/build-types/dom/remove-invalid-html.d.ts.map +1 -1
  193. package/package.json +4 -4
  194. package/src/dom/clean-node-list.ts +2 -2
  195. package/src/dom/is-edge.ts +35 -43
  196. package/src/dom/remove-invalid-html.ts +4 -4
  197. package/src/dom/test/{get-rectangle-from-range.browser.test.js → get-rectangle-from-range.browser.test.ts} +25 -25
  198. package/src/test/{dom.jsdom.test.js → dom.jsdom.test.ts} +9 -6
  199. package/src/test/{focusable.browser.test.js → focusable.browser.test.ts} +14 -13
  200. package/src/test/{tabbable.browser.test.js → tabbable.browser.test.ts} +3 -2
  201. package/build/dom/index.cjs.map +0 -7
  202. package/build/dom/types.cjs.map +0 -7
  203. package/build/types.cjs.map +0 -7
  204. package/build-module/dom/index.mjs.map +0 -7
  205. package/build-module/dom/types.mjs.map +0 -7
  206. package/build-module/types.mjs.map +0 -7
  207. /package/src/dom/test/{safe-html.jsdom.test.js → safe-html.jsdom.test.ts} +0 -0
  208. /package/src/dom/test/{strip-html.jsdom.test.js → strip-html.jsdom.test.ts} +0 -0
  209. /package/src/test/{focusable-area.jsdom.test.js → focusable-area.jsdom.test.ts} +0 -0
  210. /package/src/test/{utils.js → utils.ts} +0 -0
@@ -1,109 +1,94 @@
1
1
  "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ // \0rolldown/runtime.js
2
7
  var __create = Object.create;
3
8
  var __defProp = Object.defineProperty;
4
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
10
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
11
  var __getProtoOf = Object.getPrototypeOf;
7
12
  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
13
  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;
14
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: ((k) => from[k]).bind(null, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
19
22
  };
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
-
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ let __is_rtl_ts = require("./is-rtl.cjs");
28
+ __is_rtl_ts = __toESM(__is_rtl_ts);
29
+ let __get_range_height_ts = require("./get-range-height.cjs");
30
+ __get_range_height_ts = __toESM(__get_range_height_ts);
31
+ let __get_rectangle_from_range_ts = require("./get-rectangle-from-range.cjs");
32
+ __get_rectangle_from_range_ts = __toESM(__get_rectangle_from_range_ts);
33
+ let __is_selection_forward_ts = require("./is-selection-forward.cjs");
34
+ __is_selection_forward_ts = __toESM(__is_selection_forward_ts);
35
+ let __hidden_caret_range_from_point_ts = require("./hidden-caret-range-from-point.cjs");
36
+ __hidden_caret_range_from_point_ts = __toESM(__hidden_caret_range_from_point_ts);
37
+ let ___utils_assert_is_defined_ts = require("../utils/assert-is-defined.cjs");
38
+ let __is_input_or_text_area_ts = require("./is-input-or-text-area.cjs");
39
+ __is_input_or_text_area_ts = __toESM(__is_input_or_text_area_ts);
30
40
  // packages/dom/src/dom/is-edge.ts
31
- var is_edge_exports = {};
32
- __export(is_edge_exports, {
33
- default: () => isEdge
34
- });
35
- module.exports = __toCommonJS(is_edge_exports);
36
- var import_is_rtl = __toESM(require("./is-rtl.cjs"));
37
- var import_get_range_height = __toESM(require("./get-range-height.cjs"));
38
- var import_get_rectangle_from_range = __toESM(require("./get-rectangle-from-range.cjs"));
39
- var import_is_selection_forward = __toESM(require("./is-selection-forward.cjs"));
40
- var import_hidden_caret_range_from_point = __toESM(require("./hidden-caret-range-from-point.cjs"));
41
- var import_assert_is_defined = require("../utils/assert-is-defined.cjs");
42
- var import_is_input_or_text_area = __toESM(require("./is-input-or-text-area.cjs"));
43
- var import_scroll_if_no_range = require("./scroll-if-no-range.cjs");
41
+ /**
42
+ * Check whether the selection is at the edge of the container. Checks for
43
+ * horizontal position by default. Set `onlyVertical` to true to check only
44
+ * vertically.
45
+ *
46
+ * @param container Focusable element.
47
+ * @param isReverse Set to true to check left, false to check right.
48
+ * @param onlyVertical Set to true to check only vertical position.
49
+ *
50
+ * @return True if at the edge, false if not.
51
+ */
44
52
  function isEdge(container, isReverse, onlyVertical = false) {
45
- if ((0, import_is_input_or_text_area.default)(container) && typeof container.selectionStart === "number") {
46
- if (container.selectionStart !== container.selectionEnd) {
47
- return false;
48
- }
49
- if (isReverse) {
50
- return container.selectionStart === 0;
51
- }
52
- return container.value.length === container.selectionStart;
53
- }
54
- if (!container.isContentEditable) {
55
- return true;
56
- }
57
- const { ownerDocument } = container;
58
- const { defaultView } = ownerDocument;
59
- (0, import_assert_is_defined.assertIsDefined)(defaultView, "defaultView");
60
- const selection = defaultView.getSelection();
61
- if (!selection || !selection.rangeCount) {
62
- return false;
63
- }
64
- const range = selection.getRangeAt(0);
65
- const collapsedRange = range.cloneRange();
66
- const isForward = (0, import_is_selection_forward.default)(selection);
67
- const isCollapsed = selection.isCollapsed;
68
- if (!isCollapsed) {
69
- collapsedRange.collapse(!isForward);
70
- }
71
- const collapsedRangeRect = (0, import_get_rectangle_from_range.default)(collapsedRange);
72
- const rangeRect = (0, import_get_rectangle_from_range.default)(range);
73
- if (!collapsedRangeRect || !rangeRect) {
74
- return false;
75
- }
76
- const rangeHeight = (0, import_get_range_height.default)(range);
77
- if (!isCollapsed && rangeHeight && rangeHeight > collapsedRangeRect.height && isForward === isReverse) {
78
- return false;
79
- }
80
- const isReverseDir = (0, import_is_rtl.default)(container) ? !isReverse : isReverse;
81
- const containerRect = container.getBoundingClientRect();
82
- const x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;
83
- const y = isReverse ? containerRect.top + 1 : containerRect.bottom - 1;
84
- const isFarFromVerticalEdge = (y < 0 || y > defaultView.innerHeight) && rangeRect.top >= 0 && rangeRect.bottom <= defaultView.innerHeight;
85
- const isFarFromHorizontalEdge = (x < 0 || x > defaultView.innerWidth) && rangeRect.left >= 0 && rangeRect.right <= defaultView.innerWidth;
86
- if (isFarFromVerticalEdge || !onlyVertical && isFarFromHorizontalEdge) {
87
- return false;
88
- }
89
- const testRange = (0, import_scroll_if_no_range.scrollIfNoRange)(
90
- container,
91
- isReverse,
92
- () => (0, import_hidden_caret_range_from_point.default)(ownerDocument, x, y, container)
93
- );
94
- if (!testRange) {
95
- return false;
96
- }
97
- const testRect = (0, import_get_rectangle_from_range.default)(testRange);
98
- if (!testRect) {
99
- return false;
100
- }
101
- const verticalSide = isReverse ? "top" : "bottom";
102
- const horizontalSide = isReverseDir ? "left" : "right";
103
- const verticalDiff = testRect[verticalSide] - rangeRect[verticalSide];
104
- const horizontalDiff = testRect[horizontalSide] - collapsedRangeRect[horizontalSide];
105
- const hasVerticalDiff = Math.abs(verticalDiff) <= 1;
106
- const hasHorizontalDiff = Math.abs(horizontalDiff) <= 1;
107
- return onlyVertical ? hasVerticalDiff : hasVerticalDiff && hasHorizontalDiff;
53
+ if ((0, __is_input_or_text_area_ts.default)(container) && typeof container.selectionStart === "number") {
54
+ if (container.selectionStart !== container.selectionEnd) return false;
55
+ if (isReverse) return container.selectionStart === 0;
56
+ return container.value.length === container.selectionStart;
57
+ }
58
+ if (!container.isContentEditable) return true;
59
+ const { ownerDocument } = container;
60
+ const { defaultView } = ownerDocument;
61
+ (0, ___utils_assert_is_defined_ts.assertIsDefined)(defaultView, "defaultView");
62
+ const selection = defaultView.getSelection();
63
+ if (!selection || !selection.rangeCount) return false;
64
+ const range = selection.getRangeAt(0);
65
+ const collapsedRange = range.cloneRange();
66
+ const isForward = (0, __is_selection_forward_ts.default)(selection);
67
+ const isCollapsed = selection.isCollapsed;
68
+ if (!isCollapsed) collapsedRange.collapse(!isForward);
69
+ const collapsedRangeRect = (0, __get_rectangle_from_range_ts.default)(collapsedRange);
70
+ const rangeRect = (0, __get_rectangle_from_range_ts.default)(range);
71
+ if (!collapsedRangeRect || !rangeRect) return false;
72
+ const rangeHeight = (0, __get_range_height_ts.default)(range);
73
+ if (!isCollapsed && rangeHeight && rangeHeight > collapsedRangeRect.height && isForward === isReverse) return false;
74
+ const contentRange = ownerDocument.createRange();
75
+ contentRange.selectNodeContents(container);
76
+ if (Array.from(contentRange.getClientRects()).some((rect) => rect.height > 0 && (isReverse ? rect.bottom <= rangeRect.top + 1 : rect.top >= rangeRect.bottom - 1))) return false;
77
+ if (onlyVertical) return true;
78
+ const isReverseDir = (0, __is_rtl_ts.default)(container) ? !isReverse : isReverse;
79
+ const containerRect = container.getBoundingClientRect();
80
+ const x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;
81
+ const y = isReverse ? rangeRect.top + 1 : rangeRect.bottom - 1;
82
+ const testRange = (0, __hidden_caret_range_from_point_ts.default)(ownerDocument, x, y, container);
83
+ if (!testRange || !container.contains(testRange.startContainer)) return false;
84
+ const testRect = (0, __get_rectangle_from_range_ts.default)(testRange);
85
+ if (!testRect) return false;
86
+ const verticalSide = isReverse ? "top" : "bottom";
87
+ const horizontalSide = isReverseDir ? "left" : "right";
88
+ const verticalDiff = testRect[verticalSide] - rangeRect[verticalSide];
89
+ const horizontalDiff = testRect[horizontalSide] - collapsedRangeRect[horizontalSide];
90
+ return Math.abs(verticalDiff) <= 1 && Math.abs(horizontalDiff) <= 1;
108
91
  }
109
- //# sourceMappingURL=is-edge.cjs.map
92
+ exports.default = isEdge;
93
+
94
+ //# sourceMappingURL=is-edge.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/dom/is-edge.ts"],
4
- "sourcesContent": ["import isRTL from './is-rtl';\nimport getRangeHeight from './get-range-height';\nimport getRectangleFromRange from './get-rectangle-from-range';\nimport isSelectionForward from './is-selection-forward';\nimport hiddenCaretRangeFromPoint from './hidden-caret-range-from-point';\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\nimport { scrollIfNoRange } from './scroll-if-no-range';\n\n/**\n * Check whether the selection is at the edge of the container. Checks for\n * horizontal position by default. Set `onlyVertical` to true to check only\n * vertically.\n *\n * @param container Focusable element.\n * @param isReverse Set to true to check left, false to check right.\n * @param onlyVertical Set to true to check only vertical position.\n *\n * @return True if at the edge, false if not.\n */\nexport default function isEdge(\n\tcontainer: HTMLElement,\n\tisReverse: boolean,\n\tonlyVertical: boolean = false\n): boolean {\n\tif (\n\t\tisInputOrTextArea( container ) &&\n\t\ttypeof container.selectionStart === 'number'\n\t) {\n\t\tif ( container.selectionStart !== container.selectionEnd ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( isReverse ) {\n\t\t\treturn container.selectionStart === 0;\n\t\t}\n\n\t\treturn container.value.length === container.selectionStart;\n\t}\n\n\tif ( ! container.isContentEditable ) {\n\t\treturn true;\n\t}\n\n\tconst { ownerDocument } = container;\n\tconst { defaultView } = ownerDocument;\n\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\n\tif ( ! selection || ! selection.rangeCount ) {\n\t\treturn false;\n\t}\n\n\tconst range = selection.getRangeAt( 0 );\n\tconst collapsedRange = range.cloneRange();\n\tconst isForward = isSelectionForward( selection );\n\tconst isCollapsed = selection.isCollapsed;\n\n\t// Collapse in direction of selection.\n\tif ( ! isCollapsed ) {\n\t\tcollapsedRange.collapse( ! isForward );\n\t}\n\n\tconst collapsedRangeRect = getRectangleFromRange( collapsedRange );\n\tconst rangeRect = getRectangleFromRange( range );\n\n\tif ( ! collapsedRangeRect || ! rangeRect ) {\n\t\treturn false;\n\t}\n\n\t// Only consider the multiline selection at the edge if the direction is\n\t// towards the edge. The selection is multiline if it is taller than the\n\t// collapsed selection.\n\tconst rangeHeight = getRangeHeight( range );\n\tif (\n\t\t! isCollapsed &&\n\t\trangeHeight &&\n\t\trangeHeight > collapsedRangeRect.height &&\n\t\tisForward === isReverse\n\t) {\n\t\treturn false;\n\t}\n\n\t// In the case of RTL scripts, the horizontal edge is at the opposite side.\n\tconst isReverseDir = isRTL( container ) ? ! isReverse : isReverse;\n\tconst containerRect = container.getBoundingClientRect();\n\n\t// To check if a selection is at the edge, we insert a test selection at the\n\t// edge of the container and check if the selections have the same vertical\n\t// or horizontal position. If they do, the selection is at the edge.\n\t// This method proves to be better than a DOM-based calculation for the\n\t// horizontal edge, since it ignores empty textnodes and a trailing line\n\t// break element. In other words, we need to check visual positioning, not\n\t// DOM positioning.\n\t// It also proves better than using the computed style for the vertical\n\t// edge, because we cannot know the padding and line height reliably in\n\t// pixels. `getComputedStyle` may return a value with different units.\n\tconst x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;\n\tconst y = isReverse ? containerRect.top + 1 : containerRect.bottom - 1;\n\n\t// The test point can only be hit-tested when it is within the viewport\n\t// (`caretRangeFromPoint` returns nothing for a point outside it, upon\n\t// which `scrollIfNoRange` scrolls the container's edge into view to\n\t// measure, e.g. on every arrow press within a container taller than the\n\t// viewport). When the edge is outside the viewport and the selection is\n\t// within it, they are at least a viewport boundary apart along that\n\t// axis, so the selection cannot be at the edge. Check each axis\n\t// separately: the vertical check must not be short-circuited by a\n\t// horizontally overflowing container, and vice versa.\n\tconst isFarFromVerticalEdge =\n\t\t( y < 0 || y > defaultView.innerHeight ) &&\n\t\trangeRect.top >= 0 &&\n\t\trangeRect.bottom <= defaultView.innerHeight;\n\tconst isFarFromHorizontalEdge =\n\t\t( x < 0 || x > defaultView.innerWidth ) &&\n\t\trangeRect.left >= 0 &&\n\t\trangeRect.right <= defaultView.innerWidth;\n\n\tif (\n\t\tisFarFromVerticalEdge ||\n\t\t( ! onlyVertical && isFarFromHorizontalEdge )\n\t) {\n\t\treturn false;\n\t}\n\n\tconst testRange = scrollIfNoRange( container, isReverse, () =>\n\t\thiddenCaretRangeFromPoint( ownerDocument, x, y, container )\n\t);\n\n\tif ( ! testRange ) {\n\t\treturn false;\n\t}\n\n\tconst testRect = getRectangleFromRange( testRange );\n\n\tif ( ! testRect ) {\n\t\treturn false;\n\t}\n\n\tconst verticalSide = isReverse ? 'top' : 'bottom';\n\tconst horizontalSide = isReverseDir ? 'left' : 'right';\n\tconst verticalDiff = testRect[ verticalSide ] - rangeRect[ verticalSide ];\n\tconst horizontalDiff =\n\t\ttestRect[ horizontalSide ] - collapsedRangeRect[ horizontalSide ];\n\n\t// Allow the position to be 1px off.\n\tconst hasVerticalDiff = Math.abs( verticalDiff ) <= 1;\n\tconst hasHorizontalDiff = Math.abs( horizontalDiff ) <= 1;\n\n\treturn onlyVertical\n\t\t? hasVerticalDiff\n\t\t: hasVerticalDiff && hasHorizontalDiff;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAkB;AAClB,8BAA2B;AAC3B,sCAAkC;AAClC,kCAA+B;AAC/B,2CAAsC;AACtC,+BAAgC;AAChC,mCAA8B;AAC9B,gCAAgC;AAajB,SAAR,OACN,WACA,WACA,eAAwB,OACd;AACV,UACC,6BAAAA,SAAmB,SAAU,KAC7B,OAAO,UAAU,mBAAmB,UACnC;AACD,QAAK,UAAU,mBAAmB,UAAU,cAAe;AAC1D,aAAO;AAAA,IACR;AAEA,QAAK,WAAY;AAChB,aAAO,UAAU,mBAAmB;AAAA,IACrC;AAEA,WAAO,UAAU,MAAM,WAAW,UAAU;AAAA,EAC7C;AAEA,MAAK,CAAE,UAAU,mBAAoB;AACpC,WAAO;AAAA,EACR;AAEA,QAAM,EAAE,cAAc,IAAI;AAC1B,QAAM,EAAE,YAAY,IAAI;AAExB,gDAAiB,aAAa,aAAc;AAC5C,QAAM,YAAY,YAAY,aAAa;AAE3C,MAAK,CAAE,aAAa,CAAE,UAAU,YAAa;AAC5C,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,UAAU,WAAY,CAAE;AACtC,QAAM,iBAAiB,MAAM,WAAW;AACxC,QAAM,gBAAY,4BAAAC,SAAoB,SAAU;AAChD,QAAM,cAAc,UAAU;AAG9B,MAAK,CAAE,aAAc;AACpB,mBAAe,SAAU,CAAE,SAAU;AAAA,EACtC;AAEA,QAAM,yBAAqB,gCAAAC,SAAuB,cAAe;AACjE,QAAM,gBAAY,gCAAAA,SAAuB,KAAM;AAE/C,MAAK,CAAE,sBAAsB,CAAE,WAAY;AAC1C,WAAO;AAAA,EACR;AAKA,QAAM,kBAAc,wBAAAC,SAAgB,KAAM;AAC1C,MACC,CAAE,eACF,eACA,cAAc,mBAAmB,UACjC,cAAc,WACb;AACD,WAAO;AAAA,EACR;AAGA,QAAM,mBAAe,cAAAC,SAAO,SAAU,IAAI,CAAE,YAAY;AACxD,QAAM,gBAAgB,UAAU,sBAAsB;AAYtD,QAAM,IAAI,eAAe,cAAc,OAAO,IAAI,cAAc,QAAQ;AACxE,QAAM,IAAI,YAAY,cAAc,MAAM,IAAI,cAAc,SAAS;AAWrE,QAAM,yBACH,IAAI,KAAK,IAAI,YAAY,gBAC3B,UAAU,OAAO,KACjB,UAAU,UAAU,YAAY;AACjC,QAAM,2BACH,IAAI,KAAK,IAAI,YAAY,eAC3B,UAAU,QAAQ,KAClB,UAAU,SAAS,YAAY;AAEhC,MACC,yBACE,CAAE,gBAAgB,yBACnB;AACD,WAAO;AAAA,EACR;AAEA,QAAM,gBAAY;AAAA,IAAiB;AAAA,IAAW;AAAA,IAAW,UACxD,qCAAAC,SAA2B,eAAe,GAAG,GAAG,SAAU;AAAA,EAC3D;AAEA,MAAK,CAAE,WAAY;AAClB,WAAO;AAAA,EACR;AAEA,QAAM,eAAW,gCAAAH,SAAuB,SAAU;AAElD,MAAK,CAAE,UAAW;AACjB,WAAO;AAAA,EACR;AAEA,QAAM,eAAe,YAAY,QAAQ;AACzC,QAAM,iBAAiB,eAAe,SAAS;AAC/C,QAAM,eAAe,SAAU,YAAa,IAAI,UAAW,YAAa;AACxE,QAAM,iBACL,SAAU,cAAe,IAAI,mBAAoB,cAAe;AAGjE,QAAM,kBAAkB,KAAK,IAAK,YAAa,KAAK;AACpD,QAAM,oBAAoB,KAAK,IAAK,cAAe,KAAK;AAExD,SAAO,eACJ,kBACA,mBAAmB;AACvB;",
6
- "names": ["isInputOrTextArea", "isSelectionForward", "getRectangleFromRange", "getRangeHeight", "isRTL", "hiddenCaretRangeFromPoint"]
7
- }
1
+ {"version":3,"file":"is-edge.cjs","names":["isInputOrTextArea","isSelectionForward","getRectangleFromRange","getRangeHeight","isRTL","hiddenCaretRangeFromPoint"],"sources":["../../src/dom/is-edge.ts"],"sourcesContent":["import isRTL from './is-rtl';\nimport getRangeHeight from './get-range-height';\nimport getRectangleFromRange from './get-rectangle-from-range';\nimport isSelectionForward from './is-selection-forward';\nimport hiddenCaretRangeFromPoint from './hidden-caret-range-from-point';\nimport { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\n\n/**\n * Check whether the selection is at the edge of the container. Checks for\n * horizontal position by default. Set `onlyVertical` to true to check only\n * vertically.\n *\n * @param container Focusable element.\n * @param isReverse Set to true to check left, false to check right.\n * @param onlyVertical Set to true to check only vertical position.\n *\n * @return True if at the edge, false if not.\n */\nexport default function isEdge(\n\tcontainer: HTMLElement,\n\tisReverse: boolean,\n\tonlyVertical: boolean = false\n): boolean {\n\tif (\n\t\tisInputOrTextArea( container ) &&\n\t\ttypeof container.selectionStart === 'number'\n\t) {\n\t\tif ( container.selectionStart !== container.selectionEnd ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( isReverse ) {\n\t\t\treturn container.selectionStart === 0;\n\t\t}\n\n\t\treturn container.value.length === container.selectionStart;\n\t}\n\n\tif ( ! container.isContentEditable ) {\n\t\treturn true;\n\t}\n\n\tconst { ownerDocument } = container;\n\tconst { defaultView } = ownerDocument;\n\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\n\tif ( ! selection || ! selection.rangeCount ) {\n\t\treturn false;\n\t}\n\n\tconst range = selection.getRangeAt( 0 );\n\tconst collapsedRange = range.cloneRange();\n\tconst isForward = isSelectionForward( selection );\n\tconst isCollapsed = selection.isCollapsed;\n\n\t// Collapse in direction of selection.\n\tif ( ! isCollapsed ) {\n\t\tcollapsedRange.collapse( ! isForward );\n\t}\n\n\tconst collapsedRangeRect = getRectangleFromRange( collapsedRange );\n\tconst rangeRect = getRectangleFromRange( range );\n\n\tif ( ! collapsedRangeRect || ! rangeRect ) {\n\t\treturn false;\n\t}\n\n\t// Only consider the multiline selection at the edge if the direction is\n\t// towards the edge. The selection is multiline if it is taller than the\n\t// collapsed selection.\n\tconst rangeHeight = getRangeHeight( range );\n\tif (\n\t\t! isCollapsed &&\n\t\trangeHeight &&\n\t\trangeHeight > collapsedRangeRect.height &&\n\t\tisForward === isReverse\n\t) {\n\t\treturn false;\n\t}\n\n\t// A line above the selection (or below, when going down) means it is not\n\t// at the vertical edge. Unlike hit-testing a point, a range measures\n\t// lines outside the viewport too.\n\tconst contentRange = ownerDocument.createRange();\n\tcontentRange.selectNodeContents( container );\n\tconst hasLineBeyond = Array.from( contentRange.getClientRects() ).some(\n\t\t( rect ) =>\n\t\t\trect.height > 0 &&\n\t\t\t( isReverse\n\t\t\t\t? rect.bottom <= rangeRect.top + 1\n\t\t\t\t: rect.top >= rangeRect.bottom - 1 )\n\t);\n\n\tif ( hasLineBeyond ) {\n\t\treturn false;\n\t}\n\n\tif ( onlyVertical ) {\n\t\treturn true;\n\t}\n\n\t// In the case of RTL scripts, the horizontal edge is at the opposite side.\n\tconst isReverseDir = isRTL( container ) ? ! isReverse : isReverse;\n\tconst containerRect = container.getBoundingClientRect();\n\n\t// The selection is on the edge line. To check if it is at the horizontal\n\t// edge of that line, we hit-test a point at the container's edge on that\n\t// line and check if the caret there has the same position. This proves\n\t// better than a DOM-based calculation, since it ignores empty text nodes\n\t// and a trailing line break element. The line is within the viewport when\n\t// the selection is; otherwise the browser handles the key.\n\tconst x = isReverseDir ? containerRect.left + 1 : containerRect.right - 1;\n\tconst y = isReverse ? rangeRect.top + 1 : rangeRect.bottom - 1;\n\n\tconst testRange = hiddenCaretRangeFromPoint(\n\t\townerDocument,\n\t\tx,\n\t\ty,\n\t\tcontainer\n\t);\n\n\tif ( ! testRange || ! container.contains( testRange.startContainer ) ) {\n\t\treturn false;\n\t}\n\n\tconst testRect = getRectangleFromRange( testRange );\n\n\tif ( ! testRect ) {\n\t\treturn false;\n\t}\n\n\tconst verticalSide = isReverse ? 'top' : 'bottom';\n\tconst horizontalSide = isReverseDir ? 'left' : 'right';\n\tconst verticalDiff = testRect[ verticalSide ] - rangeRect[ verticalSide ];\n\tconst horizontalDiff =\n\t\ttestRect[ horizontalSide ] - collapsedRangeRect[ horizontalSide ];\n\n\t// Allow the position to be 1px off.\n\tconst hasVerticalDiff = Math.abs( verticalDiff ) <= 1;\n\tconst hasHorizontalDiff = Math.abs( horizontalDiff ) <= 1;\n\n\treturn hasVerticalDiff && hasHorizontalDiff;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,SAAwB,OACvB,WACA,WACA,eAAwB,OACd;CACV,KAAA,GACCA,2BAAAA,QAAAA,CAAmB,SAAU,KAC7B,OAAO,UAAU,mBAAmB,UACnC;EACD,IAAK,UAAU,mBAAmB,UAAU,cAC3C,OAAO;EAGR,IAAK,WACJ,OAAO,UAAU,mBAAmB;EAGrC,OAAO,UAAU,MAAM,WAAW,UAAU;CAC7C;CAEA,IAAK,CAAE,UAAU,mBAChB,OAAO;CAGR,MAAM,EAAE,kBAAkB;CAC1B,MAAM,EAAE,gBAAgB;CAExB,CAAA,GAAA,8BAAA,gBAAA,CAAiB,aAAa,aAAc;CAC5C,MAAM,YAAY,YAAY,aAAa;CAE3C,IAAK,CAAE,aAAa,CAAE,UAAU,YAC/B,OAAO;CAGR,MAAM,QAAQ,UAAU,WAAY,CAAE;CACtC,MAAM,iBAAiB,MAAM,WAAW;CACxC,MAAM,aAAA,GAAYC,0BAAAA,QAAAA,CAAoB,SAAU;CAChD,MAAM,cAAc,UAAU;CAG9B,IAAK,CAAE,aACN,eAAe,SAAU,CAAE,SAAU;CAGtC,MAAM,sBAAA,GAAqBC,8BAAAA,QAAAA,CAAuB,cAAe;CACjE,MAAM,aAAA,GAAYA,8BAAAA,QAAAA,CAAuB,KAAM;CAE/C,IAAK,CAAE,sBAAsB,CAAE,WAC9B,OAAO;CAMR,MAAM,eAAA,GAAcC,sBAAAA,QAAAA,CAAgB,KAAM;CAC1C,IACC,CAAE,eACF,eACA,cAAc,mBAAmB,UACjC,cAAc,WAEd,OAAO;CAMR,MAAM,eAAe,cAAc,YAAY;CAC/C,aAAa,mBAAoB,SAAU;CAS3C,IARsB,MAAM,KAAM,aAAa,eAAe,CAAE,CAAC,CAAC,MAC/D,SACD,KAAK,SAAS,MACZ,YACC,KAAK,UAAU,UAAU,MAAM,IAC/B,KAAK,OAAO,UAAU,SAAS,EAGnB,GAChB,OAAO;CAGR,IAAK,cACJ,OAAO;CAIR,MAAM,gBAAA,GAAeC,YAAAA,QAAAA,CAAO,SAAU,IAAI,CAAE,YAAY;CACxD,MAAM,gBAAgB,UAAU,sBAAsB;CAQtD,MAAM,IAAI,eAAe,cAAc,OAAO,IAAI,cAAc,QAAQ;CACxE,MAAM,IAAI,YAAY,UAAU,MAAM,IAAI,UAAU,SAAS;CAE7D,MAAM,aAAA,GAAYC,mCAAAA,QAAAA,CACjB,eACA,GACA,GACA,SACD;CAEA,IAAK,CAAE,aAAa,CAAE,UAAU,SAAU,UAAU,cAAe,GAClE,OAAO;CAGR,MAAM,YAAA,GAAWH,8BAAAA,QAAAA,CAAuB,SAAU;CAElD,IAAK,CAAE,UACN,OAAO;CAGR,MAAM,eAAe,YAAY,QAAQ;CACzC,MAAM,iBAAiB,eAAe,SAAS;CAC/C,MAAM,eAAe,SAAU,gBAAiB,UAAW;CAC3D,MAAM,iBACL,SAAU,kBAAmB,mBAAoB;CAMlD,OAHwB,KAAK,IAAK,YAAa,KAAK,KAC1B,KAAK,IAAK,cAAe,KAAK;AAGzD"}
@@ -1,29 +1,16 @@
1
1
  "use strict";
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
-
20
- // packages/dom/src/dom/is-element.ts
21
- var is_element_exports = {};
22
- __export(is_element_exports, {
23
- default: () => isElement
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
24
5
  });
25
- module.exports = __toCommonJS(is_element_exports);
6
+ // packages/dom/src/dom/is-element.ts
7
+ /**
8
+ * @param {Node | null | undefined} node
9
+ * @return {node is Element} True if node is an Element node
10
+ */
26
11
  function isElement(node) {
27
- return !!node && node.nodeType === node.ELEMENT_NODE;
12
+ return !!node && node.nodeType === node.ELEMENT_NODE;
28
13
  }
29
- //# sourceMappingURL=is-element.cjs.map
14
+ exports.default = isElement;
15
+
16
+ //# sourceMappingURL=is-element.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/dom/is-element.ts"],
4
- "sourcesContent": ["/**\n * @param {Node | null | undefined} node\n * @return {node is Element} True if node is an Element node\n */\nexport default function isElement(\n\tnode: Node | null | undefined\n): node is Element {\n\treturn !! node && node.nodeType === node.ELEMENT_NODE;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIe,SAAR,UACN,MACkB;AAClB,SAAO,CAAC,CAAE,QAAQ,KAAK,aAAa,KAAK;AAC1C;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"is-element.cjs","names":[],"sources":["../../src/dom/is-element.ts"],"sourcesContent":["/**\n * @param {Node | null | undefined} node\n * @return {node is Element} True if node is an Element node\n */\nexport default function isElement(\n\tnode: Node | null | undefined\n): node is Element {\n\treturn !! node && node.nodeType === node.ELEMENT_NODE;\n}\n"],"mappings":";;;;;;;;;;AAIA,SAAwB,UACvB,MACkB;CAClB,OAAO,CAAC,CAAE,QAAQ,KAAK,aAAa,KAAK;AAC1C"}
@@ -1,41 +1,27 @@
1
1
  "use strict";
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
-
20
- // packages/dom/src/dom/is-empty.ts
21
- var is_empty_exports = {};
22
- __export(is_empty_exports, {
23
- default: () => isEmpty
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
24
5
  });
25
- module.exports = __toCommonJS(is_empty_exports);
6
+ // packages/dom/src/dom/is-empty.ts
7
+ /**
8
+ * Recursively checks if an element is empty. An element is not empty if it
9
+ * contains text or contains elements with attributes such as images.
10
+ *
11
+ * @param element The element to check.
12
+ *
13
+ * @return Whether or not the element is empty.
14
+ */
26
15
  function isEmpty(element) {
27
- switch (element.nodeType) {
28
- case element.TEXT_NODE:
29
- return /^[ \f\n\r\t\v\u00a0]*$/.test(element.nodeValue || "");
30
- case element.ELEMENT_NODE:
31
- if (element.hasAttributes()) {
32
- return false;
33
- } else if (!element.hasChildNodes()) {
34
- return true;
35
- }
36
- return Array.from(element.childNodes).every(isEmpty);
37
- default:
38
- return true;
39
- }
16
+ switch (element.nodeType) {
17
+ case element.TEXT_NODE: return /^[ \f\n\r\t\v\u00a0]*$/.test(element.nodeValue || "");
18
+ case element.ELEMENT_NODE:
19
+ if (element.hasAttributes()) return false;
20
+ else if (!element.hasChildNodes()) return true;
21
+ return Array.from(element.childNodes).every(isEmpty);
22
+ default: return true;
23
+ }
40
24
  }
41
- //# sourceMappingURL=is-empty.cjs.map
25
+ exports.default = isEmpty;
26
+
27
+ //# sourceMappingURL=is-empty.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/dom/is-empty.ts"],
4
- "sourcesContent": ["/**\n * Recursively checks if an element is empty. An element is not empty if it\n * contains text or contains elements with attributes such as images.\n *\n * @param element The element to check.\n *\n * @return Whether or not the element is empty.\n */\nexport default function isEmpty( element: Node ): boolean {\n\tswitch ( element.nodeType ) {\n\t\tcase element.TEXT_NODE:\n\t\t\t// We cannot use \\s since it includes special spaces which we want\n\t\t\t// to preserve.\n\t\t\treturn /^[ \\f\\n\\r\\t\\v\\u00a0]*$/.test( element.nodeValue || '' );\n\t\tcase element.ELEMENT_NODE:\n\t\t\tif ( ( element as Element ).hasAttributes() ) {\n\t\t\t\treturn false;\n\t\t\t} else if ( ! element.hasChildNodes() ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn Array.from( element.childNodes ).every( isEmpty );\n\t\tdefault:\n\t\t\treturn true;\n\t}\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQe,SAAR,QAA0B,SAAyB;AACzD,UAAS,QAAQ,UAAW;AAAA,IAC3B,KAAK,QAAQ;AAGZ,aAAO,yBAAyB,KAAM,QAAQ,aAAa,EAAG;AAAA,IAC/D,KAAK,QAAQ;AACZ,UAAO,QAAqB,cAAc,GAAI;AAC7C,eAAO;AAAA,MACR,WAAY,CAAE,QAAQ,cAAc,GAAI;AACvC,eAAO;AAAA,MACR;AAEA,aAAO,MAAM,KAAM,QAAQ,UAAW,EAAE,MAAO,OAAQ;AAAA,IACxD;AACC,aAAO;AAAA,EACT;AACD;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"is-empty.cjs","names":[],"sources":["../../src/dom/is-empty.ts"],"sourcesContent":["/**\n * Recursively checks if an element is empty. An element is not empty if it\n * contains text or contains elements with attributes such as images.\n *\n * @param element The element to check.\n *\n * @return Whether or not the element is empty.\n */\nexport default function isEmpty( element: Node ): boolean {\n\tswitch ( element.nodeType ) {\n\t\tcase element.TEXT_NODE:\n\t\t\t// We cannot use \\s since it includes special spaces which we want\n\t\t\t// to preserve.\n\t\t\treturn /^[ \\f\\n\\r\\t\\v\\u00a0]*$/.test( element.nodeValue || '' );\n\t\tcase element.ELEMENT_NODE:\n\t\t\tif ( ( element as Element ).hasAttributes() ) {\n\t\t\t\treturn false;\n\t\t\t} else if ( ! element.hasChildNodes() ) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn Array.from( element.childNodes ).every( isEmpty );\n\t\tdefault:\n\t\t\treturn true;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AAQA,SAAwB,QAAS,SAAyB;CACzD,QAAS,QAAQ,UAAjB;EACC,KAAK,QAAQ,WAGZ,OAAO,yBAAyB,KAAM,QAAQ,aAAa,EAAG;EAC/D,KAAK,QAAQ;GACZ,IAAO,QAAqB,cAAc,GACzC,OAAO;QACD,IAAK,CAAE,QAAQ,cAAc,GACnC,OAAO;GAGR,OAAO,MAAM,KAAM,QAAQ,UAAW,CAAC,CAAC,MAAO,OAAQ;EACxD,SACC,OAAO;CACT;AACD"}
@@ -1,81 +1,84 @@
1
1
  "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ // \0rolldown/runtime.js
2
7
  var __create = Object.create;
3
8
  var __defProp = Object.defineProperty;
4
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
10
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
11
  var __getProtoOf = Object.getPrototypeOf;
7
12
  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
13
  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;
14
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: ((k) => from[k]).bind(null, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
19
22
  };
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
-
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ let ___utils_assert_is_defined_ts = require("../utils/assert-is-defined.cjs");
28
+ let __is_input_or_text_area_ts = require("./is-input-or-text-area.cjs");
29
+ __is_input_or_text_area_ts = __toESM(__is_input_or_text_area_ts);
30
30
  // packages/dom/src/dom/is-entirely-selected.ts
31
- var is_entirely_selected_exports = {};
32
- __export(is_entirely_selected_exports, {
33
- default: () => isEntirelySelected
34
- });
35
- module.exports = __toCommonJS(is_entirely_selected_exports);
36
- var import_assert_is_defined = require("../utils/assert-is-defined.cjs");
37
- var import_is_input_or_text_area = __toESM(require("./is-input-or-text-area.cjs"));
38
- var ZWNBSP = "\uFEFF";
31
+ /**
32
+ * Zero width non-breaking space, used as padding in the editable DOM tree when
33
+ * it is empty otherwise.
34
+ */
35
+ const ZWNBSP = "";
36
+ /**
37
+ * Check whether the contents of the element have been entirely selected.
38
+ * Returns true if there is no possibility of selection.
39
+ *
40
+ * @param element The element to check.
41
+ *
42
+ * @return True if entirely selected, false if not.
43
+ */
39
44
  function isEntirelySelected(element) {
40
- if ((0, import_is_input_or_text_area.default)(element)) {
41
- return element.selectionStart === 0 && element.value.length === element.selectionEnd;
42
- }
43
- if (!element.isContentEditable) {
44
- return true;
45
- }
46
- const text = element.textContent || "";
47
- if (text === "" || text === ZWNBSP) {
48
- return true;
49
- }
50
- const { ownerDocument } = element;
51
- const { defaultView } = ownerDocument;
52
- (0, import_assert_is_defined.assertIsDefined)(defaultView, "defaultView");
53
- const selection = defaultView.getSelection();
54
- (0, import_assert_is_defined.assertIsDefined)(selection, "selection");
55
- const range = selection.rangeCount ? selection.getRangeAt(0) : null;
56
- if (!range) {
57
- return true;
58
- }
59
- const { startContainer, endContainer, startOffset, endOffset } = range;
60
- if (startContainer === element && endContainer === element && startOffset === 0 && endOffset === element.childNodes.length) {
61
- return true;
62
- }
63
- const lastChild = element.lastChild;
64
- (0, import_assert_is_defined.assertIsDefined)(lastChild, "lastChild");
65
- const endContainerContentLength = endContainer.nodeType === endContainer.TEXT_NODE ? endContainer.data.length : endContainer.childNodes.length;
66
- return isDeepChild(startContainer, element, "firstChild") && isDeepChild(endContainer, element, "lastChild") && startOffset === 0 && endOffset === endContainerContentLength;
45
+ if ((0, __is_input_or_text_area_ts.default)(element)) return element.selectionStart === 0 && element.value.length === element.selectionEnd;
46
+ if (!element.isContentEditable) return true;
47
+ const text = element.textContent || "";
48
+ if (text === "" || text === ZWNBSP) return true;
49
+ const { ownerDocument } = element;
50
+ const { defaultView } = ownerDocument;
51
+ (0, ___utils_assert_is_defined_ts.assertIsDefined)(defaultView, "defaultView");
52
+ const selection = defaultView.getSelection();
53
+ (0, ___utils_assert_is_defined_ts.assertIsDefined)(selection, "selection");
54
+ const range = selection.rangeCount ? selection.getRangeAt(0) : null;
55
+ if (!range) return true;
56
+ const { startContainer, endContainer, startOffset, endOffset } = range;
57
+ if (startContainer === element && endContainer === element && startOffset === 0 && endOffset === element.childNodes.length) return true;
58
+ const lastChild = element.lastChild;
59
+ (0, ___utils_assert_is_defined_ts.assertIsDefined)(lastChild, "lastChild");
60
+ const endContainerContentLength = endContainer.nodeType === endContainer.TEXT_NODE ? endContainer.data.length : endContainer.childNodes.length;
61
+ return isDeepChild(startContainer, element, "firstChild") && isDeepChild(endContainer, element, "lastChild") && startOffset === 0 && endOffset === endContainerContentLength;
67
62
  }
63
+ /**
64
+ * Check whether the contents of the element have been entirely selected.
65
+ * Returns true if there is no possibility of selection.
66
+ *
67
+ * @param query The element to check.
68
+ * @param container The container that we suspect "query" may be a first or last child of.
69
+ * @param propName "firstChild" or "lastChild"
70
+ *
71
+ * @return True if query is a deep first/last child of container, false otherwise.
72
+ */
68
73
  function isDeepChild(query, container, propName) {
69
- let candidate = container;
70
- do {
71
- if (query === candidate) {
72
- return true;
73
- }
74
- candidate = candidate[propName];
75
- while (candidate && candidate.nodeType === candidate.TEXT_NODE && candidate.nodeValue === "") {
76
- candidate = candidate[propName === "lastChild" ? "previousSibling" : "nextSibling"];
77
- }
78
- } while (candidate);
79
- return false;
74
+ let candidate = container;
75
+ do {
76
+ if (query === candidate) return true;
77
+ candidate = candidate[propName];
78
+ while (candidate && candidate.nodeType === candidate.TEXT_NODE && candidate.nodeValue === "") candidate = candidate[propName === "lastChild" ? "previousSibling" : "nextSibling"];
79
+ } while (candidate);
80
+ return false;
80
81
  }
81
- //# sourceMappingURL=is-entirely-selected.cjs.map
82
+ exports.default = isEntirelySelected;
83
+
84
+ //# sourceMappingURL=is-entirely-selected.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/dom/is-entirely-selected.ts"],
4
- "sourcesContent": ["import { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\n\n/**\n * Zero width non-breaking space, used as padding in the editable DOM tree when\n * it is empty otherwise.\n */\nconst ZWNBSP = '\\ufeff';\n\n/**\n * Check whether the contents of the element have been entirely selected.\n * Returns true if there is no possibility of selection.\n *\n * @param element The element to check.\n *\n * @return True if entirely selected, false if not.\n */\nexport default function isEntirelySelected( element: HTMLElement ): boolean {\n\tif ( isInputOrTextArea( element ) ) {\n\t\treturn (\n\t\t\telement.selectionStart === 0 &&\n\t\t\telement.value.length === element.selectionEnd\n\t\t);\n\t}\n\n\tif ( ! element.isContentEditable ) {\n\t\treturn true;\n\t}\n\n\t// If the element is effectively empty (contains only the ZWNBSP\n\t// placeholder or nothing), consider it entirely selected since there's\n\t// nothing meaningful to select.\n\tconst text = element.textContent || '';\n\tif ( text === '' || text === ZWNBSP ) {\n\t\treturn true;\n\t}\n\n\tconst { ownerDocument } = element;\n\tconst { defaultView } = ownerDocument;\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tconst range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;\n\n\tif ( ! range ) {\n\t\treturn true;\n\t}\n\n\tconst { startContainer, endContainer, startOffset, endOffset } = range;\n\n\tif (\n\t\tstartContainer === element &&\n\t\tendContainer === element &&\n\t\tstartOffset === 0 &&\n\t\tendOffset === element.childNodes.length\n\t) {\n\t\treturn true;\n\t}\n\n\tconst lastChild = element.lastChild;\n\tassertIsDefined( lastChild, 'lastChild' );\n\tconst endContainerContentLength =\n\t\tendContainer.nodeType === endContainer.TEXT_NODE\n\t\t\t? ( endContainer as Text ).data.length\n\t\t\t: endContainer.childNodes.length;\n\n\treturn (\n\t\tisDeepChild( startContainer, element, 'firstChild' ) &&\n\t\tisDeepChild( endContainer, element, 'lastChild' ) &&\n\t\tstartOffset === 0 &&\n\t\tendOffset === endContainerContentLength\n\t);\n}\n\n/**\n * Check whether the contents of the element have been entirely selected.\n * Returns true if there is no possibility of selection.\n *\n * @param query The element to check.\n * @param container The container that we suspect \"query\" may be a first or last child of.\n * @param propName \"firstChild\" or \"lastChild\"\n *\n * @return True if query is a deep first/last child of container, false otherwise.\n */\nfunction isDeepChild(\n\tquery: HTMLElement | Node,\n\tcontainer: HTMLElement,\n\tpropName: 'firstChild' | 'lastChild'\n): boolean {\n\tlet candidate: HTMLElement | ChildNode | null = container;\n\tdo {\n\t\tif ( query === candidate ) {\n\t\t\treturn true;\n\t\t}\n\t\tcandidate = candidate[ propName ];\n\t\t// There may be empty text nodes between the first/last child, so ignore\n\t\t// them.\n\t\twhile (\n\t\t\tcandidate &&\n\t\t\tcandidate.nodeType === candidate.TEXT_NODE &&\n\t\t\tcandidate.nodeValue === ''\n\t\t) {\n\t\t\tcandidate =\n\t\t\t\tcandidate[\n\t\t\t\t\tpropName === 'lastChild' ? 'previousSibling' : 'nextSibling'\n\t\t\t\t];\n\t\t}\n\t} while ( candidate );\n\treturn false;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,+BAAgC;AAChC,mCAA8B;AAM9B,IAAM,SAAS;AAUA,SAAR,mBAAqC,SAAgC;AAC3E,UAAK,6BAAAA,SAAmB,OAAQ,GAAI;AACnC,WACC,QAAQ,mBAAmB,KAC3B,QAAQ,MAAM,WAAW,QAAQ;AAAA,EAEnC;AAEA,MAAK,CAAE,QAAQ,mBAAoB;AAClC,WAAO;AAAA,EACR;AAKA,QAAM,OAAO,QAAQ,eAAe;AACpC,MAAK,SAAS,MAAM,SAAS,QAAS;AACrC,WAAO;AAAA,EACR;AAEA,QAAM,EAAE,cAAc,IAAI;AAC1B,QAAM,EAAE,YAAY,IAAI;AACxB,gDAAiB,aAAa,aAAc;AAC5C,QAAM,YAAY,YAAY,aAAa;AAC3C,gDAAiB,WAAW,WAAY;AACxC,QAAM,QAAQ,UAAU,aAAa,UAAU,WAAY,CAAE,IAAI;AAEjE,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AAEA,QAAM,EAAE,gBAAgB,cAAc,aAAa,UAAU,IAAI;AAEjE,MACC,mBAAmB,WACnB,iBAAiB,WACjB,gBAAgB,KAChB,cAAc,QAAQ,WAAW,QAChC;AACD,WAAO;AAAA,EACR;AAEA,QAAM,YAAY,QAAQ;AAC1B,gDAAiB,WAAW,WAAY;AACxC,QAAM,4BACL,aAAa,aAAa,aAAa,YAClC,aAAuB,KAAK,SAC9B,aAAa,WAAW;AAE5B,SACC,YAAa,gBAAgB,SAAS,YAAa,KACnD,YAAa,cAAc,SAAS,WAAY,KAChD,gBAAgB,KAChB,cAAc;AAEhB;AAYA,SAAS,YACR,OACA,WACA,UACU;AACV,MAAI,YAA4C;AAChD,KAAG;AACF,QAAK,UAAU,WAAY;AAC1B,aAAO;AAAA,IACR;AACA,gBAAY,UAAW,QAAS;AAGhC,WACC,aACA,UAAU,aAAa,UAAU,aACjC,UAAU,cAAc,IACvB;AACD,kBACC,UACC,aAAa,cAAc,oBAAoB,aAChD;AAAA,IACF;AAAA,EACD,SAAU;AACV,SAAO;AACR;",
6
- "names": ["isInputOrTextArea"]
7
- }
1
+ {"version":3,"file":"is-entirely-selected.cjs","names":["isInputOrTextArea"],"sources":["../../src/dom/is-entirely-selected.ts"],"sourcesContent":["import { assertIsDefined } from '../utils/assert-is-defined';\nimport isInputOrTextArea from './is-input-or-text-area';\n\n/**\n * Zero width non-breaking space, used as padding in the editable DOM tree when\n * it is empty otherwise.\n */\nconst ZWNBSP = '\\ufeff';\n\n/**\n * Check whether the contents of the element have been entirely selected.\n * Returns true if there is no possibility of selection.\n *\n * @param element The element to check.\n *\n * @return True if entirely selected, false if not.\n */\nexport default function isEntirelySelected( element: HTMLElement ): boolean {\n\tif ( isInputOrTextArea( element ) ) {\n\t\treturn (\n\t\t\telement.selectionStart === 0 &&\n\t\t\telement.value.length === element.selectionEnd\n\t\t);\n\t}\n\n\tif ( ! element.isContentEditable ) {\n\t\treturn true;\n\t}\n\n\t// If the element is effectively empty (contains only the ZWNBSP\n\t// placeholder or nothing), consider it entirely selected since there's\n\t// nothing meaningful to select.\n\tconst text = element.textContent || '';\n\tif ( text === '' || text === ZWNBSP ) {\n\t\treturn true;\n\t}\n\n\tconst { ownerDocument } = element;\n\tconst { defaultView } = ownerDocument;\n\tassertIsDefined( defaultView, 'defaultView' );\n\tconst selection = defaultView.getSelection();\n\tassertIsDefined( selection, 'selection' );\n\tconst range = selection.rangeCount ? selection.getRangeAt( 0 ) : null;\n\n\tif ( ! range ) {\n\t\treturn true;\n\t}\n\n\tconst { startContainer, endContainer, startOffset, endOffset } = range;\n\n\tif (\n\t\tstartContainer === element &&\n\t\tendContainer === element &&\n\t\tstartOffset === 0 &&\n\t\tendOffset === element.childNodes.length\n\t) {\n\t\treturn true;\n\t}\n\n\tconst lastChild = element.lastChild;\n\tassertIsDefined( lastChild, 'lastChild' );\n\tconst endContainerContentLength =\n\t\tendContainer.nodeType === endContainer.TEXT_NODE\n\t\t\t? ( endContainer as Text ).data.length\n\t\t\t: endContainer.childNodes.length;\n\n\treturn (\n\t\tisDeepChild( startContainer, element, 'firstChild' ) &&\n\t\tisDeepChild( endContainer, element, 'lastChild' ) &&\n\t\tstartOffset === 0 &&\n\t\tendOffset === endContainerContentLength\n\t);\n}\n\n/**\n * Check whether the contents of the element have been entirely selected.\n * Returns true if there is no possibility of selection.\n *\n * @param query The element to check.\n * @param container The container that we suspect \"query\" may be a first or last child of.\n * @param propName \"firstChild\" or \"lastChild\"\n *\n * @return True if query is a deep first/last child of container, false otherwise.\n */\nfunction isDeepChild(\n\tquery: HTMLElement | Node,\n\tcontainer: HTMLElement,\n\tpropName: 'firstChild' | 'lastChild'\n): boolean {\n\tlet candidate: HTMLElement | ChildNode | null = container;\n\tdo {\n\t\tif ( query === candidate ) {\n\t\t\treturn true;\n\t\t}\n\t\tcandidate = candidate[ propName ];\n\t\t// There may be empty text nodes between the first/last child, so ignore\n\t\t// them.\n\t\twhile (\n\t\t\tcandidate &&\n\t\t\tcandidate.nodeType === candidate.TEXT_NODE &&\n\t\t\tcandidate.nodeValue === ''\n\t\t) {\n\t\t\tcandidate =\n\t\t\t\tcandidate[\n\t\t\t\t\tpropName === 'lastChild' ? 'previousSibling' : 'nextSibling'\n\t\t\t\t];\n\t\t}\n\t} while ( candidate );\n\treturn false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,MAAM,SAAS;;;;;;;;;AAUf,SAAwB,mBAAoB,SAAgC;CAC3E,KAAA,GAAKA,2BAAAA,QAAAA,CAAmB,OAAQ,GAC/B,OACC,QAAQ,mBAAmB,KAC3B,QAAQ,MAAM,WAAW,QAAQ;CAInC,IAAK,CAAE,QAAQ,mBACd,OAAO;CAMR,MAAM,OAAO,QAAQ,eAAe;CACpC,IAAK,SAAS,MAAM,SAAS,QAC5B,OAAO;CAGR,MAAM,EAAE,kBAAkB;CAC1B,MAAM,EAAE,gBAAgB;CACxB,CAAA,GAAA,8BAAA,gBAAA,CAAiB,aAAa,aAAc;CAC5C,MAAM,YAAY,YAAY,aAAa;CAC3C,CAAA,GAAA,8BAAA,gBAAA,CAAiB,WAAW,WAAY;CACxC,MAAM,QAAQ,UAAU,aAAa,UAAU,WAAY,CAAE,IAAI;CAEjE,IAAK,CAAE,OACN,OAAO;CAGR,MAAM,EAAE,gBAAgB,cAAc,aAAa,cAAc;CAEjE,IACC,mBAAmB,WACnB,iBAAiB,WACjB,gBAAgB,KAChB,cAAc,QAAQ,WAAW,QAEjC,OAAO;CAGR,MAAM,YAAY,QAAQ;CAC1B,CAAA,GAAA,8BAAA,gBAAA,CAAiB,WAAW,WAAY;CACxC,MAAM,4BACL,aAAa,aAAa,aAAa,YAClC,aAAuB,KAAK,SAC9B,aAAa,WAAW;CAE5B,OACC,YAAa,gBAAgB,SAAS,YAAa,KACnD,YAAa,cAAc,SAAS,WAAY,KAChD,gBAAgB,KAChB,cAAc;AAEhB;;;;;;;;;;;AAYA,SAAS,YACR,OACA,WACA,UACU;CACV,IAAI,YAA4C;CAChD,GAAG;EACF,IAAK,UAAU,WACd,OAAO;EAER,YAAY,UAAW;EAGvB,OACC,aACA,UAAU,aAAa,UAAU,aACjC,UAAU,cAAc,IAExB,YACC,UACC,aAAa,cAAc,oBAAoB;CAGnD,SAAU;CACV,OAAO;AACR"}