@testing-library/user-event 14.4.0 → 14.4.3

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 (231) hide show
  1. package/dist/cjs/clipboard/copy.js +6 -15
  2. package/dist/cjs/clipboard/cut.js +6 -15
  3. package/dist/cjs/clipboard/paste.js +6 -14
  4. package/dist/cjs/convenience/click.js +1 -4
  5. package/dist/cjs/convenience/hover.js +2 -12
  6. package/dist/cjs/document/UI.js +94 -0
  7. package/dist/cjs/document/copySelection.js +37 -0
  8. package/dist/cjs/document/getValueOrTextContent.js +27 -0
  9. package/dist/cjs/document/index.js +13 -68
  10. package/dist/cjs/document/interceptor.js +87 -4
  11. package/dist/cjs/document/prepareDocument.js +67 -0
  12. package/dist/cjs/document/trackValue.js +65 -0
  13. package/dist/cjs/event/behavior/click.js +8 -12
  14. package/dist/cjs/event/behavior/cut.js +5 -11
  15. package/dist/cjs/event/behavior/keydown.js +43 -43
  16. package/dist/cjs/event/behavior/keypress.js +9 -10
  17. package/dist/cjs/event/behavior/keyup.js +6 -7
  18. package/dist/cjs/event/behavior/paste.js +7 -12
  19. package/dist/cjs/event/createEvent.js +37 -28
  20. package/dist/cjs/event/dispatchEvent.js +21 -2
  21. package/dist/cjs/event/focus.js +44 -0
  22. package/dist/cjs/event/index.js +24 -17
  23. package/dist/cjs/{utils/edit → event}/input.js +50 -47
  24. package/dist/cjs/{utils/edit/walkRadio.js → event/radio.js} +13 -7
  25. package/dist/cjs/event/selection/getInputRange.js +20 -0
  26. package/dist/cjs/event/selection/getTargetTypeAndSelection.js +40 -0
  27. package/dist/cjs/event/selection/index.js +26 -0
  28. package/dist/cjs/event/selection/modifySelection.js +30 -0
  29. package/dist/cjs/event/selection/modifySelectionPerMouse.js +49 -0
  30. package/dist/cjs/event/selection/moveSelection.js +47 -0
  31. package/dist/cjs/{utils/focus → event/selection}/resolveCaretPosition.js +11 -19
  32. package/dist/cjs/event/selection/selectAll.js +47 -0
  33. package/dist/cjs/event/selection/setSelection.js +30 -0
  34. package/dist/cjs/event/selection/setSelectionPerMouse.js +90 -0
  35. package/dist/cjs/event/selection/setSelectionRange.js +40 -0
  36. package/dist/cjs/event/selection/updateSelectionOnFocus.js +45 -0
  37. package/dist/cjs/keyboard/index.js +13 -23
  38. package/dist/cjs/keyboard/parseKeyDef.js +8 -13
  39. package/dist/cjs/options.js +0 -28
  40. package/dist/cjs/pointer/index.js +28 -34
  41. package/dist/cjs/pointer/parseKeyDef.js +1 -9
  42. package/dist/cjs/setup/directApi.js +6 -6
  43. package/dist/cjs/setup/index.js +0 -2
  44. package/dist/cjs/setup/setup.js +69 -38
  45. package/dist/cjs/system/index.js +4 -2
  46. package/dist/cjs/system/keyboard.js +32 -32
  47. package/dist/cjs/system/pointer/buttons.js +3 -1
  48. package/dist/cjs/system/pointer/device.js +3 -1
  49. package/dist/cjs/system/pointer/index.js +82 -79
  50. package/dist/cjs/system/pointer/mouse.js +97 -81
  51. package/dist/cjs/system/pointer/pointer.js +45 -46
  52. package/dist/cjs/system/pointer/shared.js +10 -0
  53. package/dist/cjs/utility/clear.js +10 -11
  54. package/dist/cjs/utility/selectOptions.js +17 -19
  55. package/dist/cjs/utility/type.js +6 -15
  56. package/dist/cjs/utility/upload.js +9 -15
  57. package/dist/cjs/utils/dataTransfer/Clipboard.js +11 -21
  58. package/dist/cjs/utils/dataTransfer/DataTransfer.js +22 -19
  59. package/dist/cjs/utils/edit/isEditable.js +6 -10
  60. package/dist/cjs/utils/edit/maxLength.js +6 -16
  61. package/dist/cjs/utils/edit/setFiles.js +4 -2
  62. package/dist/cjs/utils/edit/{buildTimeValue.js → timeValue.js} +6 -0
  63. package/dist/cjs/utils/focus/cursor.js +2 -17
  64. package/dist/cjs/utils/focus/getActiveElement.js +3 -2
  65. package/dist/cjs/utils/focus/selection.js +1 -266
  66. package/dist/cjs/utils/index.js +7 -32
  67. package/dist/cjs/utils/keyDef/readNextDescriptor.js +5 -3
  68. package/dist/cjs/utils/misc/isDisabled.js +2 -1
  69. package/dist/cjs/utils/misc/isVisible.js +1 -1
  70. package/dist/cjs/utils/misc/level.js +4 -6
  71. package/dist/cjs/utils/pointer/cssPointerEvents.js +26 -32
  72. package/dist/esm/clipboard/copy.js +6 -15
  73. package/dist/esm/clipboard/cut.js +6 -15
  74. package/dist/esm/clipboard/paste.js +6 -14
  75. package/dist/esm/convenience/click.js +1 -4
  76. package/dist/esm/convenience/hover.js +2 -12
  77. package/dist/esm/document/UI.js +79 -0
  78. package/dist/esm/document/copySelection.js +33 -0
  79. package/dist/esm/document/getValueOrTextContent.js +23 -0
  80. package/dist/esm/document/index.js +4 -66
  81. package/dist/esm/document/interceptor.js +85 -5
  82. package/dist/esm/document/prepareDocument.js +63 -0
  83. package/dist/esm/document/trackValue.js +59 -0
  84. package/dist/esm/event/behavior/click.js +8 -12
  85. package/dist/esm/event/behavior/cut.js +5 -11
  86. package/dist/esm/event/behavior/keydown.js +36 -36
  87. package/dist/esm/event/behavior/keypress.js +9 -10
  88. package/dist/esm/event/behavior/keyup.js +6 -7
  89. package/dist/esm/event/behavior/paste.js +7 -12
  90. package/dist/esm/event/createEvent.js +37 -28
  91. package/dist/esm/event/dispatchEvent.js +20 -3
  92. package/dist/esm/event/focus.js +39 -0
  93. package/dist/esm/event/index.js +14 -19
  94. package/dist/esm/{utils/edit → event}/input.js +37 -34
  95. package/dist/esm/{utils/edit/walkRadio.js → event/radio.js} +13 -7
  96. package/dist/esm/event/selection/getInputRange.js +16 -0
  97. package/dist/esm/event/selection/getTargetTypeAndSelection.js +36 -0
  98. package/dist/esm/event/selection/index.js +9 -0
  99. package/dist/esm/event/selection/modifySelection.js +26 -0
  100. package/dist/esm/event/selection/modifySelectionPerMouse.js +45 -0
  101. package/dist/esm/event/selection/moveSelection.js +43 -0
  102. package/dist/esm/{utils/focus → event/selection}/resolveCaretPosition.js +11 -19
  103. package/dist/esm/event/selection/selectAll.js +42 -0
  104. package/dist/esm/event/selection/setSelection.js +26 -0
  105. package/dist/esm/event/selection/setSelectionPerMouse.js +86 -0
  106. package/dist/esm/event/selection/setSelectionRange.js +36 -0
  107. package/dist/esm/event/selection/updateSelectionOnFocus.js +41 -0
  108. package/dist/esm/keyboard/index.js +13 -23
  109. package/dist/esm/keyboard/parseKeyDef.js +8 -13
  110. package/dist/esm/options.js +1 -26
  111. package/dist/esm/pointer/index.js +28 -34
  112. package/dist/esm/pointer/parseKeyDef.js +1 -9
  113. package/dist/esm/setup/directApi.js +6 -6
  114. package/dist/esm/setup/index.js +0 -1
  115. package/dist/esm/setup/setup.js +63 -33
  116. package/dist/esm/system/index.js +4 -2
  117. package/dist/esm/system/keyboard.js +32 -32
  118. package/dist/esm/system/pointer/buttons.js +3 -1
  119. package/dist/esm/system/pointer/device.js +3 -1
  120. package/dist/esm/system/pointer/index.js +83 -79
  121. package/dist/esm/system/pointer/mouse.js +95 -79
  122. package/dist/esm/system/pointer/pointer.js +44 -45
  123. package/dist/esm/system/pointer/shared.js +6 -0
  124. package/dist/esm/utility/clear.js +10 -11
  125. package/dist/esm/utility/selectOptions.js +17 -19
  126. package/dist/esm/utility/type.js +6 -15
  127. package/dist/esm/utility/upload.js +9 -15
  128. package/dist/esm/utils/dataTransfer/Clipboard.js +11 -21
  129. package/dist/esm/utils/dataTransfer/DataTransfer.js +22 -19
  130. package/dist/esm/utils/edit/isEditable.js +4 -8
  131. package/dist/esm/utils/edit/maxLength.js +5 -16
  132. package/dist/esm/utils/edit/setFiles.js +4 -2
  133. package/dist/esm/utils/edit/{buildTimeValue.js → timeValue.js} +6 -1
  134. package/dist/esm/utils/focus/cursor.js +2 -17
  135. package/dist/esm/utils/focus/getActiveElement.js +3 -2
  136. package/dist/esm/utils/focus/selection.js +3 -260
  137. package/dist/esm/utils/index.js +4 -11
  138. package/dist/esm/utils/keyDef/readNextDescriptor.js +5 -3
  139. package/dist/esm/utils/misc/isDisabled.js +2 -1
  140. package/dist/esm/utils/misc/isVisible.js +1 -1
  141. package/dist/esm/utils/misc/level.js +4 -6
  142. package/dist/esm/utils/pointer/cssPointerEvents.js +26 -32
  143. package/dist/types/clipboard/copy.d.ts +1 -1
  144. package/dist/types/clipboard/cut.d.ts +1 -1
  145. package/dist/types/clipboard/paste.d.ts +1 -1
  146. package/dist/types/convenience/click.d.ts +1 -1
  147. package/dist/types/convenience/hover.d.ts +1 -1
  148. package/dist/types/document/UI.d.ts +42 -0
  149. package/dist/types/{utils/focus → document}/copySelection.d.ts +0 -0
  150. package/dist/types/document/getValueOrTextContent.d.ts +1 -0
  151. package/dist/types/document/index.d.ts +5 -10
  152. package/dist/types/document/interceptor.d.ts +3 -0
  153. package/dist/types/document/prepareDocument.d.ts +8 -0
  154. package/dist/types/document/trackValue.d.ts +17 -0
  155. package/dist/types/event/behavior/registry.d.ts +2 -2
  156. package/dist/types/event/dispatchEvent.d.ts +5 -2
  157. package/dist/types/event/focus.d.ts +5 -0
  158. package/dist/types/event/index.d.ts +6 -4
  159. package/dist/types/event/input.d.ts +2 -0
  160. package/dist/types/event/radio.d.ts +4 -0
  161. package/dist/types/event/selection/getInputRange.d.ts +5 -0
  162. package/dist/types/event/selection/getTargetTypeAndSelection.d.ts +10 -0
  163. package/dist/types/event/selection/index.d.ts +15 -0
  164. package/dist/types/event/selection/modifySelection.d.ts +8 -0
  165. package/dist/types/event/selection/modifySelectionPerMouse.d.ts +7 -0
  166. package/dist/types/event/selection/moveSelection.d.ts +4 -0
  167. package/dist/types/{utils/focus → event/selection}/resolveCaretPosition.d.ts +0 -0
  168. package/dist/types/{utils/focus → event/selection}/selectAll.d.ts +0 -0
  169. package/dist/types/event/selection/setSelection.d.ts +10 -0
  170. package/dist/types/event/selection/setSelectionPerMouse.d.ts +8 -0
  171. package/dist/types/event/selection/setSelectionRange.d.ts +6 -0
  172. package/dist/types/event/selection/updateSelectionOnFocus.d.ts +5 -0
  173. package/dist/types/keyboard/index.d.ts +2 -2
  174. package/dist/types/options.d.ts +0 -8
  175. package/dist/types/pointer/index.d.ts +3 -3
  176. package/dist/types/setup/directApi.d.ts +1 -1
  177. package/dist/types/setup/index.d.ts +2 -15
  178. package/dist/types/setup/setup.d.ts +25 -7
  179. package/dist/types/system/keyboard.d.ts +3 -3
  180. package/dist/types/system/pointer/buttons.d.ts +1 -1
  181. package/dist/types/system/pointer/index.d.ts +7 -25
  182. package/dist/types/system/pointer/mouse.d.ts +5 -5
  183. package/dist/types/system/pointer/pointer.d.ts +7 -7
  184. package/dist/types/system/pointer/shared.d.ts +20 -0
  185. package/dist/types/utility/clear.d.ts +1 -1
  186. package/dist/types/utility/selectOptions.d.ts +1 -1
  187. package/dist/types/utility/type.d.ts +3 -3
  188. package/dist/types/utility/upload.d.ts +1 -1
  189. package/dist/types/utils/click/isClickableInput.d.ts +2 -2
  190. package/dist/types/utils/edit/isEditable.d.ts +5 -6
  191. package/dist/types/utils/edit/maxLength.d.ts +14 -1
  192. package/dist/types/utils/edit/{isValidDateOrTimeValue.d.ts → timeValue.d.ts} +1 -0
  193. package/dist/types/utils/focus/selection.d.ts +4 -69
  194. package/dist/types/utils/index.d.ts +2 -9
  195. package/dist/types/utils/misc/level.d.ts +4 -13
  196. package/dist/types/utils/misc/wait.d.ts +2 -2
  197. package/dist/types/utils/pointer/cssPointerEvents.d.ts +4 -4
  198. package/package.json +29 -4
  199. package/dist/cjs/document/selection.js +0 -107
  200. package/dist/cjs/document/setRangeText.js +0 -21
  201. package/dist/cjs/document/value.js +0 -125
  202. package/dist/cjs/setup/config.js +0 -7
  203. package/dist/cjs/utils/edit/getValue.js +0 -35
  204. package/dist/cjs/utils/edit/isValidDateOrTimeValue.js +0 -11
  205. package/dist/cjs/utils/focus/blur.js +0 -16
  206. package/dist/cjs/utils/focus/copySelection.js +0 -46
  207. package/dist/cjs/utils/focus/focus.js +0 -26
  208. package/dist/cjs/utils/focus/selectAll.js +0 -54
  209. package/dist/cjs/utils/misc/eventWrapper.js +0 -15
  210. package/dist/esm/document/selection.js +0 -99
  211. package/dist/esm/document/setRangeText.js +0 -17
  212. package/dist/esm/document/value.js +0 -115
  213. package/dist/esm/setup/config.js +0 -3
  214. package/dist/esm/utils/edit/getValue.js +0 -31
  215. package/dist/esm/utils/edit/isValidDateOrTimeValue.js +0 -7
  216. package/dist/esm/utils/focus/blur.js +0 -12
  217. package/dist/esm/utils/focus/copySelection.js +0 -42
  218. package/dist/esm/utils/focus/focus.js +0 -22
  219. package/dist/esm/utils/focus/selectAll.js +0 -49
  220. package/dist/esm/utils/misc/eventWrapper.js +0 -11
  221. package/dist/types/document/selection.d.ts +0 -29
  222. package/dist/types/document/setRangeText.d.ts +0 -1
  223. package/dist/types/document/value.d.ts +0 -26
  224. package/dist/types/setup/config.d.ts +0 -6
  225. package/dist/types/utils/edit/buildTimeValue.d.ts +0 -1
  226. package/dist/types/utils/edit/getValue.d.ts +0 -1
  227. package/dist/types/utils/edit/input.d.ts +0 -2
  228. package/dist/types/utils/edit/walkRadio.d.ts +0 -4
  229. package/dist/types/utils/focus/blur.d.ts +0 -2
  230. package/dist/types/utils/focus/focus.d.ts +0 -5
  231. package/dist/types/utils/misc/eventWrapper.d.ts +0 -1
