@testing-library/user-event 14.4.3 → 14.5.1

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 (181) hide show
  1. package/dist/cjs/_interop/dtl.js +27 -0
  2. package/dist/cjs/_interop/dtlEventMap.js +27 -0
  3. package/dist/cjs/_interop/dtlHelpers.js +27 -0
  4. package/dist/cjs/clipboard/copy.js +2 -2
  5. package/dist/cjs/clipboard/cut.js +2 -2
  6. package/dist/cjs/clipboard/paste.js +4 -4
  7. package/dist/cjs/convenience/tab.js +1 -1
  8. package/dist/cjs/document/UI.js +5 -5
  9. package/dist/cjs/document/interceptor.js +1 -1
  10. package/dist/cjs/document/trackValue.js +4 -4
  11. package/dist/cjs/event/behavior/keydown.js +6 -6
  12. package/dist/cjs/event/behavior/keypress.js +2 -2
  13. package/dist/cjs/event/behavior/keyup.js +2 -2
  14. package/dist/cjs/event/behavior/paste.js +2 -2
  15. package/dist/cjs/event/createEvent.js +41 -41
  16. package/dist/cjs/event/dispatchEvent.js +2 -2
  17. package/dist/cjs/event/eventMap.js +22 -2
  18. package/dist/cjs/event/focus.js +1 -4
  19. package/dist/cjs/event/input.js +4 -4
  20. package/dist/cjs/event/selection/getInputRange.js +2 -2
  21. package/dist/cjs/event/selection/modifySelection.js +3 -3
  22. package/dist/cjs/event/selection/modifySelectionPerMouse.js +1 -1
  23. package/dist/cjs/event/selection/moveSelection.js +5 -5
  24. package/dist/cjs/event/selection/resolveCaretPosition.js +1 -1
  25. package/dist/cjs/event/selection/selectAll.js +4 -4
  26. package/dist/cjs/event/selection/setSelection.js +3 -3
  27. package/dist/cjs/event/selection/setSelectionPerMouse.js +5 -5
  28. package/dist/cjs/event/selection/setSelectionRange.js +2 -2
  29. package/dist/cjs/event/selection/updateSelectionOnFocus.js +2 -2
  30. package/dist/cjs/event/wrapEvent.js +23 -2
  31. package/dist/cjs/index.js +1 -0
  32. package/dist/cjs/keyboard/index.js +2 -2
  33. package/dist/cjs/keyboard/parseKeyDef.js +8 -8
  34. package/dist/cjs/pointer/index.js +11 -11
  35. package/dist/cjs/pointer/keyMap.js +1 -1
  36. package/dist/cjs/pointer/parseKeyDef.js +1 -1
  37. package/dist/cjs/setup/api.js +19 -17
  38. package/dist/cjs/setup/directApi.js +3 -3
  39. package/dist/cjs/setup/setup.js +10 -10
  40. package/dist/cjs/setup/wrapAsync.js +23 -2
  41. package/dist/cjs/system/index.js +15 -2
  42. package/dist/cjs/system/keyboard.js +27 -12
  43. package/dist/cjs/system/pointer/buttons.js +14 -1
  44. package/dist/cjs/system/pointer/device.js +14 -1
  45. package/dist/cjs/system/pointer/index.js +34 -17
  46. package/dist/cjs/system/pointer/mouse.js +33 -19
  47. package/dist/cjs/system/pointer/pointer.js +24 -8
  48. package/dist/cjs/system/pointer/shared.js +2 -2
  49. package/dist/cjs/utility/selectOptions.js +32 -11
  50. package/dist/cjs/utility/type.js +1 -1
  51. package/dist/cjs/utility/upload.js +4 -4
  52. package/dist/cjs/utils/dataTransfer/Clipboard.js +22 -8
  53. package/dist/cjs/utils/dataTransfer/DataTransfer.js +23 -8
  54. package/dist/cjs/utils/edit/maxLength.js +2 -2
  55. package/dist/cjs/utils/edit/setFiles.js +4 -4
  56. package/dist/cjs/utils/focus/cursor.js +2 -2
  57. package/dist/cjs/utils/focus/getActiveElement.js +2 -2
  58. package/dist/cjs/utils/focus/selector.js +1 -1
  59. package/dist/cjs/utils/keyDef/readNextDescriptor.js +5 -5
  60. package/dist/cjs/utils/misc/getTreeDiff.js +3 -3
  61. package/dist/cjs/utils/misc/getWindow.js +23 -2
  62. package/dist/cjs/utils/misc/isDisabled.js +3 -3
  63. package/dist/cjs/utils/misc/isVisible.js +1 -1
  64. package/dist/cjs/utils/misc/wait.js +1 -1
  65. package/dist/cjs/utils/pointer/cssPointerEvents.js +13 -13
  66. package/dist/esm/_interop/dtl.js +2 -0
  67. package/dist/esm/_interop/dtlEventMap.js +2 -0
  68. package/dist/esm/_interop/dtlHelpers.js +2 -0
  69. package/dist/esm/clipboard/copy.js +2 -2
  70. package/dist/esm/clipboard/cut.js +2 -2
  71. package/dist/esm/clipboard/paste.js +4 -4
  72. package/dist/esm/convenience/tab.js +1 -1
  73. package/dist/esm/document/UI.js +5 -5
  74. package/dist/esm/document/interceptor.js +1 -1
  75. package/dist/esm/document/trackValue.js +4 -4
  76. package/dist/esm/event/behavior/keydown.js +6 -6
  77. package/dist/esm/event/behavior/keypress.js +2 -2
  78. package/dist/esm/event/behavior/keyup.js +2 -2
  79. package/dist/esm/event/behavior/paste.js +2 -2
  80. package/dist/esm/event/createEvent.js +41 -41
  81. package/dist/esm/event/dispatchEvent.js +2 -2
  82. package/dist/esm/event/eventMap.js +2 -2
  83. package/dist/esm/event/focus.js +1 -4
  84. package/dist/esm/event/input.js +4 -4
  85. package/dist/esm/event/selection/getInputRange.js +2 -2
  86. package/dist/esm/event/selection/modifySelection.js +3 -3
  87. package/dist/esm/event/selection/modifySelectionPerMouse.js +1 -1
  88. package/dist/esm/event/selection/moveSelection.js +5 -5
  89. package/dist/esm/event/selection/resolveCaretPosition.js +1 -1
  90. package/dist/esm/event/selection/selectAll.js +4 -4
  91. package/dist/esm/event/selection/setSelection.js +3 -3
  92. package/dist/esm/event/selection/setSelectionPerMouse.js +5 -5
  93. package/dist/esm/event/selection/setSelectionRange.js +2 -2
  94. package/dist/esm/event/selection/updateSelectionOnFocus.js +2 -2
  95. package/dist/esm/event/wrapEvent.js +2 -1
  96. package/dist/esm/index.js +1 -1
  97. package/dist/esm/keyboard/index.js +2 -2
  98. package/dist/esm/keyboard/parseKeyDef.js +8 -8
  99. package/dist/esm/pointer/index.js +11 -11
  100. package/dist/esm/pointer/keyMap.js +1 -1
  101. package/dist/esm/pointer/parseKeyDef.js +1 -1
  102. package/dist/esm/setup/api.js +33 -12
  103. package/dist/esm/setup/directApi.js +3 -3
  104. package/dist/esm/setup/setup.js +11 -11
  105. package/dist/esm/setup/wrapAsync.js +2 -1
  106. package/dist/esm/system/index.js +15 -2
  107. package/dist/esm/system/keyboard.js +27 -12
  108. package/dist/esm/system/pointer/buttons.js +14 -1
  109. package/dist/esm/system/pointer/device.js +14 -1
  110. package/dist/esm/system/pointer/index.js +34 -17
  111. package/dist/esm/system/pointer/mouse.js +33 -19
  112. package/dist/esm/system/pointer/pointer.js +24 -8
  113. package/dist/esm/system/pointer/shared.js +2 -2
  114. package/dist/esm/utility/selectOptions.js +8 -7
  115. package/dist/esm/utility/type.js +1 -1
  116. package/dist/esm/utility/upload.js +4 -4
  117. package/dist/esm/utils/dataTransfer/Clipboard.js +22 -8
  118. package/dist/esm/utils/dataTransfer/DataTransfer.js +23 -8
  119. package/dist/esm/utils/edit/maxLength.js +2 -2
  120. package/dist/esm/utils/edit/setFiles.js +4 -4
  121. package/dist/esm/utils/focus/cursor.js +2 -2
  122. package/dist/esm/utils/focus/getActiveElement.js +2 -2
  123. package/dist/esm/utils/focus/selector.js +1 -1
  124. package/dist/esm/utils/keyDef/readNextDescriptor.js +5 -5
  125. package/dist/esm/utils/misc/getTreeDiff.js +3 -3
  126. package/dist/esm/utils/misc/getWindow.js +2 -1
  127. package/dist/esm/utils/misc/isDisabled.js +3 -3
  128. package/dist/esm/utils/misc/isVisible.js +1 -1
  129. package/dist/esm/utils/misc/wait.js +1 -1
  130. package/dist/esm/utils/pointer/cssPointerEvents.js +13 -13
  131. package/dist/types/_interop/dtl.d.ts +2 -0
  132. package/dist/types/_interop/dtlEventMap.d.ts +2 -0
  133. package/dist/types/_interop/dtlHelpers.d.ts +2 -0
  134. package/dist/types/clipboard/copy.d.ts +1 -1
  135. package/dist/types/clipboard/cut.d.ts +1 -1
  136. package/dist/types/clipboard/paste.d.ts +1 -1
  137. package/dist/types/convenience/click.d.ts +1 -1
  138. package/dist/types/convenience/hover.d.ts +1 -1
  139. package/dist/types/convenience/tab.d.ts +1 -1
  140. package/dist/types/document/UI.d.ts +3 -3
  141. package/dist/types/document/interceptor.d.ts +3 -3
  142. package/dist/types/event/behavior/registry.d.ts +1 -1
  143. package/dist/types/event/createEvent.d.ts +1 -1
  144. package/dist/types/event/dispatchEvent.d.ts +1 -1
  145. package/dist/types/event/eventMap.d.ts +8 -0
  146. package/dist/types/event/input.d.ts +1 -1
  147. package/dist/types/event/radio.d.ts +1 -1
  148. package/dist/types/event/selection/index.d.ts +2 -2
  149. package/dist/types/event/selection/modifySelectionPerMouse.d.ts +1 -1
  150. package/dist/types/event/selection/setSelectionPerMouse.d.ts +1 -1
  151. package/dist/types/event/types.d.ts +3 -3
  152. package/dist/types/index.d.ts +3 -1
  153. package/dist/types/keyboard/index.d.ts +1 -1
  154. package/dist/types/options.d.ts +2 -2
  155. package/dist/types/pointer/index.d.ts +7 -7
  156. package/dist/types/setup/api.d.ts +23 -5
  157. package/dist/types/setup/directApi.d.ts +5 -5
  158. package/dist/types/setup/setup.d.ts +5 -5
  159. package/dist/types/system/keyboard.d.ts +2 -2
  160. package/dist/types/system/pointer/buttons.d.ts +2 -2
  161. package/dist/types/system/pointer/device.d.ts +1 -1
  162. package/dist/types/system/pointer/mouse.d.ts +2 -2
  163. package/dist/types/system/pointer/pointer.d.ts +2 -2
  164. package/dist/types/utility/clear.d.ts +1 -1
  165. package/dist/types/utility/selectOptions.d.ts +1 -1
  166. package/dist/types/utility/type.d.ts +2 -2
  167. package/dist/types/utility/upload.d.ts +1 -1
  168. package/dist/types/utils/click/isClickableInput.d.ts +1 -1
  169. package/dist/types/utils/dataTransfer/Clipboard.d.ts +1 -1
  170. package/dist/types/utils/edit/isEditable.d.ts +2 -2
  171. package/dist/types/utils/edit/maxLength.d.ts +1 -1
  172. package/dist/types/utils/keyDef/readNextDescriptor.d.ts +1 -1
  173. package/dist/types/utils/misc/isElementType.d.ts +1 -1
  174. package/dist/types/utils/misc/level.d.ts +2 -2
  175. package/dist/types/utils/misc/wait.d.ts +1 -1
  176. package/dist/types/utils/pointer/cssPointerEvents.d.ts +1 -1
  177. package/package.json +22 -11
  178. /package/dist/cjs/{event → _interop}/dom-events.d.js +0 -0
  179. /package/dist/cjs/{utils/misc → _interop}/dom-helpers.d.js +0 -0
  180. /package/dist/esm/{event → _interop}/dom-events.d.js +0 -0
  181. /package/dist/esm/{utils/misc → _interop}/dom-helpers.d.js +0 -0
