@testing-library/user-event 14.4.2 → 14.5.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 (276) hide show
  1. package/dist/cjs/_interop/dtl.js +30 -0
  2. package/dist/cjs/_interop/dtlEventMap.js +30 -0
  3. package/dist/cjs/_interop/dtlHelpers.js +30 -0
  4. package/dist/cjs/clipboard/copy.js +6 -16
  5. package/dist/cjs/clipboard/cut.js +6 -16
  6. package/dist/cjs/clipboard/paste.js +6 -16
  7. package/dist/cjs/convenience/click.js +1 -4
  8. package/dist/cjs/convenience/hover.js +2 -12
  9. package/dist/cjs/convenience/tab.js +1 -1
  10. package/dist/cjs/document/UI.js +94 -0
  11. package/dist/cjs/document/copySelection.js +37 -0
  12. package/dist/cjs/document/getValueOrTextContent.js +27 -0
  13. package/dist/cjs/document/index.js +13 -68
  14. package/dist/cjs/document/interceptor.js +89 -4
  15. package/dist/cjs/document/prepareDocument.js +67 -0
  16. package/dist/cjs/document/trackValue.js +65 -0
  17. package/dist/cjs/event/behavior/click.js +8 -12
  18. package/dist/cjs/event/behavior/cut.js +5 -11
  19. package/dist/cjs/event/behavior/keydown.js +43 -47
  20. package/dist/cjs/event/behavior/keypress.js +12 -12
  21. package/dist/cjs/event/behavior/keyup.js +6 -8
  22. package/dist/cjs/event/behavior/paste.js +7 -13
  23. package/dist/cjs/event/createEvent.js +43 -50
  24. package/dist/cjs/event/dispatchEvent.js +21 -3
  25. package/dist/cjs/event/eventMap.js +2 -2
  26. package/dist/cjs/event/focus.js +44 -0
  27. package/dist/cjs/event/index.js +24 -17
  28. package/dist/cjs/{utils/edit → event}/input.js +52 -50
  29. package/dist/cjs/{utils/edit/walkRadio.js → event/radio.js} +13 -7
  30. package/dist/cjs/event/selection/getInputRange.js +20 -0
  31. package/dist/cjs/event/selection/getTargetTypeAndSelection.js +41 -0
  32. package/dist/cjs/event/selection/index.js +26 -0
  33. package/dist/cjs/event/selection/modifySelection.js +30 -0
  34. package/dist/cjs/event/selection/modifySelectionPerMouse.js +50 -0
  35. package/dist/cjs/event/selection/moveSelection.js +48 -0
  36. package/dist/cjs/{utils/focus → event/selection}/resolveCaretPosition.js +10 -18
  37. package/dist/cjs/event/selection/selectAll.js +48 -0
  38. package/dist/cjs/event/selection/setSelection.js +30 -0
  39. package/dist/cjs/event/selection/setSelectionPerMouse.js +91 -0
  40. package/dist/cjs/event/selection/setSelectionRange.js +40 -0
  41. package/dist/cjs/event/selection/updateSelectionOnFocus.js +46 -0
  42. package/dist/cjs/event/wrapEvent.js +3 -2
  43. package/dist/cjs/index.js +1 -0
  44. package/dist/cjs/keyboard/index.js +13 -23
  45. package/dist/cjs/keyboard/parseKeyDef.js +9 -17
  46. package/dist/cjs/options.js +0 -28
  47. package/dist/cjs/pointer/index.js +28 -38
  48. package/dist/cjs/pointer/keyMap.js +1 -1
  49. package/dist/cjs/pointer/parseKeyDef.js +2 -10
  50. package/dist/cjs/setup/api.js +19 -17
  51. package/dist/cjs/setup/directApi.js +6 -6
  52. package/dist/cjs/setup/index.js +0 -2
  53. package/dist/cjs/setup/setup.js +70 -42
  54. package/dist/cjs/setup/wrapAsync.js +3 -2
  55. package/dist/cjs/system/index.js +15 -2
  56. package/dist/cjs/system/keyboard.js +34 -21
  57. package/dist/cjs/system/pointer/buttons.js +14 -1
  58. package/dist/cjs/system/pointer/device.js +14 -1
  59. package/dist/cjs/system/pointer/index.js +60 -45
  60. package/dist/cjs/system/pointer/mouse.js +77 -56
  61. package/dist/cjs/system/pointer/pointer.js +56 -42
  62. package/dist/cjs/system/pointer/shared.js +10 -0
  63. package/dist/cjs/utility/clear.js +10 -11
  64. package/dist/cjs/utility/selectOptions.js +28 -29
  65. package/dist/cjs/utility/type.js +6 -15
  66. package/dist/cjs/utility/upload.js +9 -18
  67. package/dist/cjs/utils/dataTransfer/Clipboard.js +26 -24
  68. package/dist/cjs/utils/dataTransfer/DataTransfer.js +25 -9
  69. package/dist/cjs/utils/edit/isEditable.js +6 -10
  70. package/dist/cjs/utils/edit/maxLength.js +6 -17
  71. package/dist/cjs/utils/edit/setFiles.js +4 -4
  72. package/dist/cjs/utils/edit/{buildTimeValue.js → timeValue.js} +6 -0
  73. package/dist/cjs/utils/focus/cursor.js +2 -18
  74. package/dist/cjs/utils/focus/getActiveElement.js +4 -3
  75. package/dist/cjs/utils/focus/selection.js +1 -271
  76. package/dist/cjs/utils/focus/selector.js +1 -1
  77. package/dist/cjs/utils/index.js +7 -32
  78. package/dist/cjs/utils/keyDef/readNextDescriptor.js +5 -5
  79. package/dist/cjs/utils/misc/getTreeDiff.js +3 -3
  80. package/dist/cjs/utils/misc/getWindow.js +3 -2
  81. package/dist/cjs/utils/misc/isDisabled.js +3 -3
  82. package/dist/cjs/utils/misc/isVisible.js +3 -2
  83. package/dist/cjs/utils/misc/level.js +4 -9
  84. package/dist/cjs/utils/misc/wait.js +1 -1
  85. package/dist/cjs/utils/pointer/cssPointerEvents.js +31 -40
  86. package/dist/esm/_interop/dtl.js +6 -0
  87. package/dist/esm/_interop/dtlEventMap.js +6 -0
  88. package/dist/esm/_interop/dtlHelpers.js +6 -0
  89. package/dist/esm/clipboard/copy.js +6 -16
  90. package/dist/esm/clipboard/cut.js +6 -16
  91. package/dist/esm/clipboard/paste.js +6 -16
  92. package/dist/esm/convenience/click.js +1 -4
  93. package/dist/esm/convenience/hover.js +2 -12
  94. package/dist/esm/convenience/tab.js +1 -1
  95. package/dist/esm/document/UI.js +79 -0
  96. package/dist/esm/document/copySelection.js +33 -0
  97. package/dist/esm/document/getValueOrTextContent.js +23 -0
  98. package/dist/esm/document/index.js +4 -66
  99. package/dist/esm/document/interceptor.js +87 -5
  100. package/dist/esm/document/prepareDocument.js +63 -0
  101. package/dist/esm/document/trackValue.js +59 -0
  102. package/dist/esm/event/behavior/click.js +8 -12
  103. package/dist/esm/event/behavior/cut.js +5 -11
  104. package/dist/esm/event/behavior/keydown.js +36 -40
  105. package/dist/esm/event/behavior/keypress.js +12 -12
  106. package/dist/esm/event/behavior/keyup.js +6 -8
  107. package/dist/esm/event/behavior/paste.js +7 -13
  108. package/dist/esm/event/createEvent.js +43 -50
  109. package/dist/esm/event/dispatchEvent.js +20 -4
  110. package/dist/esm/event/eventMap.js +2 -2
  111. package/dist/esm/event/focus.js +39 -0
  112. package/dist/esm/event/index.js +14 -19
  113. package/dist/esm/{utils/edit → event}/input.js +39 -37
  114. package/dist/esm/{utils/edit/walkRadio.js → event/radio.js} +13 -7
  115. package/dist/esm/event/selection/getInputRange.js +16 -0
  116. package/dist/esm/event/selection/getTargetTypeAndSelection.js +37 -0
  117. package/dist/esm/event/selection/index.js +9 -0
  118. package/dist/esm/event/selection/modifySelection.js +26 -0
  119. package/dist/esm/event/selection/modifySelectionPerMouse.js +46 -0
  120. package/dist/esm/event/selection/moveSelection.js +44 -0
  121. package/dist/esm/{utils/focus → event/selection}/resolveCaretPosition.js +9 -17
  122. package/dist/esm/event/selection/selectAll.js +43 -0
  123. package/dist/esm/event/selection/setSelection.js +26 -0
  124. package/dist/esm/event/selection/setSelectionPerMouse.js +87 -0
  125. package/dist/esm/event/selection/setSelectionRange.js +36 -0
  126. package/dist/esm/event/selection/updateSelectionOnFocus.js +42 -0
  127. package/dist/esm/event/wrapEvent.js +2 -1
  128. package/dist/esm/index.js +1 -1
  129. package/dist/esm/keyboard/index.js +13 -23
  130. package/dist/esm/keyboard/parseKeyDef.js +9 -17
  131. package/dist/esm/options.js +1 -26
  132. package/dist/esm/pointer/index.js +28 -38
  133. package/dist/esm/pointer/keyMap.js +1 -1
  134. package/dist/esm/pointer/parseKeyDef.js +2 -10
  135. package/dist/esm/setup/api.js +33 -12
  136. package/dist/esm/setup/directApi.js +6 -6
  137. package/dist/esm/setup/index.js +0 -1
  138. package/dist/esm/setup/setup.js +66 -39
  139. package/dist/esm/setup/wrapAsync.js +2 -1
  140. package/dist/esm/system/index.js +15 -2
  141. package/dist/esm/system/keyboard.js +34 -21
  142. package/dist/esm/system/pointer/buttons.js +14 -1
  143. package/dist/esm/system/pointer/device.js +14 -1
  144. package/dist/esm/system/pointer/index.js +61 -45
  145. package/dist/esm/system/pointer/mouse.js +74 -53
  146. package/dist/esm/system/pointer/pointer.js +55 -41
  147. package/dist/esm/system/pointer/shared.js +6 -0
  148. package/dist/esm/utility/clear.js +10 -11
  149. package/dist/esm/utility/selectOptions.js +24 -25
  150. package/dist/esm/utility/type.js +5 -14
  151. package/dist/esm/utility/upload.js +9 -18
  152. package/dist/esm/utils/dataTransfer/Clipboard.js +26 -24
  153. package/dist/esm/utils/dataTransfer/DataTransfer.js +25 -9
  154. package/dist/esm/utils/edit/isEditable.js +4 -8
  155. package/dist/esm/utils/edit/maxLength.js +5 -17
  156. package/dist/esm/utils/edit/setFiles.js +4 -4
  157. package/dist/esm/utils/edit/{buildTimeValue.js → timeValue.js} +6 -1
  158. package/dist/esm/utils/focus/cursor.js +2 -18
  159. package/dist/esm/utils/focus/getActiveElement.js +4 -3
  160. package/dist/esm/utils/focus/selection.js +3 -265
  161. package/dist/esm/utils/focus/selector.js +1 -1
  162. package/dist/esm/utils/index.js +4 -11
  163. package/dist/esm/utils/keyDef/readNextDescriptor.js +5 -5
  164. package/dist/esm/utils/misc/getTreeDiff.js +3 -3
  165. package/dist/esm/utils/misc/getWindow.js +2 -1
  166. package/dist/esm/utils/misc/isDisabled.js +3 -3
  167. package/dist/esm/utils/misc/isVisible.js +3 -2
  168. package/dist/esm/utils/misc/level.js +4 -9
  169. package/dist/esm/utils/misc/wait.js +1 -1
  170. package/dist/esm/utils/pointer/cssPointerEvents.js +31 -40
  171. package/dist/types/_interop/dtl.d.ts +3 -0
  172. package/dist/types/_interop/dtlEventMap.d.ts +3 -0
  173. package/dist/types/_interop/dtlHelpers.d.ts +3 -0
  174. package/dist/types/clipboard/copy.d.ts +1 -1
  175. package/dist/types/clipboard/cut.d.ts +1 -1
  176. package/dist/types/clipboard/paste.d.ts +1 -1
  177. package/dist/types/convenience/click.d.ts +1 -1
  178. package/dist/types/convenience/hover.d.ts +1 -1
  179. package/dist/types/convenience/tab.d.ts +1 -1
  180. package/dist/types/document/UI.d.ts +42 -0
  181. package/dist/types/document/getValueOrTextContent.d.ts +1 -0
  182. package/dist/types/document/index.d.ts +5 -10
  183. package/dist/types/document/interceptor.d.ts +6 -3
  184. package/dist/types/document/prepareDocument.d.ts +8 -0
  185. package/dist/types/document/trackValue.d.ts +17 -0
  186. package/dist/types/event/behavior/registry.d.ts +2 -2
  187. package/dist/types/event/createEvent.d.ts +1 -1
  188. package/dist/types/event/dispatchEvent.d.ts +5 -2
  189. package/dist/types/event/eventMap.d.ts +8 -0
  190. package/dist/types/event/focus.d.ts +5 -0
  191. package/dist/types/event/index.d.ts +6 -4
  192. package/dist/types/event/input.d.ts +2 -0
  193. package/dist/types/event/radio.d.ts +4 -0
  194. package/dist/types/event/selection/getInputRange.d.ts +5 -0
  195. package/dist/types/event/selection/getTargetTypeAndSelection.d.ts +10 -0
  196. package/dist/types/event/selection/index.d.ts +15 -0
  197. package/dist/types/event/selection/modifySelection.d.ts +8 -0
  198. package/dist/types/event/selection/modifySelectionPerMouse.d.ts +7 -0
  199. package/dist/types/event/selection/moveSelection.d.ts +4 -0
  200. package/dist/types/event/selection/setSelection.d.ts +10 -0
  201. package/dist/types/event/selection/setSelectionPerMouse.d.ts +8 -0
  202. package/dist/types/event/selection/setSelectionRange.d.ts +6 -0
  203. package/dist/types/event/selection/updateSelectionOnFocus.d.ts +5 -0
  204. package/dist/types/event/types.d.ts +3 -3
  205. package/dist/types/index.d.ts +3 -1
  206. package/dist/types/keyboard/index.d.ts +2 -2
  207. package/dist/types/options.d.ts +2 -10
  208. package/dist/types/pointer/index.d.ts +7 -7
  209. package/dist/types/setup/api.d.ts +23 -5
  210. package/dist/types/setup/directApi.d.ts +5 -5
  211. package/dist/types/setup/index.d.ts +2 -15
  212. package/dist/types/setup/setup.d.ts +25 -7
  213. package/dist/types/system/keyboard.d.ts +4 -4
  214. package/dist/types/system/pointer/buttons.d.ts +2 -2
  215. package/dist/types/system/pointer/device.d.ts +1 -1
  216. package/dist/types/system/pointer/index.d.ts +7 -25
  217. package/dist/types/system/pointer/mouse.d.ts +6 -6
  218. package/dist/types/system/pointer/pointer.d.ts +8 -8
  219. package/dist/types/system/pointer/shared.d.ts +20 -0
  220. package/dist/types/utility/clear.d.ts +1 -1
  221. package/dist/types/utility/selectOptions.d.ts +1 -1
  222. package/dist/types/utility/type.d.ts +4 -4
  223. package/dist/types/utility/upload.d.ts +1 -1
  224. package/dist/types/utils/click/isClickableInput.d.ts +2 -2
  225. package/dist/types/utils/dataTransfer/Clipboard.d.ts +1 -1
  226. package/dist/types/utils/edit/isEditable.d.ts +6 -7
  227. package/dist/types/utils/edit/maxLength.d.ts +14 -1
  228. package/dist/types/utils/edit/{isValidDateOrTimeValue.d.ts → timeValue.d.ts} +1 -0
  229. package/dist/types/utils/focus/selection.d.ts +4 -69
  230. package/dist/types/utils/index.d.ts +2 -9
  231. package/dist/types/utils/keyDef/readNextDescriptor.d.ts +1 -1
  232. package/dist/types/utils/misc/isElementType.d.ts +1 -1
  233. package/dist/types/utils/misc/level.d.ts +4 -13
  234. package/dist/types/utils/misc/wait.d.ts +2 -2
  235. package/dist/types/utils/pointer/cssPointerEvents.d.ts +4 -4
  236. package/package.json +24 -12
  237. package/dist/cjs/document/selection.js +0 -108
  238. package/dist/cjs/document/setRangeText.js +0 -21
  239. package/dist/cjs/document/value.js +0 -127
  240. package/dist/cjs/setup/config.js +0 -7
  241. package/dist/cjs/utils/edit/getValue.js +0 -35
  242. package/dist/cjs/utils/edit/isValidDateOrTimeValue.js +0 -11
  243. package/dist/cjs/utils/focus/blur.js +0 -16
  244. package/dist/cjs/utils/focus/copySelection.js +0 -46
  245. package/dist/cjs/utils/focus/focus.js +0 -29
  246. package/dist/cjs/utils/focus/selectAll.js +0 -56
  247. package/dist/cjs/utils/misc/eventWrapper.js +0 -15
  248. package/dist/esm/document/selection.js +0 -100
  249. package/dist/esm/document/setRangeText.js +0 -17
  250. package/dist/esm/document/value.js +0 -117
  251. package/dist/esm/setup/config.js +0 -3
  252. package/dist/esm/utils/edit/getValue.js +0 -31
  253. package/dist/esm/utils/edit/isValidDateOrTimeValue.js +0 -7
  254. package/dist/esm/utils/focus/blur.js +0 -12
  255. package/dist/esm/utils/focus/copySelection.js +0 -42
  256. package/dist/esm/utils/focus/focus.js +0 -25
  257. package/dist/esm/utils/focus/selectAll.js +0 -51
  258. package/dist/esm/utils/misc/eventWrapper.js +0 -11
  259. package/dist/types/document/selection.d.ts +0 -29
  260. package/dist/types/document/setRangeText.d.ts +0 -1
  261. package/dist/types/document/value.d.ts +0 -26
  262. package/dist/types/setup/config.d.ts +0 -6
  263. package/dist/types/utils/edit/buildTimeValue.d.ts +0 -1
  264. package/dist/types/utils/edit/getValue.d.ts +0 -1
  265. package/dist/types/utils/edit/input.d.ts +0 -2
  266. package/dist/types/utils/edit/walkRadio.d.ts +0 -4
  267. package/dist/types/utils/focus/blur.d.ts +0 -2
  268. package/dist/types/utils/focus/focus.d.ts +0 -5
  269. package/dist/types/utils/misc/eventWrapper.d.ts +0 -1
  270. /package/dist/cjs/{event → _interop}/dom-events.d.js +0 -0
  271. /package/dist/cjs/{utils/misc → _interop}/dom-helpers.d.js +0 -0
  272. /package/dist/esm/{event → _interop}/dom-events.d.js +0 -0
  273. /package/dist/esm/{utils/misc → _interop}/dom-helpers.d.js +0 -0
  274. /package/dist/types/{utils/focus → document}/copySelection.d.ts +0 -0
  275. /package/dist/types/{utils/focus → event/selection}/resolveCaretPosition.d.ts +0 -0
  276. /package/dist/types/{utils/focus → event/selection}/selectAll.d.ts +0 -0