@@ -1,19 +1,12 @@
1
1
  import '../utils/click/isClickableInput.js';
2
2
  import '../utils/dataTransfer/Clipboard.js';
3
- import './behavior/click.js';
4
- import './behavior/cut.js';
5
- import './behavior/keydown.js';
6
- import './behavior/keypress.js';
7
- import './behavior/keyup.js';
8
- import './behavior/paste.js';
9
- import '@testing-library/dom';
10
- import { eventMap, eventMapKeys } from './eventMap.js';
11
- import '../utils/edit/maxLength.js';
12
3
  import '../utils/edit/isEditable.js';
4
+ import '../utils/edit/maxLength.js';
13
5
  import { getWindow } from '../utils/misc/getWindow.js';
14
6
  import '../utils/keyDef/readNextDescriptor.js';
15
7
  import '../utils/misc/level.js';
16
8
  import '../options.js';
9
+ import { eventMap, eventMapKeys } from './eventMap.js';
17
10
 
18
11
  const eventInitializer = {
19
12
  ClipboardEvent: [
@@ -41,42 +34,58 @@ const eventInitializer = {
41
34
  ]
42
35
  };
43
36
  function createEvent(type, target, init) {
37
+ var ref;
44
38
  const window = getWindow(target);
45
39
  const { EventType , defaultInit } = eventMap[eventMapKeys[type]];
46
40
  const event = new (getEventConstructors(window))[EventType](type, defaultInit);
47
- eventInitializer[EventType]?.forEach((f)=>f(event, init ?? {}));
41
+ (ref = eventInitializer[EventType]) === null || ref === void 0 ? void 0 : ref.forEach((f)=>f(event, init !== null && init !== void 0 ? init : {}));
48
42
  return event;
49
43
  }
50
44
  /* istanbul ignore next */ function getEventConstructors(window) {
51
- /* eslint-disable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ const Event = window.Event ?? class Event {
45
+ var _Event;
46
+ /* eslint-disable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ const Event = (_Event = window.Event) !== null && _Event !== void 0 ? _Event : class Event {
52
47
  };
53
- const AnimationEvent = window.AnimationEvent ?? class AnimationEvent extends Event {
48
+ var _AnimationEvent;
49
+ const AnimationEvent = (_AnimationEvent = window.AnimationEvent) !== null && _AnimationEvent !== void 0 ? _AnimationEvent : class AnimationEvent extends Event {
54
50
  };
55
- const ClipboardEvent = window.ClipboardEvent ?? class ClipboardEvent extends Event {
51
+ var _ClipboardEvent;
52
+ const ClipboardEvent = (_ClipboardEvent = window.ClipboardEvent) !== null && _ClipboardEvent !== void 0 ? _ClipboardEvent : class ClipboardEvent extends Event {
56
53
  };
57
- const PopStateEvent = window.PopStateEvent ?? class PopStateEvent extends Event {
54
+ var _PopStateEvent;
55
+ const PopStateEvent = (_PopStateEvent = window.PopStateEvent) !== null && _PopStateEvent !== void 0 ? _PopStateEvent : class PopStateEvent extends Event {
58
56
  };
59
- const ProgressEvent = window.ProgressEvent ?? class ProgressEvent extends Event {
57
+ var _ProgressEvent;
58
+ const ProgressEvent = (_ProgressEvent = window.ProgressEvent) !== null && _ProgressEvent !== void 0 ? _ProgressEvent : class ProgressEvent extends Event {
60
59
  };
61
- const TransitionEvent = window.TransitionEvent ?? class TransitionEvent extends Event {
60
+ var _TransitionEvent;
61
+ const TransitionEvent = (_TransitionEvent = window.TransitionEvent) !== null && _TransitionEvent !== void 0 ? _TransitionEvent : class TransitionEvent extends Event {
62
62
  };
63
- const UIEvent = window.UIEvent ?? class UIEvent extends Event {
63
+ var _UIEvent;
64
+ const UIEvent = (_UIEvent = window.UIEvent) !== null && _UIEvent !== void 0 ? _UIEvent : class UIEvent extends Event {
64
65
  };
65
- const CompositionEvent = window.CompositionEvent ?? class CompositionEvent extends UIEvent {
66
+ var _CompositionEvent;
67
+ const CompositionEvent = (_CompositionEvent = window.CompositionEvent) !== null && _CompositionEvent !== void 0 ? _CompositionEvent : class CompositionEvent extends UIEvent {
66
68
  };
67
- const FocusEvent = window.FocusEvent ?? class FocusEvent extends UIEvent {
69
+ var _FocusEvent;
70
+ const FocusEvent = (_FocusEvent = window.FocusEvent) !== null && _FocusEvent !== void 0 ? _FocusEvent : class FocusEvent extends UIEvent {
68
71
  };
69
- const InputEvent = window.InputEvent ?? class InputEvent extends UIEvent {
72
+ var _InputEvent;
73
+ const InputEvent = (_InputEvent = window.InputEvent) !== null && _InputEvent !== void 0 ? _InputEvent : class InputEvent extends UIEvent {
70
74
  };
71
- const KeyboardEvent = window.KeyboardEvent ?? class KeyboardEvent extends UIEvent {
75
+ var _KeyboardEvent;
76
+ const KeyboardEvent = (_KeyboardEvent = window.KeyboardEvent) !== null && _KeyboardEvent !== void 0 ? _KeyboardEvent : class KeyboardEvent extends UIEvent {
72
77
  };
73
- const MouseEvent = window.MouseEvent ?? class MouseEvent extends UIEvent {
78
+ var _MouseEvent;
79
+ const MouseEvent = (_MouseEvent = window.MouseEvent) !== null && _MouseEvent !== void 0 ? _MouseEvent : class MouseEvent extends UIEvent {
74
80
  };
75
- const DragEvent = window.DragEvent ?? class DragEvent extends MouseEvent {
81
+ var _DragEvent;
82
+ const DragEvent = (_DragEvent = window.DragEvent) !== null && _DragEvent !== void 0 ? _DragEvent : class DragEvent extends MouseEvent {
76
83
  };
77
- const PointerEvent = window.PointerEvent ?? class PointerEvent extends MouseEvent {
84
+ var _PointerEvent;
85
+ const PointerEvent = (_PointerEvent = window.PointerEvent) !== null && _PointerEvent !== void 0 ? _PointerEvent : class PointerEvent extends MouseEvent {
78
86
  };
79
- const TouchEvent = window.TouchEvent ?? class TouchEvent extends UIEvent {
87
+ var _TouchEvent;
88
+ const TouchEvent = (_TouchEvent = window.TouchEvent) !== null && _TouchEvent !== void 0 ? _TouchEvent : class TouchEvent extends UIEvent {
80
89
  };
81
90
  /* eslint-enable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ return {
82
91
  Event,
@@ -99,12 +108,12 @@ function createEvent(type, target, init) {
99
108
  function assignProps(obj, props) {
100
109
  for (const [key, value] of Object.entries(props)){
101
110
  Object.defineProperty(obj, key, {
102
- get: ()=>value ?? null
111
+ get: ()=>value !== null && value !== void 0 ? value : null
103
112
  });
104
113
  }
105
114
  }
106
115
  function sanitizeNumber(n) {
107
- return Number(n ?? 0);
116
+ return Number(n !== null && n !== void 0 ? n : 0);
108
117
  }
109
118
  function initClipboardEvent(event, { clipboardData }) {
110
119
  assignProps(event, {
@@ -121,7 +130,7 @@ function initInputEvent(event, { data , inputType , isComposing }) {
121
130
  function initUIEvent(event, { view , detail }) {
122
131
  assignProps(event, {
123
132
  view,
124
- detail: sanitizeNumber(detail ?? 0)
133
+ detail: sanitizeNumber(detail !== null && detail !== void 0 ? detail : 0)
125
134
  });
126
135
  }
127
136
  function initUIEventModififiers(event, { altKey , ctrlKey , metaKey , shiftKey , modifierAltGraph , modifierCapsLock , modifierFn , modifierFnLock , modifierNumLock , modifierScrollLock , modifierSymbol , modifierSymbolLock }) {
@@ -6,10 +6,23 @@ import './behavior/keyup.js';
6
6
  import './behavior/paste.js';
7
7
  import { behavior } from './behavior/registry.js';
8
8
  import { wrapEvent } from './wrapEvent.js';
9
+ import { isMouseEvent, isKeyboardEvent } from './eventMap.js';
10
+ import { createEvent } from './createEvent.js';
9
11
 
10
- function dispatchEvent(config, target, event, preventDefault = false) {
12
+ function dispatchUIEvent(target, type, init, preventDefault = false) {
13
+ if (isMouseEvent(type) || isKeyboardEvent(type)) {
14
+ init = {
15
+ ...init,
16
+ ...this.system.getUIEventModifiers()
17
+ };
18
+ }
19
+ const event = createEvent(type, target, init);
20
+ return dispatchEvent.call(this, target, event, preventDefault);
21
+ }
22
+ function dispatchEvent(target, event, preventDefault = false) {
23
+ var ref;
11
24
  const type = event.type;
12
- const behaviorImplementation = preventDefault ? ()=>{} : behavior[type]?.(event, target, config);
25
+ const behaviorImplementation = preventDefault ? ()=>{} : (ref = behavior[type]) === null || ref === void 0 ? void 0 : ref(event, target, this);
13
26
  if (behaviorImplementation) {
14
27
  event.preventDefault();
15
28
  let defaultPrevented = false;
@@ -29,5 +42,9 @@ function dispatchEvent(config, target, event, preventDefault = false) {
29
42
  }
30
43
  return wrapEvent(()=>target.dispatchEvent(event));
31
44
  }
45
+ function dispatchDOMEvent(target, type, init) {
46
+ const event = createEvent(type, target, init);
47
+ wrapEvent(()=>target.dispatchEvent(event));
48
+ }
32
49
 
33
- export { dispatchEvent };
50
+ export { dispatchDOMEvent, dispatchEvent, dispatchUIEvent };
@@ -0,0 +1,39 @@
1
+ import '../utils/click/isClickableInput.js';
2
+ import '../utils/dataTransfer/Clipboard.js';
3
+ import '../utils/edit/isEditable.js';
4
+ import '../utils/edit/maxLength.js';
5
+ import { getActiveElement } from '../utils/focus/getActiveElement.js';
6
+ import '@testing-library/dom/dist/helpers.js';
7
+ import { isFocusable } from '../utils/focus/isFocusable.js';
8
+ import '../utils/keyDef/readNextDescriptor.js';
9
+ import { findClosest } from '../utils/misc/findClosest.js';
10
+ import '../utils/misc/level.js';
11
+ import '../options.js';
12
+ import { updateSelectionOnFocus } from './selection/updateSelectionOnFocus.js';
13
+ import { wrapEvent } from './wrapEvent.js';
14
+
15
+ /**
16
+ * Focus closest focusable element.
17
+ */ function focusElement(element) {
18
+ const target = findClosest(element, isFocusable);
19
+ const activeElement = getActiveElement(element.ownerDocument);
20
+ if ((target !== null && target !== void 0 ? target : element.ownerDocument.body) === activeElement) {
21
+ return;
22
+ } else if (target) {
23
+ wrapEvent(()=>target.focus());
24
+ } else {
25
+ wrapEvent(()=>{
26
+ var ref;
27
+ return (ref = activeElement) === null || ref === void 0 ? void 0 : ref.blur();
28
+ });
29
+ }
30
+ updateSelectionOnFocus(target !== null && target !== void 0 ? target : element.ownerDocument.body);
31
+ }
32
+ function blurElement(element) {
33
+ if (!isFocusable(element)) return;
34
+ const wasActive = getActiveElement(element.ownerDocument) === element;
35
+ if (!wasActive) return;
36
+ wrapEvent(()=>element.blur());
37
+ }
38
+
39
+ export { blurElement, focusElement };
@@ -1,19 +1,14 @@
1
- import { createEvent } from './createEvent.js';
2
- import { dispatchEvent } from './dispatchEvent.js';
3
- import { isMouseEvent, isKeyboardEvent } from './eventMap.js';
4
-
5
- function dispatchUIEvent(config, target, type, init, preventDefault = false) {
6
- if (isMouseEvent(type) || isKeyboardEvent(type)) {
7
- init = {
8
- ...init,
9
- ...config.system.getUIEventModifiers()
10
- };
11
- }
12
- const event = createEvent(type, target, init);
13
- return dispatchEvent(config, target, event, preventDefault);
14
- }
15
- function bindDispatchUIEvent(config) {
16
- return dispatchUIEvent.bind(undefined, config);
17
- }
18
-
19
- export { bindDispatchUIEvent, dispatchUIEvent };
1
+ export { dispatchDOMEvent, dispatchEvent, dispatchUIEvent } from './dispatchEvent.js';
2
+ export { blurElement, focusElement } from './focus.js';
3
+ export { input } from './input.js';
4
+ import '../utils/click/isClickableInput.js';
5
+ import '../utils/dataTransfer/Clipboard.js';
6
+ import '../utils/edit/isEditable.js';
7
+ import '../utils/edit/maxLength.js';
8
+ import '@testing-library/dom/dist/helpers.js';
9
+ import '../utils/keyDef/readNextDescriptor.js';
10
+ import '../utils/misc/level.js';
11
+ import '../options.js';
12
+ export { setSelectionPerMouseDown } from './selection/setSelectionPerMouse.js';
13
+ export { modifySelectionPerMouseMove } from './selection/modifySelectionPerMouse.js';
14
+ export { isAllSelected, selectAll } from './selection/selectAll.js';
@@ -1,19 +1,18 @@
1
- import { dispatchUIEvent } from '../../event/index.js';
2
- import '../click/isClickableInput.js';
3
- import '../dataTransfer/Clipboard.js';
4
- import './isEditable.js';
5
- import '@testing-library/dom';
6
- import { isElementType } from '../misc/isElementType.js';
7
- import { getInputRange, setSelection } from '../focus/selection.js';
1
+ import { setUIValue, clearInitialValue, getUIValue } from '../document/UI.js';
2
+ import '../utils/click/isClickableInput.js';
3
+ import '../utils/dataTransfer/Clipboard.js';
4
+ import { isValidDateOrTimeValue, buildTimeValue } from '../utils/edit/timeValue.js';
5
+ import '../utils/edit/isEditable.js';
6
+ import { supportsMaxLength, getMaxLength } from '../utils/edit/maxLength.js';
7
+ import { getNextCursorPosition } from '../utils/focus/cursor.js';
8
+ import { isElementType } from '../utils/misc/isElementType.js';
8
9
  import '@testing-library/dom/dist/helpers.js';
9
- import { getNextCursorPosition } from '../focus/cursor.js';
10
- import '../keyDef/readNextDescriptor.js';
11
- import '../misc/level.js';
12
- import '../../options.js';
13
- import { setUIValue, clearInitialValue, getUIValue, commitValueAfterInput } from '../../document/value.js';
14
- import { buildTimeValue } from './buildTimeValue.js';
15
- import { isValidDateOrTimeValue } from './isValidDateOrTimeValue.js';
16
- import { getSpaceUntilMaxLength } from './maxLength.js';
10
+ import '../utils/keyDef/readNextDescriptor.js';
11
+ import '../utils/misc/level.js';
12
+ import '../options.js';
13
+ import { commitValueAfterInput } from '../document/trackValue.js';
14
+ import { getInputRange } from './selection/getInputRange.js';
15
+ import { setSelection } from './selection/setSelection.js';
17
16
 
18
17
  function isDateOrTime(element) {
19
18
  return isElementType(element, 'input') && [
@@ -21,14 +20,14 @@ function isDateOrTime(element) {
21
20
  'time'
22
21
  ].includes(element.type);
23
22
  }
24
- function input(config, element, data, inputType = 'insertText') {
23
+ function input(instance, element, data, inputType = 'insertText') {
25
24
  const inputRange = getInputRange(element);
26
25
  /* istanbul ignore if */ if (!inputRange) {
27
26
  return;
28
27
  }
29
28
  // There is no `beforeinput` event on `date` and `time` input
30
29
  if (!isDateOrTime(element)) {
31
- const unprevented = dispatchUIEvent(config, element, 'beforeinput', {
30
+ const unprevented = instance.dispatchUIEvent(element, 'beforeinput', {
32
31
  inputType,
33
32
  data
34
33
  });
@@ -37,12 +36,12 @@ function input(config, element, data, inputType = 'insertText') {
37
36
  }
38
37
  }
39
38
  if ('startContainer' in inputRange) {
40
- editContenteditable(config, element, inputRange, data, inputType);
39
+ editContenteditable(instance, element, inputRange, data, inputType);
41
40
  } else {
42
- editInputElement(config, element, inputRange, data, inputType);
41
+ editInputElement(instance, element, inputRange, data, inputType);
43
42
  }
44
43
  }
45
- function editContenteditable(config, element, inputRange, data, inputType) {
44
+ function editContenteditable(instance, element, inputRange, data, inputType) {
46
45
  let del = false;
47
46
  if (!inputRange.collapsed) {
48
47
  del = true;
@@ -77,19 +76,22 @@ function editContenteditable(config, element, inputRange, data, inputType) {
77
76
  }
78
77
  }
79
78
  if (del || data) {
80
- dispatchUIEvent(config, element, 'input', {
79
+ instance.dispatchUIEvent(element, 'input', {
81
80
  inputType
82
81
  });
83
82
  }
84
83
  }
85
- function editInputElement(config, element, inputRange, data, inputType) {
84
+ function editInputElement(instance, element, inputRange, data, inputType) {
86
85
  let dataToInsert = data;
87
- const spaceUntilMaxLength = getSpaceUntilMaxLength(element);
88
- if (spaceUntilMaxLength !== undefined && data.length > 0) {
89
- if (spaceUntilMaxLength > 0) {
90
- dataToInsert = data.substring(0, spaceUntilMaxLength);
91
- } else {
92
- return;
86
+ if (supportsMaxLength(element)) {
87
+ const maxLength = getMaxLength(element);
88
+ if (maxLength !== undefined && data.length > 0) {
89
+ const spaceUntilMaxLength = maxLength - element.value.length;
90
+ if (spaceUntilMaxLength > 0) {
91
+ dataToInsert = data.substring(0, spaceUntilMaxLength);
92
+ } else {
93
+ return;
94
+ }
93
95
  }
94
96
  }
95
97
  const { newValue , newOffset , oldValue } = calculateNewValue(dataToInsert, element, inputRange, inputType);
@@ -109,12 +111,12 @@ function editInputElement(config, element, inputRange, data, inputType) {
109
111
  });
110
112
  if (isDateOrTime(element)) {
111
113
  if (isValidDateOrTimeValue(element, newValue)) {
112
- commitInput(config, element, newOffset, {});
113
- dispatchUIEvent(config, element, 'change');
114
+ commitInput(instance, element, newOffset, {});
115
+ instance.dispatchUIEvent(element, 'change');
114
116
  clearInitialValue(element);
115
117
  }
116
118
  } else {
117
- commitInput(config, element, newOffset, {
119
+ commitInput(instance, element, newOffset, {
118
120
  data,
119
121
  inputType
120
122
  });
@@ -143,16 +145,17 @@ function calculateNewValue(inputData, node, { startOffset , endOffset }, inputT
143
145
  newOffset
144
146
  };
145
147
  }
146
- function commitInput(config, element, newOffset, inputInit) {
147
- dispatchUIEvent(config, element, 'input', inputInit);
148
+ function commitInput(instance, element, newOffset, inputInit) {
149
+ instance.dispatchUIEvent(element, 'input', inputInit);
148
150
  commitValueAfterInput(element, newOffset);
149
151
  }
150
152
  function isValidNumberInput(value) {
153
+ var ref, ref1;
151
154
  // the browser allows some invalid input but not others
152
155
  // it allows up to two '-' at any place before any 'e' or one directly following 'e'
153
156
  // it allows one '.' at any place before e
154
157
  const valueParts = value.split('e', 2);
155
- return !(/[^\d.\-e]/.test(value) || Number(value.match(/-/g)?.length) > 2 || Number(value.match(/\./g)?.length) > 1 || valueParts[1] && !/^-?\d*$/.test(valueParts[1]));
158
+ return !(/[^\d.\-e]/.test(value) || Number((ref = value.match(/-/g)) === null || ref === void 0 ? void 0 : ref.length) > 2 || Number((ref1 = value.match(/\./g)) === null || ref1 === void 0 ? void 0 : ref1.length) > 1 || valueParts[1] && !/^-?\d*$/.test(valueParts[1]));
156
159
  }
157
160
 
158
161
  export { input };
@@ -1,9 +1,15 @@
1
- import { dispatchUIEvent } from '../../event/index.js';
2
- import { focus } from '../focus/focus.js';
3
- import { getWindow } from '../misc/getWindow.js';
4
- import { isDisabled } from '../misc/isDisabled.js';
1
+ import '../utils/click/isClickableInput.js';
2
+ import '../utils/dataTransfer/Clipboard.js';
3
+ import '../utils/edit/isEditable.js';
4
+ import '../utils/edit/maxLength.js';
5
+ import { isDisabled } from '../utils/misc/isDisabled.js';
6
+ import { getWindow } from '../utils/misc/getWindow.js';
7
+ import '../utils/keyDef/readNextDescriptor.js';
8
+ import '../utils/misc/level.js';
9
+ import '../options.js';
10
+ import { focusElement } from './focus.js';
5
11
 
6
- function walkRadio(config, el, direction) {
12
+ function walkRadio(instance, el, direction) {
7
13
  const window = getWindow(el);
8
14
  const group = Array.from(el.ownerDocument.querySelectorAll(el.name ? `input[type="radio"][name="${window.CSS.escape(el.name)}"]` : `input[type="radio"][name=""], input[type="radio"]:not([name])`));
9
15
  for(let i = group.findIndex((e)=>e === el) + direction;; i += direction){
@@ -16,8 +22,8 @@ function walkRadio(config, el, direction) {
16
22
  if (isDisabled(group[i])) {
17
23
  continue;
18
24
  }
19
- focus(group[i]);
20
- dispatchUIEvent(config, group[i], 'click');
25
+ focusElement(group[i]);
26
+ instance.dispatchUIEvent(group[i], 'click');
21
27
  }
22
28
  }
23
29
 
@@ -0,0 +1,16 @@
1
+ import { getTargetTypeAndSelection } from './getTargetTypeAndSelection.js';
2
+
3
+ /**
4
+ * Get the range that would be overwritten by input.
5
+ */ function getInputRange(focusNode) {
6
+ const typeAndSelection = getTargetTypeAndSelection(focusNode);
7
+ if (typeAndSelection.type === 'input') {
8
+ return typeAndSelection.selection;
9
+ } else if (typeAndSelection.type === 'contenteditable') {
10
+ var ref;
11
+ // Multi-range on contenteditable edits the first selection instead of the last
12
+ return (ref = typeAndSelection.selection) === null || ref === void 0 ? void 0 : ref.getRangeAt(0);
13
+ }
14
+ }
15
+
16
+ export { getInputRange };
@@ -0,0 +1,36 @@
1
+ import { getUISelection } from '../../document/UI.js';
2
+ import '../../utils/click/isClickableInput.js';
3
+ import '../../utils/dataTransfer/Clipboard.js';
4
+ import { getContentEditable } from '../../utils/edit/isContentEditable.js';
5
+ import '../../utils/edit/isEditable.js';
6
+ import '../../utils/edit/maxLength.js';
7
+ import '@testing-library/dom/dist/helpers.js';
8
+ import { hasOwnSelection } from '../../utils/focus/selection.js';
9
+ import '../../utils/keyDef/readNextDescriptor.js';
10
+ import '../../utils/misc/level.js';
11
+ import '../../options.js';
12
+
13
+ /**
14
+ * Determine which selection logic and selection ranges to consider.
15
+ */ function getTargetTypeAndSelection(node) {
16
+ const element = getElement(node);
17
+ if (element && hasOwnSelection(element)) {
18
+ return {
19
+ type: 'input',
20
+ selection: getUISelection(element)
21
+ };
22
+ }
23
+ const selection = element === null || element === void 0 ? void 0 : element.ownerDocument.getSelection();
24
+ // It is possible to extend a single-range selection into a contenteditable.
25
+ // This results in the range acting like a range outside of contenteditable.
26
+ const isCE = getContentEditable(node) && (selection === null || selection === void 0 ? void 0 : selection.anchorNode) && getContentEditable(selection.anchorNode);
27
+ return {
28
+ type: isCE ? 'contenteditable' : 'default',
29
+ selection
30
+ };
31
+ }
32
+ function getElement(node) {
33
+ return node.nodeType === 1 ? node : node.parentElement;
34
+ }
35
+
36
+ export { getTargetTypeAndSelection };
@@ -0,0 +1,9 @@
1
+ export { getInputRange } from './getInputRange.js';
2
+ export { modifySelection } from './modifySelection.js';
3
+ export { moveSelection } from './moveSelection.js';
4
+ export { setSelectionPerMouseDown } from './setSelectionPerMouse.js';
5
+ export { modifySelectionPerMouseMove } from './modifySelectionPerMouse.js';
6
+ export { isAllSelected, selectAll } from './selectAll.js';
7
+ export { setSelectionRange } from './setSelectionRange.js';
8
+ export { setSelection } from './setSelection.js';
9
+ export { updateSelectionOnFocus } from './updateSelectionOnFocus.js';
@@ -0,0 +1,26 @@
1
+ import { setUISelection } from '../../document/UI.js';
2
+ import '../../utils/click/isClickableInput.js';
3
+ import '../../utils/dataTransfer/Clipboard.js';
4
+ import '../../utils/edit/isEditable.js';
5
+ import '../../utils/edit/maxLength.js';
6
+ import '@testing-library/dom/dist/helpers.js';
7
+ import '../../utils/keyDef/readNextDescriptor.js';
8
+ import '../../utils/misc/level.js';
9
+ import '../../options.js';
10
+ import { getTargetTypeAndSelection } from './getTargetTypeAndSelection.js';
11
+
12
+ /**
13
+ * Extend/shrink the selection like with Shift+Arrows or Shift+Mouse
14
+ */ function modifySelection({ focusNode , focusOffset }) {
15
+ var ref, ref1;
16
+ const typeAndSelection = getTargetTypeAndSelection(focusNode);
17
+ if (typeAndSelection.type === 'input') {
18
+ return setUISelection(focusNode, {
19
+ anchorOffset: typeAndSelection.selection.anchorOffset,
20
+ focusOffset
21
+ }, 'modify');
22
+ }
23
+ (ref1 = (ref = focusNode.ownerDocument) === null || ref === void 0 ? void 0 : ref.getSelection()) === null || ref1 === void 0 ? void 0 : ref1.extend(focusNode, focusOffset);
24
+ }
25
+
26
+ export { modifySelection };
@@ -0,0 +1,45 @@
1
+ import { setUISelection } from '../../document/UI.js';
2
+ import '../../utils/click/isClickableInput.js';
3
+ import '../../utils/dataTransfer/Clipboard.js';
4
+ import '../../utils/edit/isEditable.js';
5
+ import '../../utils/edit/maxLength.js';
6
+ import '@testing-library/dom/dist/helpers.js';
7
+ import '../../utils/keyDef/readNextDescriptor.js';
8
+ import '../../utils/misc/level.js';
9
+ import '../../options.js';
10
+ import { resolveCaretPosition } from './resolveCaretPosition.js';
11
+
12
+ function modifySelectionPerMouseMove(selectionRange, { document , target , node , offset }) {
13
+ const selectionFocus = resolveCaretPosition({
14
+ target,
15
+ node,
16
+ offset
17
+ });
18
+ if ('node' in selectionRange) {
19
+ // When the mouse is dragged outside of an input/textarea,
20
+ // the selection is extended to the beginning or end of the input
21
+ // depending on pointer position.
22
+ // TODO: extend selection according to pointer position
23
+ /* istanbul ignore else */ if (selectionFocus.node === selectionRange.node) {
24
+ const anchorOffset = selectionFocus.offset < selectionRange.start ? selectionRange.end : selectionRange.start;
25
+ const focusOffset = selectionFocus.offset > selectionRange.end || selectionFocus.offset < selectionRange.start ? selectionFocus.offset : selectionRange.end;
26
+ setUISelection(selectionRange.node, {
27
+ anchorOffset,
28
+ focusOffset
29
+ });
30
+ }
31
+ } else {
32
+ const range = selectionRange.cloneRange();
33
+ const cmp = range.comparePoint(selectionFocus.node, selectionFocus.offset);
34
+ if (cmp < 0) {
35
+ range.setStart(selectionFocus.node, selectionFocus.offset);
36
+ } else if (cmp > 0) {
37
+ range.setEnd(selectionFocus.node, selectionFocus.offset);
38
+ }
39
+ const selection = document.getSelection();
40
+ selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
41
+ selection === null || selection === void 0 ? void 0 : selection.addRange(range.cloneRange());
42
+ }
43
+ }
44
+
45
+ export { modifySelectionPerMouseMove };
@@ -0,0 +1,43 @@
1
+ import { getUISelection } from '../../document/UI.js';
2
+ import '../../utils/click/isClickableInput.js';
3
+ import '../../utils/dataTransfer/Clipboard.js';
4
+ import '../../utils/edit/isEditable.js';
5
+ import '../../utils/edit/maxLength.js';
6
+ import { getNextCursorPosition } from '../../utils/focus/cursor.js';
7
+ import '@testing-library/dom/dist/helpers.js';
8
+ import { hasOwnSelection } from '../../utils/focus/selection.js';
9
+ import '../../utils/keyDef/readNextDescriptor.js';
10
+ import '../../utils/misc/level.js';
11
+ import '../../options.js';
12
+ import { setSelection } from './setSelection.js';
13
+
14
+ /**
15
+ * Move the selection
16
+ */ function moveSelection(node, direction) {
17
+ // TODO: implement shift
18
+ if (hasOwnSelection(node)) {
19
+ const selection = getUISelection(node);
20
+ setSelection({
21
+ focusNode: node,
22
+ focusOffset: selection.startOffset === selection.endOffset ? selection.focusOffset + direction : direction < 0 ? selection.startOffset : selection.endOffset
23
+ });
24
+ } else {
25
+ const selection1 = node.ownerDocument.getSelection();
26
+ if (!(selection1 === null || selection1 === void 0 ? void 0 : selection1.focusNode)) {
27
+ return;
28
+ }
29
+ if (selection1.isCollapsed) {
30
+ const nextPosition = getNextCursorPosition(selection1.focusNode, selection1.focusOffset, direction);
31
+ if (nextPosition) {
32
+ setSelection({
33
+ focusNode: nextPosition.node,
34
+ focusOffset: nextPosition.offset
35
+ });
36
+ }
37
+ } else {
38
+ selection1[direction < 0 ? 'collapseToStart' : 'collapseToEnd']();
39
+ }
40
+ }
41
+ }
42
+
43
+ export { moveSelection };
@@ -1,32 +1,24 @@
1
- import '../click/isClickableInput.js';
2
- import '../dataTransfer/Clipboard.js';
3
- import '../edit/maxLength.js';
4
- import '../edit/isEditable.js';
5
- import '@testing-library/dom';
6
- import { hasOwnSelection } from './selection.js';
1
+ import { getUIValue } from '../../document/UI.js';
2
+ import '../../utils/click/isClickableInput.js';
3
+ import '../../utils/dataTransfer/Clipboard.js';
4
+ import '../../utils/edit/isEditable.js';
5
+ import '../../utils/edit/maxLength.js';
7
6
  import '@testing-library/dom/dist/helpers.js';
8
- import '../keyDef/readNextDescriptor.js';
9
- import '../misc/level.js';
7
+ import { hasOwnSelection } from '../../utils/focus/selection.js';
8
+ import '../../utils/keyDef/readNextDescriptor.js';
9
+ import '../../utils/misc/level.js';
10
10
  import '../../options.js';
11
- import '../../event/eventMap.js';
12
- import '../../event/behavior/click.js';
13
- import '../../event/behavior/cut.js';
14
- import '../../event/behavior/keydown.js';
15
- import '../../event/behavior/keypress.js';
16
- import '../../event/behavior/keyup.js';
17
- import '../../event/behavior/paste.js';
18
- import { getUIValue } from '../../document/value.js';
19
11
 
20
12
  function resolveCaretPosition({ target , node , offset }) {
21
13
  if (hasOwnSelection(target)) {
22
14
  return {
23
15
  node: target,
24
- offset: offset ?? getUIValue(target).length
16
+ offset: offset !== null && offset !== void 0 ? offset : getUIValue(target).length
25
17
  };
26
18
  } else if (node) {
27
19
  return {
28
20
  node,
29
- offset: offset ?? (node.nodeType === 3 ? node.nodeValue.length : node.childNodes.length)
21
+ offset: offset !== null && offset !== void 0 ? offset : node.nodeType === 3 ? node.nodeValue.length : node.childNodes.length
30
22
  };
31
23
  }
32
24
  return findNodeAtTextOffset(target, offset);
@@ -58,7 +50,7 @@ function findNodeAtTextOffset(node, offset, isRoot = true) {
58
50
  if (c.nodeType === 3) {
59
51
  return {
60
52
  node: c,
61
- offset: offset ?? c.nodeValue.length
53
+ offset: offset !== null && offset !== void 0 ? offset : c.nodeValue.length
62
54
  };
63
55
  }
64
56
  }