@testing-library/user-event 14.6.1 → 14.6.4

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 (116) hide show
  1. package/README.md +19 -16
  2. package/dist/cjs/clipboard/copy.js +2 -2
  3. package/dist/cjs/clipboard/cut.js +2 -2
  4. package/dist/cjs/clipboard/paste.js +3 -4
  5. package/dist/cjs/document/UI.js +5 -7
  6. package/dist/cjs/document/interceptor.js +4 -4
  7. package/dist/cjs/document/patchFocus.js +5 -3
  8. package/dist/cjs/document/trackValue.js +2 -2
  9. package/dist/cjs/event/behavior/keydown.js +4 -4
  10. package/dist/cjs/event/behavior/keypress.js +1 -1
  11. package/dist/cjs/event/behavior/keyup.js +1 -1
  12. package/dist/cjs/event/behavior/paste.js +1 -1
  13. package/dist/cjs/event/createEvent.js +25 -39
  14. package/dist/cjs/event/dispatchEvent.js +1 -1
  15. package/dist/cjs/event/focus.js +3 -3
  16. package/dist/cjs/event/input.js +3 -2
  17. package/dist/cjs/event/selection/getInputRange.js +1 -1
  18. package/dist/cjs/event/selection/getTargetTypeAndSelection.js +2 -2
  19. package/dist/cjs/event/selection/modifySelection.js +1 -1
  20. package/dist/cjs/event/selection/modifySelectionPerMouse.js +2 -2
  21. package/dist/cjs/event/selection/moveSelection.js +1 -1
  22. package/dist/cjs/event/selection/resolveCaretPosition.js +4 -5
  23. package/dist/cjs/event/selection/selectAll.js +5 -5
  24. package/dist/cjs/event/selection/setSelection.js +1 -1
  25. package/dist/cjs/event/selection/setSelectionPerMouse.js +9 -11
  26. package/dist/cjs/event/selection/setSelectionRange.js +1 -1
  27. package/dist/cjs/event/selection/updateSelectionOnFocus.js +2 -2
  28. package/dist/cjs/event/wrapEvent.js +2 -1
  29. package/dist/cjs/keyboard/index.js +1 -1
  30. package/dist/cjs/keyboard/parseKeyDef.js +4 -4
  31. package/dist/cjs/pointer/index.js +9 -9
  32. package/dist/cjs/setup/api.js +4 -4
  33. package/dist/cjs/setup/setup.js +10 -10
  34. package/dist/cjs/system/index.js +1 -3
  35. package/dist/cjs/system/keyboard.js +8 -11
  36. package/dist/cjs/system/pointer/buttons.js +1 -5
  37. package/dist/cjs/system/pointer/device.js +1 -3
  38. package/dist/cjs/system/pointer/index.js +19 -22
  39. package/dist/cjs/system/pointer/mouse.js +10 -13
  40. package/dist/cjs/system/pointer/pointer.js +6 -8
  41. package/dist/cjs/system/pointer/shared.js +1 -1
  42. package/dist/cjs/utility/type.js +1 -1
  43. package/dist/cjs/utility/upload.js +3 -3
  44. package/dist/cjs/utils/dataTransfer/Clipboard.js +14 -9
  45. package/dist/cjs/utils/dataTransfer/DataTransfer.js +5 -7
  46. package/dist/cjs/utils/edit/isContentEditable.js +1 -1
  47. package/dist/cjs/utils/edit/maxLength.js +1 -1
  48. package/dist/cjs/utils/edit/setFiles.js +2 -3
  49. package/dist/cjs/utils/focus/cursor.js +1 -1
  50. package/dist/cjs/utils/focus/getActiveElement.js +10 -8
  51. package/dist/cjs/utils/focus/selector.js +2 -1
  52. package/dist/cjs/utils/keyDef/readNextDescriptor.js +8 -9
  53. package/dist/cjs/utils/misc/getWindow.js +1 -1
  54. package/dist/cjs/utils/misc/isDisabled.js +1 -1
  55. package/dist/cjs/utils/misc/isVisible.js +1 -1
  56. package/dist/cjs/utils/pointer/cssPointerEvents.js +11 -12
  57. package/dist/esm/clipboard/copy.js +2 -2
  58. package/dist/esm/clipboard/cut.js +2 -2
  59. package/dist/esm/clipboard/paste.js +3 -4
  60. package/dist/esm/document/UI.js +5 -7
  61. package/dist/esm/document/interceptor.js +5 -5
  62. package/dist/esm/document/patchFocus.js +5 -3
  63. package/dist/esm/document/trackValue.js +3 -3
  64. package/dist/esm/event/behavior/keydown.js +5 -5
  65. package/dist/esm/event/behavior/keypress.js +1 -1
  66. package/dist/esm/event/behavior/keyup.js +1 -1
  67. package/dist/esm/event/behavior/paste.js +1 -1
  68. package/dist/esm/event/createEvent.js +25 -39
  69. package/dist/esm/event/dispatchEvent.js +1 -1
  70. package/dist/esm/event/focus.js +3 -3
  71. package/dist/esm/event/input.js +3 -2
  72. package/dist/esm/event/selection/getInputRange.js +1 -1
  73. package/dist/esm/event/selection/getTargetTypeAndSelection.js +2 -2
  74. package/dist/esm/event/selection/modifySelection.js +1 -1
  75. package/dist/esm/event/selection/modifySelectionPerMouse.js +2 -2
  76. package/dist/esm/event/selection/moveSelection.js +1 -1
  77. package/dist/esm/event/selection/resolveCaretPosition.js +4 -5
  78. package/dist/esm/event/selection/selectAll.js +6 -6
  79. package/dist/esm/event/selection/setSelection.js +1 -1
  80. package/dist/esm/event/selection/setSelectionPerMouse.js +9 -11
  81. package/dist/esm/event/selection/setSelectionRange.js +1 -1
  82. package/dist/esm/event/selection/updateSelectionOnFocus.js +2 -2
  83. package/dist/esm/event/wrapEvent.js +2 -1
  84. package/dist/esm/keyboard/index.js +1 -1
  85. package/dist/esm/keyboard/parseKeyDef.js +4 -4
  86. package/dist/esm/pointer/index.js +9 -9
  87. package/dist/esm/setup/api.js +3 -3
  88. package/dist/esm/setup/setup.js +11 -11
  89. package/dist/esm/system/index.js +1 -3
  90. package/dist/esm/system/keyboard.js +8 -11
  91. package/dist/esm/system/pointer/buttons.js +1 -5
  92. package/dist/esm/system/pointer/device.js +1 -3
  93. package/dist/esm/system/pointer/index.js +19 -22
  94. package/dist/esm/system/pointer/mouse.js +10 -13
  95. package/dist/esm/system/pointer/pointer.js +6 -8
  96. package/dist/esm/system/pointer/shared.js +1 -1
  97. package/dist/esm/utility/type.js +1 -1
  98. package/dist/esm/utility/upload.js +3 -3
  99. package/dist/esm/utils/dataTransfer/Clipboard.js +14 -9
  100. package/dist/esm/utils/dataTransfer/DataTransfer.js +5 -7
  101. package/dist/esm/utils/edit/isContentEditable.js +1 -1
  102. package/dist/esm/utils/edit/maxLength.js +1 -1
  103. package/dist/esm/utils/edit/setFiles.js +2 -3
  104. package/dist/esm/utils/focus/cursor.js +1 -1
  105. package/dist/esm/utils/focus/getActiveElement.js +10 -8
  106. package/dist/esm/utils/focus/selector.js +2 -1
  107. package/dist/esm/utils/keyDef/readNextDescriptor.js +8 -9
  108. package/dist/esm/utils/misc/getWindow.js +1 -1
  109. package/dist/esm/utils/misc/isDisabled.js +1 -1
  110. package/dist/esm/utils/misc/isVisible.js +1 -1
  111. package/dist/esm/utils/pointer/cssPointerEvents.js +11 -12
  112. package/dist/types/document/UI.d.ts +3 -3
  113. package/dist/types/event/behavior/registry.d.ts +1 -2
  114. package/dist/types/options.d.ts +1 -1
  115. package/dist/types/system/keyboard.d.ts +1 -1
  116. package/package.json +6 -3