@@ -1,91 +1,102 @@
1
- import { dispatchUIEvent } from '../../event/index.js';
2
1
  import '../../utils/click/isClickableInput.js';
3
2
  import '../../utils/dataTransfer/Clipboard.js';
4
- import '../../utils/edit/maxLength.js';
5
3
  import '../../utils/edit/isEditable.js';
6
- import '@testing-library/dom';
4
+ import '../../utils/edit/maxLength.js';
7
5
  import '@testing-library/dom/dist/helpers.js';
8
6
  import '../../utils/keyDef/readNextDescriptor.js';
9
7
  import { getTreeDiff } from '../../utils/misc/getTreeDiff.js';
10
8
  import '../../utils/misc/level.js';
11
9
  import { assertPointerEvents, hasPointerEvents } from '../../utils/pointer/cssPointerEvents.js';
12
- import { isDifferentPointerPosition } from './index.js';
10
+ import { isDifferentPointerPosition } from './shared.js';
13
11
 
12
+ function _define_property(obj, key, value) {
13
+ if (key in obj) {
14
+ Object.defineProperty(obj, key, {
15
+ value: value,
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true
19
+ });
20
+ } else {
21
+ obj[key] = value;
22
+ }
23
+ return obj;
24
+ }
14
25
  class Pointer {
15
- init(config, position) {
26
+ init(instance, position) {
16
27
  this.position = position;
17
- const target = this.getTarget(config);
28
+ const target = this.getTarget(instance);
18
29
  const [, enter] = getTreeDiff(null, target);
19
30
  const init = this.getEventInit();
20
- assertPointerEvents(config, target);
21
- dispatchUIEvent(config, target, 'pointerover', init);
22
- enter.forEach((el)=>dispatchUIEvent(config, el, 'pointerenter', init));
31
+ assertPointerEvents(instance, target);
32
+ instance.dispatchUIEvent(target, 'pointerover', init);
33
+ enter.forEach((el)=>instance.dispatchUIEvent(el, 'pointerenter', init));
23
34
  return this;
24
35
  }
25
- move(config, position) {
36
+ move(instance, position) {
26
37
  const prevPosition = this.position;
27
- const prevTarget = this.getTarget(config);
38
+ const prevTarget = this.getTarget(instance);
28
39
  this.position = position;
29
40
  if (!isDifferentPointerPosition(prevPosition, position)) {
30
41
  return;
31
42
  }
32
- const nextTarget = this.getTarget(config);
43
+ const nextTarget = this.getTarget(instance);
33
44
  const init = this.getEventInit();
34
45
  const [leave, enter] = getTreeDiff(prevTarget, nextTarget);
35
46
  return {
36
47
  leave: ()=>{
37
- if (hasPointerEvents(config, prevTarget)) {
48
+ if (hasPointerEvents(instance, prevTarget)) {
38
49
  if (prevTarget !== nextTarget) {
39
- dispatchUIEvent(config, prevTarget, 'pointerout', init);
40
- leave.forEach((el)=>dispatchUIEvent(config, el, 'pointerleave', init));
50
+ instance.dispatchUIEvent(prevTarget, 'pointerout', init);
51
+ leave.forEach((el)=>instance.dispatchUIEvent(el, 'pointerleave', init));
41
52
  }
42
53
  }
43
54
  },
44
55
  enter: ()=>{
45
- assertPointerEvents(config, nextTarget);
56
+ assertPointerEvents(instance, nextTarget);
46
57
  if (prevTarget !== nextTarget) {
47
- dispatchUIEvent(config, nextTarget, 'pointerover', init);
48
- enter.forEach((el)=>dispatchUIEvent(config, el, 'pointerenter', init));
58
+ instance.dispatchUIEvent(nextTarget, 'pointerover', init);
59
+ enter.forEach((el)=>instance.dispatchUIEvent(el, 'pointerenter', init));
49
60
  }
50
61
  },
51
62
  move: ()=>{
52
- dispatchUIEvent(config, nextTarget, 'pointermove', init);
63
+ instance.dispatchUIEvent(nextTarget, 'pointermove', init);
53
64
  }
54
65
  };
55
66
  }
56
- down(config, _keyDef) {
67
+ down(instance, _keyDef) {
57
68
  if (this.isDown) {
58
69
  return;
59
70
  }
60
- const target = this.getTarget(config);
61
- assertPointerEvents(config, target);
71
+ const target = this.getTarget(instance);
72
+ assertPointerEvents(instance, target);
62
73
  this.isDown = true;
63
- this.isPrevented = !dispatchUIEvent(config, target, 'pointerdown', this.getEventInit());
74
+ this.isPrevented = !instance.dispatchUIEvent(target, 'pointerdown', this.getEventInit());
64
75
  }
65
- up(config, _keyDef) {
76
+ up(instance, _keyDef) {
66
77
  if (!this.isDown) {
67
78
  return;
68
79
  }
69
- const target = this.getTarget(config);
70
- assertPointerEvents(config, target);
80
+ const target = this.getTarget(instance);
81
+ assertPointerEvents(instance, target);
71
82
  this.isDown = false;
72
- dispatchUIEvent(config, target, 'pointerup', this.getEventInit());
83
+ instance.dispatchUIEvent(target, 'pointerup', this.getEventInit());
73
84
  }
74
- release(config) {
75
- const target = this.getTarget(config);
85
+ release(instance) {
86
+ const target = this.getTarget(instance);
76
87
  const [leave] = getTreeDiff(target, null);
77
88
  const init = this.getEventInit();
78
89
  // Currently there is no PointerEventsCheckLevel that would
79
90
  // make this check not use the *asserted* cached value from `up`.
80
- /* istanbul ignore else */ if (hasPointerEvents(config, target)) {
81
- dispatchUIEvent(config, target, 'pointerout', init);
82
- leave.forEach((el)=>dispatchUIEvent(config, el, 'pointerleave', init));
91
+ /* istanbul ignore else */ if (hasPointerEvents(instance, target)) {
92
+ instance.dispatchUIEvent(target, 'pointerout', init);
93
+ leave.forEach((el)=>instance.dispatchUIEvent(el, 'pointerleave', init));
83
94
  }
84
95
  this.isCancelled = true;
85
96
  }
86
- getTarget(config) {
87
- var _target;
88
- return (_target = this.position.target) !== null && _target !== void 0 ? _target : config.document.body;
97
+ getTarget(instance) {
98
+ var _this_position_target;
99
+ return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
89
100
  }
90
101
  getEventInit() {
91
102
  return {
@@ -95,12 +106,15 @@ class Pointer {
95
106
  isPrimary: this.isPrimary
96
107
  };
97
108
  }
98
- constructor({ pointerId , pointerType , isPrimary }){
99
- this.isMultitouch = false;
100
- this.isCancelled = false;
101
- this.isDown = false;
102
- this.isPrevented = false;
103
- this.position = {};
109
+ constructor({ pointerId, pointerType, isPrimary }){
110
+ _define_property(this, "pointerId", void 0);
111
+ _define_property(this, "pointerType", void 0);
112
+ _define_property(this, "isPrimary", void 0);
113
+ _define_property(this, "isMultitouch", false);
114
+ _define_property(this, "isCancelled", false);
115
+ _define_property(this, "isDown", false);
116
+ _define_property(this, "isPrevented", false);
117
+ _define_property(this, "position", {});
104
118
  this.pointerId = pointerId;
105
119
  this.pointerType = pointerType;
106
120
  this.isPrimary = isPrimary;
@@ -0,0 +1,6 @@
1
+ function isDifferentPointerPosition(positionA, positionB) {
2
+ var _positionA_coords, _positionB_coords, _positionA_coords1, _positionB_coords1, _positionA_caret, _positionB_caret, _positionA_caret1, _positionB_caret1;
3
+ return positionA.target !== positionB.target || ((_positionA_coords = positionA.coords) === null || _positionA_coords === void 0 ? void 0 : _positionA_coords.x) !== ((_positionB_coords = positionB.coords) === null || _positionB_coords === void 0 ? void 0 : _positionB_coords.y) || ((_positionA_coords1 = positionA.coords) === null || _positionA_coords1 === void 0 ? void 0 : _positionA_coords1.y) !== ((_positionB_coords1 = positionB.coords) === null || _positionB_coords1 === void 0 ? void 0 : _positionB_coords1.y) || ((_positionA_caret = positionA.caret) === null || _positionA_caret === void 0 ? void 0 : _positionA_caret.node) !== ((_positionB_caret = positionB.caret) === null || _positionB_caret === void 0 ? void 0 : _positionB_caret.node) || ((_positionA_caret1 = positionA.caret) === null || _positionA_caret1 === void 0 ? void 0 : _positionA_caret1.offset) !== ((_positionB_caret1 = positionB.caret) === null || _positionB_caret1 === void 0 ? void 0 : _positionB_caret1.offset);
4
+ }
5
+
6
+ export { isDifferentPointerPosition };
@@ -1,7 +1,3 @@
1
- import '../setup/index.js';
2
- import '../utils/click/isClickableInput.js';
3
- import '../utils/dataTransfer/Clipboard.js';
4
- import '../event/eventMap.js';
5
1
  import '../event/behavior/click.js';
6
2
  import '../event/behavior/cut.js';
7
3
  import '../event/behavior/keydown.js';
@@ -9,22 +5,25 @@ import '../event/behavior/keypress.js';
9
5
  import '../event/behavior/keyup.js';
10
6
  import '../event/behavior/paste.js';
11
7
  import '@testing-library/dom';
12
- import { input } from '../utils/edit/input.js';
8
+ import '../event/eventMap.js';
9
+ import '../utils/click/isClickableInput.js';
10
+ import '../utils/dataTransfer/Clipboard.js';
13
11
  import { isEditable } from '../utils/edit/isEditable.js';
14
- import { focus } from '../utils/focus/focus.js';
15
- import '@testing-library/dom/dist/helpers.js';
12
+ import '../utils/edit/maxLength.js';
16
13
  import { isDisabled } from '../utils/misc/isDisabled.js';
17
- import { selectAll, isAllSelected } from '../utils/focus/selectAll.js';
14
+ import '@testing-library/dom/dist/helpers.js';
18
15
  import '../utils/keyDef/readNextDescriptor.js';
19
16
  import '../utils/misc/level.js';
20
17
  import '../options.js';
21
- import { Config } from '../setup/config.js';
18
+ import { focusElement } from '../event/focus.js';
19
+ import { input } from '../event/input.js';
20
+ import { selectAll, isAllSelected } from '../event/selection/selectAll.js';
22
21
 
23
22
  async function clear(element) {
24
23
  if (!isEditable(element) || isDisabled(element)) {
25
24
  throw new Error('clear()` is only supported on editable elements.');
26
25
  }
27
- focus(element);
26
+ focusElement(element);
28
27
  if (element.ownerDocument.activeElement !== element) {
29
28
  throw new Error('The element to be cleared could not be focused.');
30
29
  }
@@ -32,7 +31,7 @@ async function clear(element) {
32
31
  if (!isAllSelected(element)) {
33
32
  throw new Error('The element content to be cleared could not be selected.');
34
33
  }
35
- input(this[Config], element, '', 'deleteContentBackward');
34
+ input(this, element, '', 'deleteContentBackward');
36
35
  }
37
36
 
38
37
  export { clear };
@@ -1,26 +1,25 @@
1
- import { getConfig } from '@testing-library/dom';
1
+ import dtl from '../_interop/dtl.js';
2
2
  import '../utils/click/isClickableInput.js';
3
3
  import '../utils/dataTransfer/Clipboard.js';
4
- import '../event/eventMap.js';
5
- import '../event/behavior/click.js';
6
- import '../event/behavior/cut.js';
7
- import '../event/behavior/keydown.js';
8
- import '../event/behavior/keypress.js';
9
- import '../event/behavior/keyup.js';
10
- import '../event/behavior/paste.js';
11
- import '../utils/edit/maxLength.js';
12
4
  import '../utils/edit/isEditable.js';
13
- import { focus } from '../utils/focus/focus.js';
14
- import '@testing-library/dom/dist/helpers.js';
15
- import { isDisabled } from '../utils/misc/isDisabled.js';
5
+ import '../utils/edit/maxLength.js';
16
6
  import { isElementType } from '../utils/misc/isElementType.js';
7
+ import { isDisabled } from '../utils/misc/isDisabled.js';
8
+ import '@testing-library/dom/dist/helpers.js';
17
9
  import '../utils/keyDef/readNextDescriptor.js';
18
10
  import '../utils/misc/level.js';
19
11
  import { wait } from '../utils/misc/wait.js';
20
12
  import { hasPointerEvents } from '../utils/pointer/cssPointerEvents.js';
21
- import '../setup/index.js';
22
- import { Config } from '../setup/config.js';
13
+ import '../event/behavior/click.js';
14
+ import '../event/behavior/cut.js';
15
+ import '../event/behavior/keydown.js';
16
+ import '../event/behavior/keypress.js';
17
+ import '../event/behavior/keyup.js';
18
+ import '../event/behavior/paste.js';
19
+ import '../event/eventMap.js';
20
+ import { focusElement } from '../event/focus.js';
23
21
 
22
+ const { getConfig } = dtl;
24
23
  async function selectOptions(select, values) {
25
24
  return selectOptionsBase.call(this, true, select, values);
26
25
  }
@@ -60,7 +59,7 @@ async function selectOptionsBase(newValue, select, values) {
60
59
  if (isElementType(select, 'select')) {
61
60
  if (select.multiple) {
62
61
  for (const option of selectedOptions){
63
- const withPointerEvents = this[Config].pointerEventsCheck === 0 ? true : hasPointerEvents(this[Config], option);
62
+ const withPointerEvents = this.config.pointerEventsCheck === 0 ? true : hasPointerEvents(this, option);
64
63
  // events fired for multiple select are weird. Can't use hover...
65
64
  if (withPointerEvents) {
66
65
  this.dispatchUIEvent(option, 'pointerover');
@@ -72,7 +71,7 @@ async function selectOptionsBase(newValue, select, values) {
72
71
  this.dispatchUIEvent(option, 'pointerdown');
73
72
  this.dispatchUIEvent(option, 'mousedown');
74
73
  }
75
- focus(select);
74
+ focusElement(select);
76
75
  if (withPointerEvents) {
77
76
  this.dispatchUIEvent(option, 'pointerup');
78
77
  this.dispatchUIEvent(option, 'mouseup');
@@ -81,18 +80,18 @@ async function selectOptionsBase(newValue, select, values) {
81
80
  if (withPointerEvents) {
82
81
  this.dispatchUIEvent(option, 'click');
83
82
  }
84
- await wait(this[Config]);
83
+ await wait(this.config);
85
84
  }
86
85
  } else if (selectedOptions.length === 1) {
87
- const withPointerEvents1 = this[Config].pointerEventsCheck === 0 ? true : hasPointerEvents(this[Config], select);
86
+ const withPointerEvents = this.config.pointerEventsCheck === 0 ? true : hasPointerEvents(this, select);
88
87
  // the click to open the select options
89
- if (withPointerEvents1) {
88
+ if (withPointerEvents) {
90
89
  await this.click(select);
91
90
  } else {
92
- focus(select);
91
+ focusElement(select);
93
92
  }
94
93
  selectOption(selectedOptions[0]);
95
- if (withPointerEvents1) {
94
+ if (withPointerEvents) {
96
95
  // the browser triggers another click event on the select for the click on the option
97
96
  // this second click has no 'down' phase
98
97
  this.dispatchUIEvent(select, 'pointerover');
@@ -103,14 +102,14 @@ async function selectOptionsBase(newValue, select, values) {
103
102
  this.dispatchUIEvent(select, 'mouseup');
104
103
  this.dispatchUIEvent(select, 'click');
105
104
  }
106
- await wait(this[Config]);
105
+ await wait(this.config);
107
106
  } else {
108
107
  throw getConfig().getElementError(`Cannot select multiple options on a non-multiple select`, select);
109
108
  }
110
109
  } else if (select.getAttribute('role') === 'listbox') {
111
- for (const option1 of selectedOptions){
112
- await this.click(option1);
113
- await this.unhover(option1);
110
+ for (const option of selectedOptions){
111
+ await this.click(option);
112
+ await this.unhover(option);
114
113
  }
115
114
  } else {
116
115
  throw getConfig().getElementError(`Cannot select options on elements that are neither select nor listbox elements`, select);
@@ -1,24 +1,15 @@
1
+ import { releaseAllKeys } from '../keyboard/index.js';
1
2
  import '../utils/click/isClickableInput.js';
2
3
  import '../utils/dataTransfer/Clipboard.js';
3
- import '../event/eventMap.js';
4
- import '../event/behavior/click.js';
5
- import '../event/behavior/cut.js';
6
- import '../event/behavior/keydown.js';
7
- import '../event/behavior/keypress.js';
8
- import '../event/behavior/keyup.js';
9
- import '../event/behavior/paste.js';
10
- import '@testing-library/dom';
11
- import '../utils/edit/maxLength.js';
12
4
  import '../utils/edit/isEditable.js';
13
- import { setSelectionRange } from '../utils/focus/selection.js';
5
+ import '../utils/edit/maxLength.js';
14
6
  import '@testing-library/dom/dist/helpers.js';
15
7
  import '../utils/keyDef/readNextDescriptor.js';
16
8
  import '../utils/misc/level.js';
17
9
  import '../options.js';
18
- import { releaseAllKeys } from '../keyboard/index.js';
19
- import { Config } from '../setup/config.js';
10
+ import { setSelectionRange } from '../event/selection/setSelectionRange.js';
20
11
 
21
- async function type(element, text, { skipClick =this[Config].skipClick , skipAutoClose =this[Config].skipAutoClose , initialSelectionStart , initialSelectionEnd } = {}) {
12
+ async function type(element, text, { skipClick = this.config.skipClick, skipAutoClose = this.config.skipAutoClose, initialSelectionStart, initialSelectionEnd } = {}) {
22
13
  // TODO: properly type guard
23
14
  // we use this workaround for now to prevent changing behavior
24
15
  if (element.disabled) return;
@@ -30,7 +21,7 @@ async function type(element, text, { skipClick =this[Config].skipClick , skipAut
30
21
  }
31
22
  await this.keyboard(text);
32
23
  if (!skipAutoClose) {
33
- await releaseAllKeys(this[Config]);
24
+ await releaseAllKeys(this);
34
25
  }
35
26
  }
36
27
 
@@ -1,43 +1,34 @@
1
1
  import '../utils/click/isClickableInput.js';
2
2
  import { createFileList } from '../utils/dataTransfer/FileList.js';
3
3
  import '../utils/dataTransfer/Clipboard.js';
4
- import '../event/eventMap.js';
5
- import '../event/behavior/click.js';
6
- import '../event/behavior/cut.js';
7
- import '../event/behavior/keydown.js';
8
- import '../event/behavior/keypress.js';
9
- import '../event/behavior/keyup.js';
10
- import '../event/behavior/paste.js';
11
- import '@testing-library/dom';
12
- import '../utils/edit/maxLength.js';
13
4
  import '../utils/edit/isEditable.js';
5
+ import '../utils/edit/maxLength.js';
14
6
  import { setFiles } from '../utils/edit/setFiles.js';
15
- import { isDisabled } from '../utils/misc/isDisabled.js';
16
7
  import { isElementType } from '../utils/misc/isElementType.js';
8
+ import { isDisabled } from '../utils/misc/isDisabled.js';
17
9
  import { getWindow } from '../utils/misc/getWindow.js';
18
10
  import '../utils/keyDef/readNextDescriptor.js';
19
11
  import '../utils/misc/level.js';
20
12
  import '../options.js';
21
- import '../setup/index.js';
22
- import { Config } from '../setup/config.js';
23
13
 
24
14
  async function upload(element, fileOrFiles) {
25
15
  const input = isElementType(element, 'label') ? element.control : element;
26
16
  if (!input || !isElementType(input, 'input', {
27
17
  type: 'file'
28
18
  })) {
29
- throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === void 0 ? void 0 : input.tagName} element does not accept file uploads`);
19
+ var _input;
20
+ throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${(_input = input) === null || _input === void 0 ? void 0 : _input.tagName} element does not accept file uploads`);
30
21
  }
31
22
  if (isDisabled(element)) return;
32
23
  const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [
33
24
  fileOrFiles
34
- ]).filter((file)=>!this[Config].applyAccept || isAcceptableFile(file, input.accept)).slice(0, input.multiple ? undefined : 1);
25
+ ]).filter((file)=>!this.config.applyAccept || isAcceptableFile(file, input.accept)).slice(0, input.multiple ? undefined : 1);
35
26
  const fileDialog = ()=>{
36
- var ref;
27
+ var _input_files;
37
28
  // do not fire an input event if the file selection does not change
38
- if (files.length === ((ref = input.files) === null || ref === void 0 ? void 0 : ref.length) && files.every((f, i)=>{
39
- var ref;
40
- return f === ((ref = input.files) === null || ref === void 0 ? void 0 : ref.item(i));
29
+ if (files.length === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.length) && files.every((f, i)=>{
30
+ var _input_files;
31
+ return f === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.item(i));
41
32
  })) {
42
33
  return;
43
34
  }
@@ -1,29 +1,28 @@
1
- import '../click/isClickableInput.js';
1
+ import { getWindow } from '../misc/getWindow.js';
2
2
  import { readBlobText } from './Blob.js';
3
3
  import { createDataTransfer, getBlobFromDataTransferItem } from './DataTransfer.js';
4
- import '../../event/eventMap.js';
5
- import '../../event/behavior/click.js';
6
- import '../../event/behavior/cut.js';
7
- import '../../event/behavior/keydown.js';
8
- import '../../event/behavior/keypress.js';
9
- import '../../event/behavior/keyup.js';
10
- import '../../event/behavior/paste.js';
11
- import '@testing-library/dom';
12
- import '../edit/maxLength.js';
13
- import '../edit/isEditable.js';
14
- import { getWindow } from '../misc/getWindow.js';
15
- import '../keyDef/readNextDescriptor.js';
16
- import '../misc/level.js';
17
- import '../../options.js';
18
4
 
19
5
  // Clipboard is not available in jsdom
6
+ function _define_property(obj, key, value) {
7
+ if (key in obj) {
8
+ Object.defineProperty(obj, key, {
9
+ value: value,
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true
13
+ });
14
+ } else {
15
+ obj[key] = value;
16
+ }
17
+ return obj;
18
+ }
20
19
  // MDN lists string|Blob|Promise<Blob|string> as possible types in ClipboardItemData
21
20
  // lib.dom.d.ts lists only Promise<Blob|string>
22
21
  // https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/ClipboardItem#syntax
23
22
  function createClipboardItem(window, ...blobs) {
24
23
  const dataMap = Object.fromEntries(blobs.map((b)=>[
25
24
  typeof b === 'string' ? 'text/plain' : b.type,
26
- Promise.resolve(b),
25
+ Promise.resolve(b)
27
26
  ]));
28
27
  // use real ClipboardItem if available
29
28
  /* istanbul ignore if */ if (typeof window.ClipboardItem !== 'undefined') {
@@ -45,6 +44,7 @@ function createClipboardItem(window, ...blobs) {
45
44
  });
46
45
  }
47
46
  constructor(d){
47
+ _define_property(this, "data", void 0);
48
48
  this.data = d;
49
49
  }
50
50
  }(dataMap);
@@ -75,15 +75,15 @@ function createClipboardStub(window, control) {
75
75
  }
76
76
  constructor(...args){
77
77
  super(...args);
78
- this.items = [];
78
+ _define_property(this, "items", []);
79
79
  }
80
80
  }(), {
81
81
  [ClipboardStubControl]: control
82
82
  });
83
83
  }
84
84
  function isClipboardStub(clipboard) {
85
- var ref;
86
- return !!((ref = clipboard) === null || ref === void 0 ? void 0 : ref[ClipboardStubControl]);
85
+ var _clipboard;
86
+ return !!((_clipboard = clipboard) === null || _clipboard === void 0 ? void 0 : _clipboard[ClipboardStubControl]);
87
87
  }
88
88
  function attachClipboardStubToView(window) {
89
89
  if (isClipboardStub(window.navigator.clipboard)) {
@@ -124,8 +124,9 @@ function detachClipboardStubFromView(window) {
124
124
  }
125
125
  }
126
126
  async function readDataTransferFromClipboard(document) {
127
+ var _window;
127
128
  const window = document.defaultView;
128
- const clipboard = window === null || window === void 0 ? void 0 : window.navigator.clipboard;
129
+ const clipboard = (_window = window) === null || _window === void 0 ? void 0 : _window.navigator.clipboard;
129
130
  const items = clipboard && await clipboard.read();
130
131
  if (!items) {
131
132
  throw new Error('The Clipboard API is unavailable.');
@@ -153,11 +154,12 @@ async function writeDataTransferToClipboard(document, clipboardData) {
153
154
  throw new Error('The Clipboard API is unavailable.');
154
155
  }
155
156
  }
156
- /* istanbul ignore else */ if (typeof globalThis.afterEach === 'function') {
157
- globalThis.afterEach(()=>resetClipboardStubOnView(globalThis.window));
157
+ const g = globalThis;
158
+ /* istanbul ignore else */ if (typeof g.afterEach === 'function') {
159
+ g.afterEach(()=>resetClipboardStubOnView(globalThis.window));
158
160
  }
159
- /* istanbul ignore else */ if (typeof globalThis.afterAll === 'function') {
160
- globalThis.afterAll(()=>detachClipboardStubFromView(globalThis.window));
161
+ /* istanbul ignore else */ if (typeof g.afterAll === 'function') {
162
+ g.afterAll(()=>detachClipboardStubFromView(globalThis.window));
161
163
  }
162
164
 
163
165
  export { attachClipboardStubToView, createClipboardItem, detachClipboardStubFromView, readDataTransferFromClipboard, resetClipboardStubOnView, writeDataTransferToClipboard };
@@ -1,5 +1,18 @@
1
1
  import { createFileList } from './FileList.js';
2
2
 
3
+ function _define_property(obj, key, value) {
4
+ if (key in obj) {
5
+ Object.defineProperty(obj, key, {
6
+ value: value,
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true
10
+ });
11
+ } else {
12
+ obj[key] = value;
13
+ }
14
+ return obj;
15
+ }
3
16
  // DataTransfer is not implemented in jsdom.
4
17
  // DataTransfer with FileList is being created by the browser on certain events.
5
18
  class DataTransferItemStub {
@@ -15,8 +28,10 @@ class DataTransferItemStub {
15
28
  throw new Error('not implemented');
16
29
  }
17
30
  constructor(dataOrFile, type){
18
- this.file = null;
19
- this.data = undefined;
31
+ _define_property(this, "kind", void 0);
32
+ _define_property(this, "type", void 0);
33
+ _define_property(this, "file", null);
34
+ _define_property(this, "data", undefined);
20
35
  if (typeof dataOrFile === 'string') {
21
36
  this.kind = 'string';
22
37
  this.type = String(type);
@@ -51,10 +66,11 @@ function getTypeMatcher(type, exact) {
51
66
  function createDataTransferStub(window) {
52
67
  return new class DataTransferStub {
53
68
  getData(format) {
54
- var ref;
55
- const match = (ref = this.items.find(getTypeMatcher(format, true))) !== null && ref !== void 0 ? ref : this.items.find(getTypeMatcher(format, false));
69
+ var _match;
70
+ var _this_items_find;
71
+ const match = (_this_items_find = this.items.find(getTypeMatcher(format, true))) !== null && _this_items_find !== void 0 ? _this_items_find : this.items.find(getTypeMatcher(format, false));
56
72
  let text = '';
57
- match === null || match === void 0 ? void 0 : match.getAsString((t)=>{
73
+ (_match = match) === null || _match === void 0 ? void 0 : _match.getAsString((t)=>{
58
74
  text = t;
59
75
  });
60
76
  return text;
@@ -89,10 +105,10 @@ function createDataTransferStub(window) {
89
105
  }
90
106
  /* istanbul ignore next */ setDragImage() {}
91
107
  constructor(){
92
- this.dropEffect = 'none';
93
- this.effectAllowed = 'uninitialized';
94
- this.items = new DataTransferItemListStub();
95
- this.files = createFileList(window, []);
108
+ _define_property(this, "dropEffect", 'none');
109
+ _define_property(this, "effectAllowed", 'uninitialized');
110
+ _define_property(this, "items", new DataTransferItemListStub());
111
+ _define_property(this, "files", createFileList(window, []));
96
112
  }
97
113
  }();
98
114
  }
@@ -2,9 +2,7 @@ import { isElementType } from '../misc/isElementType.js';
2
2
  import { isContentEditable } from './isContentEditable.js';
3
3
 
4
4
  function isEditable(element) {
5
- return isEditableInput(element) || isElementType(element, 'textarea', {
6
- readOnly: false
7
- }) || isContentEditable(element);
5
+ return isEditableInputOrTextArea(element) && !element.readOnly || isContentEditable(element);
8
6
  }
9
7
  var editableInputTypes;
10
8
  (function(editableInputTypes) {
@@ -21,10 +19,8 @@ var editableInputTypes;
21
19
  editableInputTypes['url'] = 'url';
22
20
  editableInputTypes['week'] = 'week';
23
21
  })(editableInputTypes || (editableInputTypes = {}));
24
- function isEditableInput(element) {
25
- return isElementType(element, 'input', {
26
- readOnly: false
27
- }) && Boolean(editableInputTypes[element.type]);
22
+ function isEditableInputOrTextArea(element) {
23
+ return isElementType(element, 'textarea') || isElementType(element, 'input') && element.type in editableInputTypes;
28
24
  }
29
25
 
30
- export { editableInputTypes, isEditable, isEditableInput };
26
+ export { isEditable, isEditableInputOrTextArea };
@@ -1,5 +1,4 @@
1
1
  import { isElementType } from '../misc/isElementType.js';
2
- import { getValue } from './getValue.js';
3
2
 
4
3
  var maxLengthSupportedTypes;
5
4
  (function(maxLengthSupportedTypes) {
@@ -10,26 +9,15 @@ var maxLengthSupportedTypes;
10
9
  maxLengthSupportedTypes['text'] = 'text';
11
10
  maxLengthSupportedTypes['url'] = 'url';
12
11
  })(maxLengthSupportedTypes || (maxLengthSupportedTypes = {}));
13
- function getSpaceUntilMaxLength(element) {
14
- const value = getValue(element);
15
- /* istanbul ignore if */ if (value === null) {
16
- return undefined;
17
- }
18
- const maxLength = getSanitizedMaxLength(element);
19
- return maxLength ? maxLength - value.length : undefined;
20
- }
21
12
  // can't use .maxLength property because of a jsdom bug:
22
13
  // https://github.com/jsdom/jsdom/issues/2927
23
- function getSanitizedMaxLength(element) {
24
- if (!supportsMaxLength(element)) {
25
- return undefined;
26
- }
27
- var ref;
28
- const attr = (ref = element.getAttribute('maxlength')) !== null && ref !== void 0 ? ref : '';
14
+ function getMaxLength(element) {
15
+ var _element_getAttribute;
16
+ const attr = (_element_getAttribute = element.getAttribute('maxlength')) !== null && _element_getAttribute !== void 0 ? _element_getAttribute : '';
29
17
  return /^\d+$/.test(attr) && Number(attr) >= 0 ? Number(attr) : undefined;
30
18
  }
31
19
  function supportsMaxLength(element) {
32
- return isElementType(element, 'textarea') || isElementType(element, 'input') && Boolean(maxLengthSupportedTypes[element.type]);
20
+ return isElementType(element, 'textarea') || isElementType(element, 'input') && element.type in maxLengthSupportedTypes;
33
21
  }
34
22
 
35
- export { getSpaceUntilMaxLength };
23
+ export { getMaxLength, supportsMaxLength };