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