@@ -9,9 +9,7 @@ function _define_property(obj, key, value) {
9
9
  configurable: true,
10
10
  writable: true
11
11
  });
12
- } else {
13
- obj[key] = value;
14
- }
12
+ } else obj[key] = value;
15
13
  return obj;
16
14
  }
17
15
  var DOM_KEY_LOCATION = /*#__PURE__*/ function(DOM_KEY_LOCATION) {
@@ -50,7 +48,7 @@ class KeyboardHost {
50
48
  getPressedKeys() {
51
49
  return this.pressed.values().map((p)=>p.keyDef);
52
50
  }
53
- /** Press a key */ async keydown(instance, keyDef) {
51
+ /** Press a key */ async keydown(instance, keyDef, repeat = false) {
54
52
  const key = String(keyDef.key);
55
53
  const code = String(keyDef.code);
56
54
  const target = getActiveElementOrBody(instance.config.document);
@@ -61,7 +59,8 @@ class KeyboardHost {
61
59
  }
62
60
  const unprevented = instance.dispatchUIEvent(target, 'keydown', {
63
61
  key,
64
- code
62
+ code,
63
+ repeat
65
64
  });
66
65
  if (isModifierLock(key) && !this.modifiers[key]) {
67
66
  this.modifiers[key] = true;
@@ -108,7 +107,7 @@ class KeyboardHost {
108
107
  return (key.length === 1 || key === 'Enter') && !this.modifiers.Control && !this.modifiers.Alt;
109
108
  }
110
109
  constructor(system){
111
- _define_property(this, "system", undefined);
110
+ _define_property(this, "system", void 0);
112
111
  _define_property(this, "modifiers", {
113
112
  Alt: false,
114
113
  AltGraph: false,
@@ -125,9 +124,8 @@ class KeyboardHost {
125
124
  });
126
125
  _define_property(this, "pressed", new class {
127
126
  add(code, keyDef) {
128
- var _this_registry, _code;
129
- var _;
130
- (_ = (_this_registry = this.registry)[_code = code]) !== null && _ !== undefined ? _ : _this_registry[_code] = {
127
+ var _this_registry, _code, _;
128
+ (_ = (_this_registry = this.registry)[_code = code]) !== null && _ !== void 0 ? _ : _this_registry[_code] = {
131
129
  keyDef,
132
130
  unpreventedDefault: false
133
131
  };
@@ -143,10 +141,9 @@ class KeyboardHost {
143
141
  }
144
142
  isUnprevented(code) {
145
143
  var _this_registry_code;
146
- return !!((_this_registry_code = this.registry[code]) === null || _this_registry_code === undefined ? undefined : _this_registry_code.unpreventedDefault);
144
+ return !!((_this_registry_code = this.registry[code]) === null || _this_registry_code === void 0 ? void 0 : _this_registry_code.unpreventedDefault);
147
145
  }
148
146
  delete(code) {
149
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
150
147
  delete this.registry[code];
151
148
  }
152
149
  values() {
@@ -6,16 +6,13 @@ function _define_property(obj, key, value) {
6
6
  configurable: true,
7
7
  writable: true
8
8
  });
9
- } else {
10
- obj[key] = value;
11
- }
9
+ } else obj[key] = value;
12
10
  return obj;
13
11
  }
14
12
  class Buttons {
15
13
  getButtons() {
16
14
  let v = 0;
17
15
  for (const button of Object.keys(this.pressed)){
18
- // eslint-disable-next-line no-bitwise
19
16
  v |= 2 ** Number(button);
20
17
  }
21
18
  return v;
@@ -36,7 +33,6 @@ class Buttons {
36
33
  if (button in this.pressed) {
37
34
  this.pressed[button] = this.pressed[button].filter((k)=>k.name !== keyDef.name);
38
35
  if (this.pressed[button].length === 0) {
39
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
40
36
  delete this.pressed[button];
41
37
  return button;
42
38
  }
@@ -6,9 +6,7 @@ function _define_property(obj, key, value) {
6
6
  configurable: true,
7
7
  writable: true
8
8
  });
9
- } else {
10
- obj[key] = value;
11
- }
9
+ } else obj[key] = value;
12
10
  return obj;
13
11
  }
14
12
  class Device {
@@ -11,9 +11,7 @@ function _define_property(obj, key, value) {
11
11
  configurable: true,
12
12
  writable: true
13
13
  });
14
- } else {
15
- obj[key] = value;
16
- }
14
+ } else obj[key] = value;
17
15
  return obj;
18
16
  }
19
17
  class PointerHost {
@@ -46,12 +44,12 @@ class PointerHost {
46
44
  // the order in which they interweave/follow on a user interaction depends on the implementation.
47
45
  const pointermove = pointer.move(instance, position);
48
46
  const mousemove = pointer.pointerType === 'touch' ? undefined : this.mouse.move(instance, position, pointer.isPrevented);
49
- pointermove === null || pointermove === undefined ? undefined : pointermove.leave();
50
- mousemove === null || mousemove === undefined ? undefined : mousemove.leave();
51
- pointermove === null || pointermove === undefined ? undefined : pointermove.enter();
52
- mousemove === null || mousemove === undefined ? undefined : mousemove.enter();
53
- pointermove === null || pointermove === undefined ? undefined : pointermove.move();
54
- mousemove === null || mousemove === undefined ? undefined : mousemove.move();
47
+ pointermove === null || pointermove === void 0 ? void 0 : pointermove.leave();
48
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
49
+ pointermove === null || pointermove === void 0 ? void 0 : pointermove.enter();
50
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
51
+ pointermove === null || pointermove === void 0 ? void 0 : pointermove.move();
52
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
55
53
  }
56
54
  async release(instance, keyDef, position) {
57
55
  const device = this.devices.get(keyDef.pointerType);
@@ -72,16 +70,16 @@ class PointerHost {
72
70
  }
73
71
  if (pointer.pointerType === 'touch' && !pointer.isMultitouch) {
74
72
  const mousemove = this.mouse.move(instance, position, isPrevented);
75
- mousemove === null || mousemove === undefined ? undefined : mousemove.leave();
76
- mousemove === null || mousemove === undefined ? undefined : mousemove.enter();
77
- mousemove === null || mousemove === undefined ? undefined : mousemove.move();
73
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
74
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
75
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
78
76
  this.mouse.down(instance, keyDef, isPrevented);
79
77
  }
80
78
  if (!pointer.isMultitouch) {
81
79
  const mousemove = this.mouse.move(instance, position, isPrevented);
82
- mousemove === null || mousemove === undefined ? undefined : mousemove.leave();
83
- mousemove === null || mousemove === undefined ? undefined : mousemove.enter();
84
- mousemove === null || mousemove === undefined ? undefined : mousemove.move();
80
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
81
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
82
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
85
83
  this.mouse.up(instance, keyDef, isPrevented);
86
84
  }
87
85
  }
@@ -96,21 +94,20 @@ class PointerHost {
96
94
  }
97
95
  getMouseTarget(instance) {
98
96
  var _this_mouse_position_target;
99
- return (_this_mouse_position_target = this.mouse.position.target) !== null && _this_mouse_position_target !== undefined ? _this_mouse_position_target : instance.config.document.body;
97
+ return (_this_mouse_position_target = this.mouse.position.target) !== null && _this_mouse_position_target !== void 0 ? _this_mouse_position_target : instance.config.document.body;
100
98
  }
101
99
  setMousePosition(position) {
102
100
  this.mouse.position = position;
103
101
  this.pointers.get('mouse').position = position;
104
102
  }
105
103
  constructor(system){
106
- _define_property(this, "system", undefined);
107
- _define_property(this, "mouse", undefined);
108
- _define_property(this, "buttons", undefined);
104
+ _define_property(this, "system", void 0);
105
+ _define_property(this, "mouse", void 0);
106
+ _define_property(this, "buttons", void 0);
109
107
  _define_property(this, "devices", new class {
110
108
  get(k) {
111
- var _this_registry, _k;
112
- var _;
113
- return (_ = (_this_registry = this.registry)[_k = k]) !== null && _ !== undefined ? _ : _this_registry[_k] = new Device();
109
+ var _this_registry, _k, _;
110
+ return (_ = (_this_registry = this.registry)[_k = k]) !== null && _ !== void 0 ? _ : _this_registry[_k] = new Device();
114
111
  }
115
112
  constructor(){
116
113
  _define_property(this, "registry", {});
@@ -22,9 +22,7 @@ function _define_property(obj, key, value) {
22
22
  configurable: true,
23
23
  writable: true
24
24
  });
25
- } else {
26
- obj[key] = value;
27
- }
25
+ } else obj[key] = value;
28
26
  return obj;
29
27
  }
30
28
  /**
@@ -126,7 +124,7 @@ function _define_property(obj, key, value) {
126
124
  }
127
125
  getTarget(instance) {
128
126
  var _this_position_target;
129
- return (_this_position_target = this.position.target) !== null && _this_position_target !== undefined ? _this_position_target : instance.config.document.body;
127
+ return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
130
128
  }
131
129
  startSelecting(instance, clickCount) {
132
130
  var _this_position_caret, _this_position_caret1;
@@ -134,8 +132,8 @@ function _define_property(obj, key, value) {
134
132
  this.selecting = setSelectionPerMouseDown({
135
133
  document: instance.config.document,
136
134
  target: this.getTarget(instance),
137
- node: (_this_position_caret = this.position.caret) === null || _this_position_caret === undefined ? undefined : _this_position_caret.node,
138
- offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === undefined ? undefined : _this_position_caret1.offset,
135
+ node: (_this_position_caret = this.position.caret) === null || _this_position_caret === void 0 ? void 0 : _this_position_caret.node,
136
+ offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === void 0 ? void 0 : _this_position_caret1.offset,
139
137
  clickCount
140
138
  });
141
139
  }
@@ -147,8 +145,8 @@ function _define_property(obj, key, value) {
147
145
  modifySelectionPerMouseMove(this.selecting, {
148
146
  document: instance.config.document,
149
147
  target: this.getTarget(instance),
150
- node: (_this_position_caret = this.position.caret) === null || _this_position_caret === undefined ? undefined : _this_position_caret.node,
151
- offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === undefined ? undefined : _this_position_caret1.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
152
150
  });
153
151
  }
154
152
  endSelecting() {
@@ -157,7 +155,7 @@ function _define_property(obj, key, value) {
157
155
  constructor(){
158
156
  _define_property(this, "position", {});
159
157
  _define_property(this, "buttons", new Buttons());
160
- _define_property(this, "selecting", undefined);
158
+ _define_property(this, "selecting", void 0);
161
159
  _define_property(this, "buttonDownTarget", {});
162
160
  // According to spec the `detail` on click events should be the number
163
161
  // of *consecutive* clicks with a specific button.
@@ -178,13 +176,12 @@ function _define_property(obj, key, value) {
178
176
  return current;
179
177
  }
180
178
  getOnDown(button) {
181
- var _this_count_button;
179
+ var _this_count_button, _this_count_button1;
182
180
  this.down = {
183
- [button]: (_this_count_button = this.count[button]) !== null && _this_count_button !== undefined ? _this_count_button : 0
181
+ [button]: (_this_count_button = this.count[button]) !== null && _this_count_button !== void 0 ? _this_count_button : 0
184
182
  };
185
- var _this_count_button1;
186
183
  this.count = {
187
- [button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !== undefined ? _this_count_button1 : 0
184
+ [button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !== void 0 ? _this_count_button1 : 0
188
185
  };
189
186
  return Number(this.count[button]) + 1;
190
187
  }
@@ -12,9 +12,7 @@ function _define_property(obj, key, value) {
12
12
  configurable: true,
13
13
  writable: true
14
14
  });
15
- } else {
16
- obj[key] = value;
17
- }
15
+ } else obj[key] = value;
18
16
  return obj;
19
17
  }
20
18
  class Pointer {
@@ -91,7 +89,7 @@ class Pointer {
91
89
  }
92
90
  getTarget(instance) {
93
91
  var _this_position_target;
94
- return (_this_position_target = this.position.target) !== null && _this_position_target !== undefined ? _this_position_target : instance.config.document.body;
92
+ return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
95
93
  }
96
94
  getEventInit(/**
97
95
  * The `button` that caused the event.
@@ -109,10 +107,10 @@ class Pointer {
109
107
  };
110
108
  }
111
109
  constructor({ pointerId, pointerType, isPrimary }, buttons){
112
- _define_property(this, "pointerId", undefined);
113
- _define_property(this, "pointerType", undefined);
114
- _define_property(this, "isPrimary", undefined);
115
- _define_property(this, "buttons", undefined);
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, "buttons", void 0);
116
114
  _define_property(this, "isMultitouch", false);
117
115
  _define_property(this, "isCancelled", false);
118
116
  _define_property(this, "isDown", false);
@@ -1,6 +1,6 @@
1
1
  function isDifferentPointerPosition(positionA, positionB) {
2
2
  var _positionA_coords, _positionB_coords, _positionA_coords1, _positionB_coords1, _positionA_coords2, _positionB_coords2, _positionA_coords3, _positionB_coords3, _positionA_coords4, _positionB_coords4, _positionA_coords5, _positionB_coords5, _positionA_coords6, _positionB_coords6, _positionA_coords7, _positionB_coords7, _positionA_coords8, _positionB_coords8, _positionA_coords9, _positionB_coords9, _positionA_caret, _positionB_caret, _positionA_caret1, _positionB_caret1;
3
- return positionA.target !== positionB.target || ((_positionA_coords = positionA.coords) === null || _positionA_coords === undefined ? undefined : _positionA_coords.x) !== ((_positionB_coords = positionB.coords) === null || _positionB_coords === undefined ? undefined : _positionB_coords.x) || ((_positionA_coords1 = positionA.coords) === null || _positionA_coords1 === undefined ? undefined : _positionA_coords1.y) !== ((_positionB_coords1 = positionB.coords) === null || _positionB_coords1 === undefined ? undefined : _positionB_coords1.y) || ((_positionA_coords2 = positionA.coords) === null || _positionA_coords2 === undefined ? undefined : _positionA_coords2.clientX) !== ((_positionB_coords2 = positionB.coords) === null || _positionB_coords2 === undefined ? undefined : _positionB_coords2.clientX) || ((_positionA_coords3 = positionA.coords) === null || _positionA_coords3 === undefined ? undefined : _positionA_coords3.clientY) !== ((_positionB_coords3 = positionB.coords) === null || _positionB_coords3 === undefined ? undefined : _positionB_coords3.clientY) || ((_positionA_coords4 = positionA.coords) === null || _positionA_coords4 === undefined ? undefined : _positionA_coords4.offsetX) !== ((_positionB_coords4 = positionB.coords) === null || _positionB_coords4 === undefined ? undefined : _positionB_coords4.offsetX) || ((_positionA_coords5 = positionA.coords) === null || _positionA_coords5 === undefined ? undefined : _positionA_coords5.offsetY) !== ((_positionB_coords5 = positionB.coords) === null || _positionB_coords5 === undefined ? undefined : _positionB_coords5.offsetY) || ((_positionA_coords6 = positionA.coords) === null || _positionA_coords6 === undefined ? undefined : _positionA_coords6.pageX) !== ((_positionB_coords6 = positionB.coords) === null || _positionB_coords6 === undefined ? undefined : _positionB_coords6.pageX) || ((_positionA_coords7 = positionA.coords) === null || _positionA_coords7 === undefined ? undefined : _positionA_coords7.pageY) !== ((_positionB_coords7 = positionB.coords) === null || _positionB_coords7 === undefined ? undefined : _positionB_coords7.pageY) || ((_positionA_coords8 = positionA.coords) === null || _positionA_coords8 === undefined ? undefined : _positionA_coords8.screenX) !== ((_positionB_coords8 = positionB.coords) === null || _positionB_coords8 === undefined ? undefined : _positionB_coords8.screenX) || ((_positionA_coords9 = positionA.coords) === null || _positionA_coords9 === undefined ? undefined : _positionA_coords9.screenY) !== ((_positionB_coords9 = positionB.coords) === null || _positionB_coords9 === undefined ? undefined : _positionB_coords9.screenY) || ((_positionA_caret = positionA.caret) === null || _positionA_caret === undefined ? undefined : _positionA_caret.node) !== ((_positionB_caret = positionB.caret) === null || _positionB_caret === undefined ? undefined : _positionB_caret.node) || ((_positionA_caret1 = positionA.caret) === null || _positionA_caret1 === undefined ? undefined : _positionA_caret1.offset) !== ((_positionB_caret1 = positionB.caret) === null || _positionB_caret1 === undefined ? undefined : _positionB_caret1.offset);
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.x) || ((_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_coords2 = positionA.coords) === null || _positionA_coords2 === void 0 ? void 0 : _positionA_coords2.clientX) !== ((_positionB_coords2 = positionB.coords) === null || _positionB_coords2 === void 0 ? void 0 : _positionB_coords2.clientX) || ((_positionA_coords3 = positionA.coords) === null || _positionA_coords3 === void 0 ? void 0 : _positionA_coords3.clientY) !== ((_positionB_coords3 = positionB.coords) === null || _positionB_coords3 === void 0 ? void 0 : _positionB_coords3.clientY) || ((_positionA_coords4 = positionA.coords) === null || _positionA_coords4 === void 0 ? void 0 : _positionA_coords4.offsetX) !== ((_positionB_coords4 = positionB.coords) === null || _positionB_coords4 === void 0 ? void 0 : _positionB_coords4.offsetX) || ((_positionA_coords5 = positionA.coords) === null || _positionA_coords5 === void 0 ? void 0 : _positionA_coords5.offsetY) !== ((_positionB_coords5 = positionB.coords) === null || _positionB_coords5 === void 0 ? void 0 : _positionB_coords5.offsetY) || ((_positionA_coords6 = positionA.coords) === null || _positionA_coords6 === void 0 ? void 0 : _positionA_coords6.pageX) !== ((_positionB_coords6 = positionB.coords) === null || _positionB_coords6 === void 0 ? void 0 : _positionB_coords6.pageX) || ((_positionA_coords7 = positionA.coords) === null || _positionA_coords7 === void 0 ? void 0 : _positionA_coords7.pageY) !== ((_positionB_coords7 = positionB.coords) === null || _positionB_coords7 === void 0 ? void 0 : _positionB_coords7.pageY) || ((_positionA_coords8 = positionA.coords) === null || _positionA_coords8 === void 0 ? void 0 : _positionA_coords8.screenX) !== ((_positionB_coords8 = positionB.coords) === null || _positionB_coords8 === void 0 ? void 0 : _positionB_coords8.screenX) || ((_positionA_coords9 = positionA.coords) === null || _positionA_coords9 === void 0 ? void 0 : _positionA_coords9.screenY) !== ((_positionB_coords9 = positionB.coords) === null || _positionB_coords9 === void 0 ? void 0 : _positionB_coords9.screenY) || ((_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
4
  }
5
5
 
6
6
  export { isDifferentPointerPosition };
@@ -10,7 +10,7 @@ async function type(element, text, { skipClick = this.config.skipClick, skipAuto
10
10
  await this.click(element);
11
11
  }
12
12
  if (initialSelectionStart !== undefined) {
13
- setSelectionRange(element, initialSelectionStart, initialSelectionEnd !== null && initialSelectionEnd !== undefined ? initialSelectionEnd : initialSelectionStart);
13
+ setSelectionRange(element, initialSelectionStart, initialSelectionEnd !== null && initialSelectionEnd !== void 0 ? initialSelectionEnd : initialSelectionStart);
14
14
  }
15
15
  await this.keyboard(text);
16
16
  if (!skipAutoClose) {
@@ -10,7 +10,7 @@ async function upload(element, fileOrFiles) {
10
10
  if (!input || !isElementType(input, 'input', {
11
11
  type: 'file'
12
12
  })) {
13
- throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === undefined ? undefined : input.tagName} element does not accept file uploads`);
13
+ throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === void 0 ? void 0 : input.tagName} element does not accept file uploads`);
14
14
  }
15
15
  if (isDisabled(element)) return;
16
16
  const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [
@@ -19,9 +19,9 @@ async function upload(element, fileOrFiles) {
19
19
  const fileDialog = ()=>{
20
20
  var _input_files;
21
21
  // do not fire an input event if the file selection does not change
22
- if (files.length === ((_input_files = input.files) === null || _input_files === undefined ? undefined : _input_files.length) && files.every((f, i)=>{
22
+ if (files.length === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.length) && files.every((f, i)=>{
23
23
  var _input_files;
24
- return f === ((_input_files = input.files) === null || _input_files === undefined ? undefined : _input_files.item(i));
24
+ return f === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.item(i));
25
25
  })) {
26
26
  return;
27
27
  }
@@ -2,7 +2,6 @@ import { getWindow } from '../misc/getWindow.js';
2
2
  import { readBlobText } from './Blob.js';
3
3
  import { createDataTransfer, getBlobFromDataTransferItem } from './DataTransfer.js';
4
4
 
5
- // Clipboard is not available in jsdom
6
5
  function _define_property(obj, key, value) {
7
6
  if (key in obj) {
8
7
  Object.defineProperty(obj, key, {
@@ -11,9 +10,7 @@ function _define_property(obj, key, value) {
11
10
  configurable: true,
12
11
  writable: true
13
12
  });
14
- } else {
15
- obj[key] = value;
16
- }
13
+ } else obj[key] = value;
17
14
  return obj;
18
15
  }
19
16
  // MDN lists string|Blob|Promise<Blob|string> as possible types in ClipboardItemData
@@ -44,7 +41,7 @@ function createClipboardItem(window, ...blobs) {
44
41
  });
45
42
  }
46
43
  constructor(d){
47
- _define_property(this, "data", undefined);
44
+ _define_property(this, "data", void 0);
48
45
  this.data = d;
49
46
  }
50
47
  }(dataMap);
@@ -81,7 +78,7 @@ function createClipboardStub(window, control) {
81
78
  });
82
79
  }
83
80
  function isClipboardStub(clipboard) {
84
- return !!(clipboard === null || clipboard === undefined ? undefined : clipboard[ClipboardStubControl]);
81
+ return !!(clipboard === null || clipboard === void 0 ? void 0 : clipboard[ClipboardStubControl]);
85
82
  }
86
83
  function attachClipboardStubToView(window) {
87
84
  if (isClipboardStub(window.navigator.clipboard)) {
@@ -123,7 +120,7 @@ function detachClipboardStubFromView(window) {
123
120
  }
124
121
  async function readDataTransferFromClipboard(document) {
125
122
  const window = document.defaultView;
126
- const clipboard = window === null || window === undefined ? undefined : window.navigator.clipboard;
123
+ const clipboard = window === null || window === void 0 ? void 0 : window.navigator.clipboard;
127
124
  const items = clipboard && await clipboard.read();
128
125
  if (!items) {
129
126
  throw new Error('The Clipboard API is unavailable.');
@@ -153,10 +150,18 @@ async function writeDataTransferToClipboard(document, clipboardData) {
153
150
  }
154
151
  const g = globalThis;
155
152
  /* istanbul ignore else */ if (typeof g.afterEach === 'function') {
156
- g.afterEach(()=>resetClipboardStubOnView(globalThis.window));
153
+ g.afterEach(()=>{
154
+ if (typeof globalThis.window !== 'undefined') {
155
+ resetClipboardStubOnView(globalThis.window);
156
+ }
157
+ });
157
158
  }
158
159
  /* istanbul ignore else */ if (typeof g.afterAll === 'function') {
159
- g.afterAll(()=>detachClipboardStubFromView(globalThis.window));
160
+ g.afterAll(()=>{
161
+ if (typeof globalThis.window !== 'undefined') {
162
+ detachClipboardStubFromView(globalThis.window);
163
+ }
164
+ });
160
165
  }
161
166
 
162
167
  export { attachClipboardStubToView, createClipboardItem, detachClipboardStubFromView, readDataTransferFromClipboard, resetClipboardStubOnView, writeDataTransferToClipboard };
@@ -8,9 +8,7 @@ function _define_property(obj, key, value) {
8
8
  configurable: true,
9
9
  writable: true
10
10
  });
11
- } else {
12
- obj[key] = value;
13
- }
11
+ } else obj[key] = value;
14
12
  return obj;
15
13
  }
16
14
  // DataTransfer is not implemented in jsdom.
@@ -28,8 +26,8 @@ class DataTransferItemStub {
28
26
  throw new Error('not implemented');
29
27
  }
30
28
  constructor(dataOrFile, type){
31
- _define_property(this, "kind", undefined);
32
- _define_property(this, "type", undefined);
29
+ _define_property(this, "kind", void 0);
30
+ _define_property(this, "type", void 0);
33
31
  _define_property(this, "file", null);
34
32
  _define_property(this, "data", undefined);
35
33
  if (typeof dataOrFile === 'string') {
@@ -67,9 +65,9 @@ function createDataTransferStub(window) {
67
65
  return new class DataTransferStub {
68
66
  getData(format) {
69
67
  var _this_items_find;
70
- const match = (_this_items_find = this.items.find(getTypeMatcher(format, true))) !== null && _this_items_find !== undefined ? _this_items_find : this.items.find(getTypeMatcher(format, false));
68
+ 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));
71
69
  let text = '';
72
- match === null || match === undefined ? undefined : match.getAsString((t)=>{
70
+ match === null || match === void 0 ? void 0 : match.getAsString((t)=>{
73
71
  text = t;
74
72
  });
75
73
  return text;
@@ -1,4 +1,4 @@
1
- //jsdom is not supporting isContentEditable
1
+ // jsdom is not supporting isContentEditable
2
2
  function isContentEditable(element) {
3
3
  return element.hasAttribute('contenteditable') && (element.getAttribute('contenteditable') == 'true' || element.getAttribute('contenteditable') == '');
4
4
  }
@@ -13,7 +13,7 @@ var maxLengthSupportedTypes = /*#__PURE__*/ function(maxLengthSupportedTypes) {
13
13
  // https://github.com/jsdom/jsdom/issues/2927
14
14
  function getMaxLength(element) {
15
15
  var _element_getAttribute;
16
- const attr = (_element_getAttribute = element.getAttribute('maxlength')) !== null && _element_getAttribute !== undefined ? _element_getAttribute : '';
16
+ const attr = (_element_getAttribute = element.getAttribute('maxlength')) !== null && _element_getAttribute !== void 0 ? _element_getAttribute : '';
17
17
  return /^\d+$/.test(attr) && Number(attr) >= 0 ? Number(attr) : undefined;
18
18
  }
19
19
  function supportsMaxLength(element) {
@@ -6,13 +6,12 @@ function restoreProperty(obj, prop, descriptor) {
6
6
  if (descriptor) {
7
7
  Object.defineProperty(obj, prop, descriptor);
8
8
  } else {
9
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
10
9
  delete obj[prop];
11
10
  }
12
11
  }
13
12
  function setFiles(el, files) {
14
13
  var _el_fakeFiles;
15
- (_el_fakeFiles = el[fakeFiles]) === null || _el_fakeFiles === undefined ? undefined : _el_fakeFiles.restore();
14
+ (_el_fakeFiles = el[fakeFiles]) === null || _el_fakeFiles === void 0 ? void 0 : _el_fakeFiles.restore();
16
15
  const typeDescr = Object.getOwnPropertyDescriptor(el, 'type');
17
16
  const valueDescr = Object.getOwnPropertyDescriptor(el, 'value');
18
17
  const filesDescr = Object.getOwnPropertyDescriptor(el, 'files');
@@ -37,7 +36,7 @@ function setFiles(el, files) {
37
36
  restore();
38
37
  } else {
39
38
  var _valueDescr_set;
40
- valueDescr === null || valueDescr === undefined ? undefined : (_valueDescr_set = valueDescr.set) === null || _valueDescr_set === undefined ? undefined : _valueDescr_set.call(el, v);
39
+ valueDescr === null || valueDescr === void 0 ? void 0 : (_valueDescr_set = valueDescr.set) === null || _valueDescr_set === void 0 ? void 0 : _valueDescr_set.call(el, v);
41
40
  }
42
41
  }
43
42
  },
@@ -107,7 +107,7 @@ function walkNodes(node, direction, callback) {
107
107
  if (callback(node)) {
108
108
  return node;
109
109
  }
110
- } else if (node.parentNode && (!isElement(node.parentNode) || !isContentEditable(node.parentNode) && node.parentNode !== ((_node_ownerDocument = node.ownerDocument) === null || _node_ownerDocument === undefined ? undefined : _node_ownerDocument.body))) {
110
+ } else if (node.parentNode && (!isElement(node.parentNode) || !isContentEditable(node.parentNode) && node.parentNode !== ((_node_ownerDocument = node.ownerDocument) === null || _node_ownerDocument === void 0 ? void 0 : _node_ownerDocument.body))) {
111
111
  node = node.parentNode;
112
112
  } else {
113
113
  break;
@@ -2,19 +2,21 @@ import { isDisabled } from '../misc/isDisabled.js';
2
2
 
3
3
  function getActiveElement(document) {
4
4
  const activeElement = document.activeElement;
5
- if (activeElement === null || activeElement === undefined ? undefined : activeElement.shadowRoot) {
6
- return getActiveElement(activeElement.shadowRoot);
7
- } else {
8
- // Browser does not yield disabled elements as document.activeElement - jsdom does
9
- if (isDisabled(activeElement)) {
10
- return document.ownerDocument ? /* istanbul ignore next */ document.ownerDocument.body : document.body;
5
+ if (activeElement === null || activeElement === void 0 ? void 0 : activeElement.shadowRoot) {
6
+ const activeElementInShadowTree = getActiveElement(activeElement.shadowRoot);
7
+ if (activeElementInShadowTree) {
8
+ return activeElementInShadowTree;
11
9
  }
12
- return activeElement;
13
10
  }
11
+ // Browser does not yield disabled elements as document.activeElement - jsdom does
12
+ if (isDisabled(activeElement)) {
13
+ return document.ownerDocument ? /* istanbul ignore next */ document.ownerDocument.body : document.body;
14
+ }
15
+ return activeElement;
14
16
  }
15
17
  function getActiveElementOrBody(document) {
16
18
  var _getActiveElement;
17
- return (_getActiveElement = getActiveElement(document)) !== null && _getActiveElement !== undefined ? _getActiveElement : /* istanbul ignore next */ document.body;
19
+ return (_getActiveElement = getActiveElement(document)) !== null && _getActiveElement !== void 0 ? _getActiveElement : /* istanbul ignore next */ document.body;
18
20
  }
19
21
 
20
22
  export { getActiveElement, getActiveElementOrBody };
@@ -6,7 +6,8 @@ const FOCUSABLE_SELECTOR = [
6
6
  '[contenteditable=""]',
7
7
  '[contenteditable="true"]',
8
8
  'a[href]',
9
- '[tabindex]:not([disabled])'
9
+ '[tabindex]:not([disabled])',
10
+ 'details > summary'
10
11
  ].join(', ');
11
12
 
12
13
  export { FOCUSABLE_SELECTOR };
@@ -1,8 +1,7 @@
1
- var bracketDict = /*#__PURE__*/ function(bracketDict) {
2
- bracketDict["{"] = "}";
3
- bracketDict["["] = "]";
4
- return bracketDict;
5
- }(bracketDict || {});
1
+ const bracketDict = {
2
+ '{': '}',
3
+ '[': ']'
4
+ };
6
5
  /**
7
6
  * Read the next key definition from user input
8
7
  *
@@ -37,16 +36,16 @@ function readPrintableChar(text, pos, context) {
37
36
  };
38
37
  }
39
38
  function readTag(text, pos, startBracket, context) {
39
+ var _ref;
40
40
  var _text_slice_match, _text_slice_match1;
41
41
  const releasePreviousModifier = text[pos] === '/' ? '/' : '';
42
42
  pos += releasePreviousModifier.length;
43
43
  const escapedDescriptor = startBracket === '{' && text[pos] === '\\';
44
44
  pos += Number(escapedDescriptor);
45
- const descriptor = escapedDescriptor ? text[pos] : (_text_slice_match = text.slice(pos).match(startBracket === '{' ? /^\w+|^[^}>/]/ : /^\w+/)) === null || _text_slice_match === undefined ? undefined : _text_slice_match[0];
45
+ 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];
46
46
  assertDescriptor(descriptor, text, pos, context);
47
47
  pos += descriptor.length;
48
- var _text_slice_match_;
49
- const repeatModifier = (_text_slice_match_ = (_text_slice_match1 = text.slice(pos).match(/^>\d+/)) === null || _text_slice_match1 === undefined ? undefined : _text_slice_match1[0]) !== null && _text_slice_match_ !== undefined ? _text_slice_match_ : '';
48
+ const repeatModifier = (_ref = (_text_slice_match1 = text.slice(pos).match(/^>\d+/)) === null || _text_slice_match1 === void 0 ? void 0 : _text_slice_match1[0]) !== null && _ref !== void 0 ? _ref : '';
50
49
  pos += repeatModifier.length;
51
50
  const releaseSelfModifier = text[pos] === '/' || !repeatModifier && text[pos] === '>' ? text[pos] : '';
52
51
  pos += releaseSelfModifier.length;
@@ -82,7 +81,7 @@ function hasReleaseSelf(releaseSelfModifier, repeatModifier) {
82
81
  }
83
82
  }
84
83
  function getErrorMessage(expected, found, text, context) {
85
- return `Expected ${expected} but found "${found !== null && found !== undefined ? found : ''}" in "${text}"
84
+ return `Expected ${expected} but found "${found !== null && found !== void 0 ? found : ''}" in "${text}"
86
85
  See ${context === 'pointer' ? `https://testing-library.com/docs/user-event/pointer#pressing-a-button-or-touching-the-screen` : `https://testing-library.com/docs/user-event/keyboard`}
87
86
  for more information about how userEvent parses your input.`;
88
87
  }
@@ -2,7 +2,7 @@ function getWindow(node) {
2
2
  var _node_ownerDocument;
3
3
  if (isDocument(node) && node.defaultView) {
4
4
  return node.defaultView;
5
- } else if ((_node_ownerDocument = node.ownerDocument) === null || _node_ownerDocument === undefined ? undefined : _node_ownerDocument.defaultView) {
5
+ } else if ((_node_ownerDocument = node.ownerDocument) === null || _node_ownerDocument === void 0 ? void 0 : _node_ownerDocument.defaultView) {
6
6
  return node.ownerDocument.defaultView;
7
7
  }
8
8
  throw new Error(`Could not determine window of node. Node was ${describe(node)}`);
@@ -16,7 +16,7 @@ function isDisabled(element) {
16
16
  }
17
17
  } else if (isElementType(el, 'fieldset')) {
18
18
  var _el_querySelector;
19
- if (el.hasAttribute('disabled') && !((_el_querySelector = el.querySelector(':scope > legend')) === null || _el_querySelector === undefined ? undefined : _el_querySelector.contains(element))) {
19
+ if (el.hasAttribute('disabled') && !((_el_querySelector = el.querySelector(':scope > legend')) === null || _el_querySelector === void 0 ? void 0 : _el_querySelector.contains(element))) {
20
20
  return true;
21
21
  }
22
22
  } else if (el.tagName.includes('-')) {
@@ -2,7 +2,7 @@ import { getWindow } from './getWindow.js';
2
2
 
3
3
  function isVisible(element) {
4
4
  const window = getWindow(element);
5
- for(let el = element; el === null || el === undefined ? undefined : el.ownerDocument; el = el.parentElement){
5
+ for(let el = element; el === null || el === void 0 ? void 0 : el.ownerDocument; el = el.parentElement){
6
6
  const { display, visibility } = window.getComputedStyle(el);
7
7
  if (display === 'none') {
8
8
  return false;