@@ -7,7 +7,19 @@ var device = require('./device.js');
7
7
  var mouse = require('./mouse.js');
8
8
  var pointer = require('./pointer.js');
9
9
 
10
- var _registry, _k;
10
+ function _define_property(obj, key, value) {
11
+ if (key in obj) {
12
+ Object.defineProperty(obj, key, {
13
+ value: value,
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true
17
+ });
18
+ } else {
19
+ obj[key] = value;
20
+ }
21
+ return obj;
22
+ }
11
23
  class PointerHost {
12
24
  isKeyPressed(keyDef) {
13
25
  return this.devices.get(keyDef.pointerType).isPressed(keyDef);
@@ -67,10 +79,10 @@ class PointerHost {
67
79
  this.mouse.down(instance, keyDef, pointer);
68
80
  }
69
81
  if (!pointer.isMultitouch) {
70
- const mousemove1 = this.mouse.move(instance, pointer.position);
71
- mousemove1 === null || mousemove1 === void 0 ? void 0 : mousemove1.leave();
72
- mousemove1 === null || mousemove1 === void 0 ? void 0 : mousemove1.enter();
73
- mousemove1 === null || mousemove1 === void 0 ? void 0 : mousemove1.move();
82
+ const mousemove = this.mouse.move(instance, pointer.position);
83
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
84
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
85
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
74
86
  this.mouse.up(instance, keyDef, pointer);
75
87
  }
76
88
  }
@@ -85,25 +97,30 @@ class PointerHost {
85
97
  this.mouse.resetClickCount();
86
98
  }
87
99
  getMouseTarget(instance) {
88
- var _target;
89
- return (_target = this.mouse.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
100
+ var _this_mouse_position_target;
101
+ return (_this_mouse_position_target = this.mouse.position.target) !== null && _this_mouse_position_target !== void 0 ? _this_mouse_position_target : instance.config.document.body;
90
102
  }
91
103
  setMousePosition(position) {
92
104
  this.mouse.position = position;
93
105
  this.pointers.get('mouse').position = position;
94
106
  }
95
107
  constructor(system){
96
- this.devices = new class {
108
+ _define_property(this, "system", void 0);
109
+ _define_property(this, "mouse", void 0);
110
+ _define_property(this, "buttons", void 0);
111
+ _define_property(this, "devices", new class {
97
112
  get(k) {
98
- var ref;
99
- (ref = (_registry = this.registry)[_k = k]) !== null && ref !== void 0 ? ref : _registry[_k] = new device.Device();
113
+ var // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
114
+ _this_registry, _k;
115
+ var _;
116
+ (_ = (_this_registry = this.registry)[_k = k]) !== null && _ !== void 0 ? _ : _this_registry[_k] = new device.Device();
100
117
  return this.registry[k];
101
118
  }
102
119
  constructor(){
103
- this.registry = {};
120
+ _define_property(this, "registry", {});
104
121
  }
105
- }();
106
- this.pointers = new class {
122
+ }());
123
+ _define_property(this, "pointers", new class {
107
124
  new(pointerName, keyDef) {
108
125
  const isPrimary = keyDef.pointerType !== 'touch' || !Object.values(this.registry).some((p)=>p.pointerType === 'touch' && !p.isCancelled);
109
126
  if (!isPrimary) {
@@ -130,16 +147,16 @@ class PointerHost {
130
147
  return pointerName in this.registry;
131
148
  }
132
149
  constructor(){
133
- this.registry = {
150
+ _define_property(this, "registry", {
134
151
  mouse: new pointer.Pointer({
135
152
  pointerId: 1,
136
153
  pointerType: 'mouse',
137
154
  isPrimary: true
138
155
  })
139
- };
140
- this.nextId = 2;
156
+ });
157
+ _define_property(this, "nextId", 2);
141
158
  }
142
- }();
159
+ }());
143
160
  this.system = system;
144
161
  this.buttons = new buttons.Buttons();
145
162
  this.mouse = new mouse.Mouse();
@@ -26,6 +26,19 @@ var modifySelectionPerMouse = require('../../event/selection/modifySelectionPerM
26
26
  var buttons = require('./buttons.js');
27
27
  var shared = require('./shared.js');
28
28
 
29
+ function _define_property(obj, key, value) {
30
+ if (key in obj) {
31
+ Object.defineProperty(obj, key, {
32
+ value: value,
33
+ enumerable: true,
34
+ configurable: true,
35
+ writable: true
36
+ });
37
+ } else {
38
+ obj[key] = value;
39
+ }
40
+ return obj;
41
+ }
29
42
  /**
30
43
  * This object is the single "virtual" mouse that might be controlled by multiple different pointer devices.
31
44
  */ class Mouse {
@@ -123,39 +136,40 @@ var shared = require('./shared.js');
123
136
  return init;
124
137
  }
125
138
  getTarget(instance) {
126
- var _target;
127
- return (_target = this.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
139
+ var _this_position_target;
140
+ return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
128
141
  }
129
142
  startSelecting(instance, clickCount) {
130
- var ref, ref1;
143
+ var _this_position_caret, _this_position_caret1;
131
144
  // TODO: support extending range (shift)
132
145
  this.selecting = setSelectionPerMouse.setSelectionPerMouseDown({
133
146
  document: instance.config.document,
134
147
  target: this.getTarget(instance),
135
- node: (ref = this.position.caret) === null || ref === void 0 ? void 0 : ref.node,
136
- offset: (ref1 = this.position.caret) === null || ref1 === void 0 ? void 0 : ref1.offset,
148
+ node: (_this_position_caret = this.position.caret) === null || _this_position_caret === void 0 ? void 0 : _this_position_caret.node,
149
+ offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === void 0 ? void 0 : _this_position_caret1.offset,
137
150
  clickCount
138
151
  });
139
152
  }
140
153
  modifySelecting(instance) {
141
- var ref, ref1;
154
+ var _this_position_caret, _this_position_caret1;
142
155
  if (!this.selecting) {
143
156
  return;
144
157
  }
145
158
  modifySelectionPerMouse.modifySelectionPerMouseMove(this.selecting, {
146
159
  document: instance.config.document,
147
160
  target: this.getTarget(instance),
148
- node: (ref = this.position.caret) === null || ref === void 0 ? void 0 : ref.node,
149
- offset: (ref1 = this.position.caret) === null || ref1 === void 0 ? void 0 : ref1.offset
161
+ node: (_this_position_caret = this.position.caret) === null || _this_position_caret === void 0 ? void 0 : _this_position_caret.node,
162
+ offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === void 0 ? void 0 : _this_position_caret1.offset
150
163
  });
151
164
  }
152
165
  endSelecting() {
153
166
  this.selecting = undefined;
154
167
  }
155
168
  constructor(){
156
- this.position = {};
157
- this.buttons = new buttons.Buttons();
158
- this.buttonDownTarget = {};
169
+ _define_property(this, "position", {});
170
+ _define_property(this, "buttons", new buttons.Buttons());
171
+ _define_property(this, "selecting", void 0);
172
+ _define_property(this, "buttonDownTarget", {});
159
173
  // According to spec the `detail` on click events should be the number
160
174
  // of *consecutive* clicks with a specific button.
161
175
  // On `mousedown` and `mouseup` it should be this number increased by one.
@@ -166,7 +180,7 @@ var shared = require('./shared.js');
166
180
  // If there is a delay while a button is pressed,
167
181
  // the `mouseup` and `click` are normal, but a following `mousedown` starts a new click count.
168
182
  // We'll follow the minimal implementation of Webkit.
169
- this.clickCount = new class {
183
+ _define_property(this, "clickCount", new class {
170
184
  incOnClick(button) {
171
185
  const current = this.down[button] === undefined ? undefined : Number(this.down[button]) + 1;
172
186
  this.count = this.count[button] === undefined ? {} : {
@@ -175,13 +189,13 @@ var shared = require('./shared.js');
175
189
  return current;
176
190
  }
177
191
  getOnDown(button) {
178
- var _button;
192
+ var _this_count_button;
179
193
  this.down = {
180
- [button]: (_button = this.count[button]) !== null && _button !== void 0 ? _button : 0
194
+ [button]: (_this_count_button = this.count[button]) !== null && _this_count_button !== void 0 ? _this_count_button : 0
181
195
  };
182
- var _button1;
196
+ var _this_count_button1;
183
197
  this.count = {
184
- [button]: (_button1 = this.count[button]) !== null && _button1 !== void 0 ? _button1 : 0
198
+ [button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !== void 0 ? _this_count_button1 : 0
185
199
  };
186
200
  return Number(this.count[button]) + 1;
187
201
  }
@@ -192,10 +206,10 @@ var shared = require('./shared.js');
192
206
  this.count = {};
193
207
  }
194
208
  constructor(){
195
- this.down = {};
196
- this.count = {};
209
+ _define_property(this, "down", {});
210
+ _define_property(this, "count", {});
197
211
  }
198
- }();
212
+ }());
199
213
  }
200
214
  }
201
215
 
@@ -13,6 +13,19 @@ require('../../utils/misc/level.js');
13
13
  var cssPointerEvents = require('../../utils/pointer/cssPointerEvents.js');
14
14
  var shared = require('./shared.js');
15
15
 
16
+ function _define_property(obj, key, value) {
17
+ if (key in obj) {
18
+ Object.defineProperty(obj, key, {
19
+ value: value,
20
+ enumerable: true,
21
+ configurable: true,
22
+ writable: true
23
+ });
24
+ } else {
25
+ obj[key] = value;
26
+ }
27
+ return obj;
28
+ }
16
29
  class Pointer {
17
30
  init(instance, position) {
18
31
  this.position = position;
@@ -86,8 +99,8 @@ class Pointer {
86
99
  this.isCancelled = true;
87
100
  }
88
101
  getTarget(instance) {
89
- var _target;
90
- return (_target = this.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
102
+ var _this_position_target;
103
+ return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
91
104
  }
92
105
  getEventInit() {
93
106
  return {
@@ -97,12 +110,15 @@ class Pointer {
97
110
  isPrimary: this.isPrimary
98
111
  };
99
112
  }
100
- constructor({ pointerId , pointerType , isPrimary }){
101
- this.isMultitouch = false;
102
- this.isCancelled = false;
103
- this.isDown = false;
104
- this.isPrevented = false;
105
- this.position = {};
113
+ constructor({ pointerId, pointerType, isPrimary }){
114
+ _define_property(this, "pointerId", void 0);
115
+ _define_property(this, "pointerType", void 0);
116
+ _define_property(this, "isPrimary", void 0);
117
+ _define_property(this, "isMultitouch", false);
118
+ _define_property(this, "isCancelled", false);
119
+ _define_property(this, "isDown", false);
120
+ _define_property(this, "isPrevented", false);
121
+ _define_property(this, "position", {});
106
122
  this.pointerId = pointerId;
107
123
  this.pointerType = pointerType;
108
124
  this.isPrimary = isPrimary;
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function isDifferentPointerPosition(positionA, positionB) {
6
- var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
7
- return positionA.target !== positionB.target || ((ref = positionA.coords) === null || ref === void 0 ? void 0 : ref.x) !== ((ref1 = positionB.coords) === null || ref1 === void 0 ? void 0 : ref1.y) || ((ref2 = positionA.coords) === null || ref2 === void 0 ? void 0 : ref2.y) !== ((ref3 = positionB.coords) === null || ref3 === void 0 ? void 0 : ref3.y) || ((ref4 = positionA.caret) === null || ref4 === void 0 ? void 0 : ref4.node) !== ((ref5 = positionB.caret) === null || ref5 === void 0 ? void 0 : ref5.node) || ((ref6 = positionA.caret) === null || ref6 === void 0 ? void 0 : ref6.offset) !== ((ref7 = positionB.caret) === null || ref7 === void 0 ? void 0 : ref7.offset);
6
+ var _positionA_coords, _positionB_coords, _positionA_coords1, _positionB_coords1, _positionA_caret, _positionB_caret, _positionA_caret1, _positionB_caret1;
7
+ 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);
8
8
  }
9
9
 
10
10
  exports.isDifferentPointerPosition = isDifferentPointerPosition;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dom = require('@testing-library/dom');
5
+ var named = require('@testing-library/dom');
6
6
  require('../utils/click/isClickableInput.js');
7
7
  require('../utils/dataTransfer/Clipboard.js');
8
8
  require('../utils/edit/isEditable.js');
@@ -23,6 +23,27 @@ require('../event/behavior/paste.js');
23
23
  require('../event/eventMap.js');
24
24
  var focus = require('../event/focus.js');
25
25
 
26
+ function _interopNamespace(e) {
27
+ if (e && e.__esModule) return e;
28
+ var n = Object.create(null);
29
+ if (e) {
30
+ Object.keys(e).forEach(function (k) {
31
+ if (k !== 'default') {
32
+ var d = Object.getOwnPropertyDescriptor(e, k);
33
+ Object.defineProperty(n, k, d.get ? d : {
34
+ enumerable: true,
35
+ get: function () { return e[k]; }
36
+ });
37
+ }
38
+ });
39
+ }
40
+ n["default"] = e;
41
+ return Object.freeze(n);
42
+ }
43
+
44
+ var named__namespace = /*#__PURE__*/_interopNamespace(named);
45
+
46
+ const { getConfig } = named__namespace;
26
47
  async function selectOptions(select, values) {
27
48
  return selectOptionsBase.call(this, true, select, values);
28
49
  }
@@ -31,7 +52,7 @@ async function deselectOptions(select, values) {
31
52
  }
32
53
  async function selectOptionsBase(newValue, select, values) {
33
54
  if (!newValue && !select.multiple) {
34
- throw dom.getConfig().getElementError(`Unable to deselect an option in a non-multiple select. Use selectOptions to change the selection instead.`, select);
55
+ throw getConfig().getElementError(`Unable to deselect an option in a non-multiple select. Use selectOptions to change the selection instead.`, select);
35
56
  }
36
57
  const valArray = Array.isArray(values) ? values : [
37
58
  values
@@ -45,7 +66,7 @@ async function selectOptionsBase(newValue, select, values) {
45
66
  if (matchingOption) {
46
67
  return matchingOption;
47
68
  } else {
48
- throw dom.getConfig().getElementError(`Value "${String(val)}" not found in options`, select);
69
+ throw getConfig().getElementError(`Value "${String(val)}" not found in options`, select);
49
70
  }
50
71
  }
51
72
  }).filter((option)=>!isDisabled.isDisabled(option));
@@ -86,15 +107,15 @@ async function selectOptionsBase(newValue, select, values) {
86
107
  await wait.wait(this.config);
87
108
  }
88
109
  } else if (selectedOptions.length === 1) {
89
- const withPointerEvents1 = this.config.pointerEventsCheck === 0 ? true : cssPointerEvents.hasPointerEvents(this, select);
110
+ const withPointerEvents = this.config.pointerEventsCheck === 0 ? true : cssPointerEvents.hasPointerEvents(this, select);
90
111
  // the click to open the select options
91
- if (withPointerEvents1) {
112
+ if (withPointerEvents) {
92
113
  await this.click(select);
93
114
  } else {
94
115
  focus.focusElement(select);
95
116
  }
96
117
  selectOption(selectedOptions[0]);
97
- if (withPointerEvents1) {
118
+ if (withPointerEvents) {
98
119
  // the browser triggers another click event on the select for the click on the option
99
120
  // this second click has no 'down' phase
100
121
  this.dispatchUIEvent(select, 'pointerover');
@@ -107,15 +128,15 @@ async function selectOptionsBase(newValue, select, values) {
107
128
  }
108
129
  await wait.wait(this.config);
109
130
  } else {
110
- throw dom.getConfig().getElementError(`Cannot select multiple options on a non-multiple select`, select);
131
+ throw getConfig().getElementError(`Cannot select multiple options on a non-multiple select`, select);
111
132
  }
112
133
  } else if (select.getAttribute('role') === 'listbox') {
113
- for (const option1 of selectedOptions){
114
- await this.click(option1);
115
- await this.unhover(option1);
134
+ for (const option of selectedOptions){
135
+ await this.click(option);
136
+ await this.unhover(option);
116
137
  }
117
138
  } else {
118
- throw dom.getConfig().getElementError(`Cannot select options on elements that are neither select nor listbox elements`, select);
139
+ throw getConfig().getElementError(`Cannot select options on elements that are neither select nor listbox elements`, select);
119
140
  }
120
141
  }
121
142
 
@@ -13,7 +13,7 @@ require('../utils/misc/level.js');
13
13
  require('../options.js');
14
14
  var setSelectionRange = require('../event/selection/setSelectionRange.js');
15
15
 
16
- async function type(element, text, { skipClick =this.config.skipClick , skipAutoClose =this.config.skipAutoClose , initialSelectionStart , initialSelectionEnd } = {}) {
16
+ async function type(element, text, { skipClick = this.config.skipClick, skipAutoClose = this.config.skipAutoClose, initialSelectionStart, initialSelectionEnd } = {}) {
17
17
  // TODO: properly type guard
18
18
  // we use this workaround for now to prevent changing behavior
19
19
  if (element.disabled) return;
@@ -27,11 +27,11 @@ async function upload(element, fileOrFiles) {
27
27
  fileOrFiles
28
28
  ]).filter((file)=>!this.config.applyAccept || isAcceptableFile(file, input.accept)).slice(0, input.multiple ? undefined : 1);
29
29
  const fileDialog = ()=>{
30
- var ref;
30
+ var _input_files;
31
31
  // do not fire an input event if the file selection does not change
32
- if (files.length === ((ref = input.files) === null || ref === void 0 ? void 0 : ref.length) && files.every((f, i)=>{
33
- var ref;
34
- return f === ((ref = input.files) === null || ref === void 0 ? void 0 : ref.item(i));
32
+ if (files.length === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.length) && files.every((f, i)=>{
33
+ var _input_files;
34
+ return f === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.item(i));
35
35
  })) {
36
36
  return;
37
37
  }
@@ -7,13 +7,26 @@ var Blob = require('./Blob.js');
7
7
  var DataTransfer = require('./DataTransfer.js');
8
8
 
9
9
  // Clipboard is not available in jsdom
10
+ function _define_property(obj, key, value) {
11
+ if (key in obj) {
12
+ Object.defineProperty(obj, key, {
13
+ value: value,
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true
17
+ });
18
+ } else {
19
+ obj[key] = value;
20
+ }
21
+ return obj;
22
+ }
10
23
  // MDN lists string|Blob|Promise<Blob|string> as possible types in ClipboardItemData
11
24
  // lib.dom.d.ts lists only Promise<Blob|string>
12
25
  // https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/ClipboardItem#syntax
13
26
  function createClipboardItem(window, ...blobs) {
14
27
  const dataMap = Object.fromEntries(blobs.map((b)=>[
15
28
  typeof b === 'string' ? 'text/plain' : b.type,
16
- Promise.resolve(b),
29
+ Promise.resolve(b)
17
30
  ]));
18
31
  // use real ClipboardItem if available
19
32
  /* istanbul ignore if */ if (typeof window.ClipboardItem !== 'undefined') {
@@ -35,6 +48,7 @@ function createClipboardItem(window, ...blobs) {
35
48
  });
36
49
  }
37
50
  constructor(d){
51
+ _define_property(this, "data", void 0);
38
52
  this.data = d;
39
53
  }
40
54
  }(dataMap);
@@ -65,15 +79,14 @@ function createClipboardStub(window, control) {
65
79
  }
66
80
  constructor(...args){
67
81
  super(...args);
68
- this.items = [];
82
+ _define_property(this, "items", []);
69
83
  }
70
84
  }(), {
71
85
  [ClipboardStubControl]: control
72
86
  });
73
87
  }
74
88
  function isClipboardStub(clipboard) {
75
- var ref;
76
- return !!((ref = clipboard) === null || ref === void 0 ? void 0 : ref[ClipboardStubControl]);
89
+ return !!(clipboard === null || clipboard === void 0 ? void 0 : clipboard[ClipboardStubControl]);
77
90
  }
78
91
  function attachClipboardStubToView(window) {
79
92
  if (isClipboardStub(window.navigator.clipboard)) {
@@ -143,11 +156,12 @@ async function writeDataTransferToClipboard(document, clipboardData) {
143
156
  throw new Error('The Clipboard API is unavailable.');
144
157
  }
145
158
  }
146
- /* istanbul ignore else */ if (typeof globalThis.afterEach === 'function') {
147
- globalThis.afterEach(()=>resetClipboardStubOnView(globalThis.window));
159
+ const g = globalThis;
160
+ /* istanbul ignore else */ if (typeof g.afterEach === 'function') {
161
+ g.afterEach(()=>resetClipboardStubOnView(globalThis.window));
148
162
  }
149
- /* istanbul ignore else */ if (typeof globalThis.afterAll === 'function') {
150
- globalThis.afterAll(()=>detachClipboardStubFromView(globalThis.window));
163
+ /* istanbul ignore else */ if (typeof g.afterAll === 'function') {
164
+ g.afterAll(()=>detachClipboardStubFromView(globalThis.window));
151
165
  }
152
166
 
153
167
  exports.attachClipboardStubToView = attachClipboardStubToView;
@@ -4,6 +4,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var FileList = require('./FileList.js');
6
6
 
7
+ function _define_property(obj, key, value) {
8
+ if (key in obj) {
9
+ Object.defineProperty(obj, key, {
10
+ value: value,
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true
14
+ });
15
+ } else {
16
+ obj[key] = value;
17
+ }
18
+ return obj;
19
+ }
7
20
  // DataTransfer is not implemented in jsdom.
8
21
  // DataTransfer with FileList is being created by the browser on certain events.
9
22
  class DataTransferItemStub {
@@ -19,8 +32,10 @@ class DataTransferItemStub {
19
32
  throw new Error('not implemented');
20
33
  }
21
34
  constructor(dataOrFile, type){
22
- this.file = null;
23
- this.data = undefined;
35
+ _define_property(this, "kind", void 0);
36
+ _define_property(this, "type", void 0);
37
+ _define_property(this, "file", null);
38
+ _define_property(this, "data", undefined);
24
39
  if (typeof dataOrFile === 'string') {
25
40
  this.kind = 'string';
26
41
  this.type = String(type);
@@ -55,8 +70,8 @@ function getTypeMatcher(type, exact) {
55
70
  function createDataTransferStub(window) {
56
71
  return new class DataTransferStub {
57
72
  getData(format) {
58
- var ref;
59
- const match = (ref = this.items.find(getTypeMatcher(format, true))) !== null && ref !== void 0 ? ref : this.items.find(getTypeMatcher(format, false));
73
+ var _this_items_find;
74
+ 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));
60
75
  let text = '';
61
76
  match === null || match === void 0 ? void 0 : match.getAsString((t)=>{
62
77
  text = t;
@@ -93,10 +108,10 @@ function createDataTransferStub(window) {
93
108
  }
94
109
  /* istanbul ignore next */ setDragImage() {}
95
110
  constructor(){
96
- this.dropEffect = 'none';
97
- this.effectAllowed = 'uninitialized';
98
- this.items = new DataTransferItemListStub();
99
- this.files = FileList.createFileList(window, []);
111
+ _define_property(this, "dropEffect", 'none');
112
+ _define_property(this, "effectAllowed", 'uninitialized');
113
+ _define_property(this, "items", new DataTransferItemListStub());
114
+ _define_property(this, "files", FileList.createFileList(window, []));
100
115
  }
101
116
  }();
102
117
  }
@@ -16,8 +16,8 @@ var maxLengthSupportedTypes;
16
16
  // can't use .maxLength property because of a jsdom bug:
17
17
  // https://github.com/jsdom/jsdom/issues/2927
18
18
  function getMaxLength(element) {
19
- var ref;
20
- const attr = (ref = element.getAttribute('maxlength')) !== null && ref !== void 0 ? ref : '';
19
+ var _element_getAttribute;
20
+ const attr = (_element_getAttribute = element.getAttribute('maxlength')) !== null && _element_getAttribute !== void 0 ? _element_getAttribute : '';
21
21
  return /^\d+$/.test(attr) && Number(attr) >= 0 ? Number(attr) : undefined;
22
22
  }
23
23
  function supportsMaxLength(element) {
@@ -15,8 +15,8 @@ function restoreProperty(obj, prop, descriptor) {
15
15
  }
16
16
  }
17
17
  function setFiles(el, files) {
18
- var ref;
19
- (ref = el[fakeFiles]) === null || ref === void 0 ? void 0 : ref.restore();
18
+ var _el_fakeFiles;
19
+ (_el_fakeFiles = el[fakeFiles]) === null || _el_fakeFiles === void 0 ? void 0 : _el_fakeFiles.restore();
20
20
  const typeDescr = Object.getOwnPropertyDescriptor(el, 'type');
21
21
  const valueDescr = Object.getOwnPropertyDescriptor(el, 'value');
22
22
  const filesDescr = Object.getOwnPropertyDescriptor(el, 'files');
@@ -40,8 +40,8 @@ function setFiles(el, files) {
40
40
  if (v === '') {
41
41
  restore();
42
42
  } else {
43
- var ref;
44
- valueDescr === null || valueDescr === void 0 ? void 0 : (ref = valueDescr.set) === null || ref === void 0 ? void 0 : ref.call(el, v);
43
+ var _valueDescr_set;
44
+ valueDescr === null || valueDescr === void 0 ? void 0 : (_valueDescr_set = valueDescr.set) === null || _valueDescr_set === void 0 ? void 0 : _valueDescr_set.call(el, v);
45
45
  }
46
46
  }
47
47
  },
@@ -104,14 +104,14 @@ function isTextNode(node) {
104
104
  }
105
105
  function walkNodes(node, direction, callback) {
106
106
  for(;;){
107
- var ref;
107
+ var _node_ownerDocument;
108
108
  const sibling = node[`${direction}Sibling`];
109
109
  if (sibling) {
110
110
  node = getDescendant(sibling, direction === 'next' ? 'first' : 'last');
111
111
  if (callback(node)) {
112
112
  return node;
113
113
  }
114
- } else if (node.parentNode && (!isElement(node.parentNode) || !isContentEditable.isContentEditable(node.parentNode) && node.parentNode !== ((ref = node.ownerDocument) === null || ref === void 0 ? void 0 : ref.body))) {
114
+ } else if (node.parentNode && (!isElement(node.parentNode) || !isContentEditable.isContentEditable(node.parentNode) && node.parentNode !== ((_node_ownerDocument = node.ownerDocument) === null || _node_ownerDocument === void 0 ? void 0 : _node_ownerDocument.body))) {
115
115
  node = node.parentNode;
116
116
  } else {
117
117
  break;
@@ -17,8 +17,8 @@ function getActiveElement(document) {
17
17
  }
18
18
  }
19
19
  function getActiveElementOrBody(document) {
20
- var ref;
21
- return (ref = getActiveElement(document)) !== null && ref !== void 0 ? ref : /* istanbul ignore next */ document.body;
20
+ var _getActiveElement;
21
+ return (_getActiveElement = getActiveElement(document)) !== null && _getActiveElement !== void 0 ? _getActiveElement : /* istanbul ignore next */ document.body;
22
22
  }
23
23
 
24
24
  exports.getActiveElement = getActiveElement;
@@ -10,7 +10,7 @@ const FOCUSABLE_SELECTOR = [
10
10
  '[contenteditable=""]',
11
11
  '[contenteditable="true"]',
12
12
  'a[href]',
13
- '[tabindex]:not([disabled])',
13
+ '[tabindex]:not([disabled])'
14
14
  ].join(', ');
15
15
 
16
16
  exports.FOCUSABLE_SELECTOR = FOCUSABLE_SELECTOR;
@@ -41,16 +41,16 @@ function readPrintableChar(text, pos, context) {
41
41
  };
42
42
  }
43
43
  function readTag(text, pos, startBracket, context) {
44
- var ref, ref1;
44
+ var _text_slice_match, _text_slice_match1;
45
45
  const releasePreviousModifier = text[pos] === '/' ? '/' : '';
46
46
  pos += releasePreviousModifier.length;
47
47
  const escapedDescriptor = startBracket === '{' && text[pos] === '\\';
48
48
  pos += Number(escapedDescriptor);
49
- const descriptor = escapedDescriptor ? text[pos] : (ref = text.slice(pos).match(startBracket === '{' ? /^\w+|^[^}>/]/ : /^\w+/)) === null || ref === void 0 ? void 0 : ref[0];
49
+ const descriptor = escapedDescriptor ? text[pos] : (_text_slice_match = text.slice(pos).match(startBracket === '{' ? /^\w+|^[^}>/]/ : /^\w+/)) === null || _text_slice_match === void 0 ? void 0 : _text_slice_match[0];
50
50
  assertDescriptor(descriptor, text, pos, context);
51
51
  pos += descriptor.length;
52
- var ref2;
53
- const repeatModifier = (ref2 = (ref1 = text.slice(pos).match(/^>\d+/)) === null || ref1 === void 0 ? void 0 : ref1[0]) !== null && ref2 !== void 0 ? ref2 : '';
52
+ var _text_slice_match_;
53
+ const repeatModifier = (_text_slice_match_ = (_text_slice_match1 = text.slice(pos).match(/^>\d+/)) === null || _text_slice_match1 === void 0 ? void 0 : _text_slice_match1[0]) !== null && _text_slice_match_ !== void 0 ? _text_slice_match_ : '';
54
54
  pos += repeatModifier.length;
55
55
  const releaseSelfModifier = text[pos] === '/' || !repeatModifier && text[pos] === '>' ? text[pos] : '';
56
56
  pos += releaseSelfModifier.length;
@@ -60,7 +60,7 @@ function readTag(text, pos, startBracket, context) {
60
60
  throw new Error(getErrorMessage([
61
61
  !repeatModifier && 'repeat modifier',
62
62
  !releaseSelfModifier && 'release modifier',
63
- `"${expectedEndBracket}"`,
63
+ `"${expectedEndBracket}"`
64
64
  ].filter(Boolean).join(' or '), text[pos], text, context));
65
65
  }
66
66
  pos += endBracket.length;