@testing-library/user-event 14.5.2 → 14.6.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/clipboard/copy.js +1 -7
- package/dist/cjs/clipboard/cut.js +1 -7
- package/dist/cjs/clipboard/paste.js +2 -8
- package/dist/cjs/convenience/hover.js +0 -5
- package/dist/cjs/document/UI.js +3 -3
- package/dist/cjs/document/copySelection.js +0 -6
- package/dist/cjs/document/getValueOrTextContent.js +0 -6
- package/dist/cjs/document/interceptor.js +5 -11
- package/dist/cjs/document/patchFocus.js +104 -0
- package/dist/cjs/document/prepareDocument.js +1 -7
- package/dist/cjs/document/trackValue.js +2 -8
- package/dist/cjs/event/behavior/click.js +3 -9
- package/dist/cjs/event/behavior/cut.js +0 -5
- package/dist/cjs/event/behavior/keydown.js +5 -10
- package/dist/cjs/event/behavior/keypress.js +2 -7
- package/dist/cjs/event/behavior/keyup.js +1 -6
- package/dist/cjs/event/behavior/paste.js +1 -6
- package/dist/cjs/event/createEvent.js +40 -33
- package/dist/cjs/event/dispatchEvent.js +1 -1
- package/dist/cjs/event/eventMap.js +32 -0
- package/dist/cjs/event/focus.js +5 -9
- package/dist/cjs/event/index.js +0 -6
- package/dist/cjs/event/input.js +2 -7
- package/dist/cjs/event/radio.js +1 -6
- package/dist/cjs/event/selection/getInputRange.js +1 -1
- package/dist/cjs/event/selection/getTargetTypeAndSelection.js +2 -8
- package/dist/cjs/event/selection/modifySelection.js +1 -7
- package/dist/cjs/event/selection/modifySelectionPerMouse.js +2 -8
- package/dist/cjs/event/selection/moveSelection.js +1 -7
- package/dist/cjs/event/selection/resolveCaretPosition.js +4 -10
- package/dist/cjs/event/selection/selectAll.js +3 -9
- package/dist/cjs/event/selection/setSelection.js +1 -7
- package/dist/cjs/event/selection/setSelectionPerMouse.js +7 -13
- package/dist/cjs/event/selection/setSelectionRange.js +1 -7
- package/dist/cjs/event/selection/updateSelectionOnFocus.js +6 -8
- package/dist/cjs/index.js +1 -4
- package/dist/cjs/keyboard/index.js +0 -6
- package/dist/cjs/keyboard/keyMap.js +23 -1
- package/dist/cjs/keyboard/parseKeyDef.js +4 -9
- package/dist/cjs/options.js +5 -3
- package/dist/cjs/pointer/index.js +6 -11
- package/dist/cjs/pointer/parseKeyDef.js +0 -5
- package/dist/cjs/setup/setup.js +7 -7
- package/dist/cjs/system/keyboard.js +47 -25
- package/dist/cjs/system/pointer/index.js +45 -50
- package/dist/cjs/system/pointer/mouse.js +24 -29
- package/dist/cjs/system/pointer/pointer.js +24 -19
- package/dist/cjs/system/pointer/shared.js +2 -2
- package/dist/cjs/utility/clear.js +0 -5
- package/dist/cjs/utility/selectOptions.js +1 -6
- package/dist/cjs/utility/type.js +1 -7
- package/dist/cjs/utility/upload.js +13 -15
- package/dist/cjs/utils/click/isClickableInput.js +3 -3
- package/dist/cjs/utils/dataTransfer/Clipboard.js +5 -6
- package/dist/cjs/utils/dataTransfer/DataTransfer.js +6 -10
- package/dist/cjs/utils/edit/isEditable.js +3 -3
- package/dist/cjs/utils/edit/maxLength.js +4 -4
- package/dist/cjs/utils/edit/setFiles.js +2 -2
- package/dist/cjs/utils/focus/cursor.js +2 -2
- package/dist/cjs/utils/focus/getActiveElement.js +2 -2
- package/dist/cjs/utils/index.js +1 -4
- package/dist/cjs/utils/keyDef/readNextDescriptor.js +6 -6
- package/dist/cjs/utils/misc/getWindow.js +1 -1
- package/dist/cjs/utils/misc/isDisabled.js +1 -1
- package/dist/cjs/utils/misc/isVisible.js +1 -1
- package/dist/cjs/utils/misc/level.js +4 -3
- package/dist/cjs/utils/pointer/cssPointerEvents.js +11 -11
- package/dist/esm/clipboard/copy.js +1 -7
- package/dist/esm/clipboard/cut.js +1 -7
- package/dist/esm/clipboard/paste.js +2 -8
- package/dist/esm/convenience/hover.js +0 -5
- package/dist/esm/document/UI.js +3 -3
- package/dist/esm/document/copySelection.js +0 -6
- package/dist/esm/document/getValueOrTextContent.js +0 -6
- package/dist/esm/document/interceptor.js +5 -11
- package/dist/esm/document/patchFocus.js +101 -0
- package/dist/esm/document/prepareDocument.js +1 -7
- package/dist/esm/document/trackValue.js +2 -8
- package/dist/esm/event/behavior/click.js +3 -9
- package/dist/esm/event/behavior/cut.js +0 -5
- package/dist/esm/event/behavior/keydown.js +5 -10
- package/dist/esm/event/behavior/keypress.js +2 -7
- package/dist/esm/event/behavior/keyup.js +1 -6
- package/dist/esm/event/behavior/paste.js +1 -6
- package/dist/esm/event/createEvent.js +40 -33
- package/dist/esm/event/dispatchEvent.js +1 -1
- package/dist/esm/event/eventMap.js +32 -0
- package/dist/esm/event/focus.js +5 -9
- package/dist/esm/event/index.js +0 -6
- package/dist/esm/event/input.js +2 -7
- package/dist/esm/event/radio.js +1 -6
- package/dist/esm/event/selection/getInputRange.js +1 -1
- package/dist/esm/event/selection/getTargetTypeAndSelection.js +2 -8
- package/dist/esm/event/selection/modifySelection.js +1 -7
- package/dist/esm/event/selection/modifySelectionPerMouse.js +2 -8
- package/dist/esm/event/selection/moveSelection.js +1 -7
- package/dist/esm/event/selection/resolveCaretPosition.js +4 -10
- package/dist/esm/event/selection/selectAll.js +3 -9
- package/dist/esm/event/selection/setSelection.js +1 -7
- package/dist/esm/event/selection/setSelectionPerMouse.js +7 -13
- package/dist/esm/event/selection/setSelectionRange.js +1 -7
- package/dist/esm/event/selection/updateSelectionOnFocus.js +6 -8
- package/dist/esm/keyboard/index.js +0 -6
- package/dist/esm/keyboard/keyMap.js +23 -1
- package/dist/esm/keyboard/parseKeyDef.js +4 -9
- package/dist/esm/options.js +3 -3
- package/dist/esm/pointer/index.js +6 -11
- package/dist/esm/pointer/parseKeyDef.js +0 -5
- package/dist/esm/setup/setup.js +7 -7
- package/dist/esm/system/keyboard.js +46 -25
- package/dist/esm/system/pointer/index.js +45 -50
- package/dist/esm/system/pointer/mouse.js +24 -29
- package/dist/esm/system/pointer/pointer.js +24 -19
- package/dist/esm/system/pointer/shared.js +2 -2
- package/dist/esm/utility/clear.js +0 -5
- package/dist/esm/utility/selectOptions.js +1 -6
- package/dist/esm/utility/type.js +1 -7
- package/dist/esm/utility/upload.js +13 -15
- package/dist/esm/utils/click/isClickableInput.js +3 -3
- package/dist/esm/utils/dataTransfer/Clipboard.js +5 -6
- package/dist/esm/utils/dataTransfer/DataTransfer.js +6 -10
- package/dist/esm/utils/edit/isEditable.js +3 -3
- package/dist/esm/utils/edit/maxLength.js +4 -4
- package/dist/esm/utils/edit/setFiles.js +2 -2
- package/dist/esm/utils/focus/cursor.js +2 -2
- package/dist/esm/utils/focus/getActiveElement.js +2 -2
- package/dist/esm/utils/keyDef/readNextDescriptor.js +6 -6
- package/dist/esm/utils/misc/getWindow.js +1 -1
- package/dist/esm/utils/misc/isDisabled.js +1 -1
- package/dist/esm/utils/misc/isVisible.js +1 -1
- package/dist/esm/utils/misc/level.js +3 -3
- package/dist/esm/utils/pointer/cssPointerEvents.js +11 -11
- package/dist/types/document/patchFocus.d.ts +9 -0
- package/dist/types/event/eventMap.d.ts +32 -0
- package/dist/types/event/types.d.ts +1 -1
- package/dist/types/keyboard/parseKeyDef.d.ts +1 -1
- package/dist/types/options.d.ts +1 -1
- package/dist/types/system/keyboard.d.ts +1 -4
- package/dist/types/system/pointer/mouse.d.ts +9 -4
- package/dist/types/system/pointer/pointer.d.ts +7 -5
- package/dist/types/utils/dataTransfer/DataTransfer.d.ts +1 -1
- package/package.json +3 -3
|
@@ -5,15 +5,9 @@ import '../../event/behavior/keypress.js';
|
|
|
5
5
|
import '../../event/behavior/keyup.js';
|
|
6
6
|
import '../../event/behavior/paste.js';
|
|
7
7
|
import '@testing-library/dom';
|
|
8
|
-
import '../../utils/click/isClickableInput.js';
|
|
9
8
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
10
|
-
import '../../utils/edit/isEditable.js';
|
|
11
|
-
import '../../utils/edit/maxLength.js';
|
|
12
9
|
import { isDisabled } from '../../utils/misc/isDisabled.js';
|
|
13
|
-
import '../../utils/keyDef/readNextDescriptor.js';
|
|
14
10
|
import { getTreeDiff } from '../../utils/misc/getTreeDiff.js';
|
|
15
|
-
import '../../utils/misc/level.js';
|
|
16
|
-
import '../../options.js';
|
|
17
11
|
import { focusElement } from '../../event/focus.js';
|
|
18
12
|
import { setSelectionPerMouseDown } from '../../event/selection/setSelectionPerMouse.js';
|
|
19
13
|
import { modifySelectionPerMouseMove } from '../../event/selection/modifySelectionPerMouse.js';
|
|
@@ -36,7 +30,7 @@ function _define_property(obj, key, value) {
|
|
|
36
30
|
/**
|
|
37
31
|
* This object is the single "virtual" mouse that might be controlled by multiple different pointer devices.
|
|
38
32
|
*/ class Mouse {
|
|
39
|
-
move(instance, position) {
|
|
33
|
+
move(instance, position, /** Whether `preventDefault()` has been called on the `pointerdown` event */ isPrevented) {
|
|
40
34
|
const prevPosition = this.position;
|
|
41
35
|
const prevTarget = this.getTarget(instance);
|
|
42
36
|
this.position = position;
|
|
@@ -60,40 +54,46 @@ function _define_property(obj, key, value) {
|
|
|
60
54
|
}
|
|
61
55
|
},
|
|
62
56
|
move: ()=>{
|
|
57
|
+
if (isPrevented) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
63
60
|
instance.dispatchUIEvent(nextTarget, 'mousemove', init);
|
|
64
61
|
this.modifySelecting(instance);
|
|
65
62
|
}
|
|
66
63
|
};
|
|
67
64
|
}
|
|
68
|
-
down(instance, keyDef,
|
|
65
|
+
down(instance, keyDef, /** Whether `preventDefault()` has been called on the `pointerdown` event */ isPrevented) {
|
|
69
66
|
const button = this.buttons.down(keyDef);
|
|
70
67
|
if (button === undefined) {
|
|
71
68
|
return;
|
|
72
69
|
}
|
|
73
70
|
const target = this.getTarget(instance);
|
|
74
71
|
this.buttonDownTarget[button] = target;
|
|
75
|
-
const disabled = isDisabled(target);
|
|
76
72
|
const init = this.getEventInit('mousedown', keyDef.button);
|
|
77
|
-
|
|
73
|
+
const disabled = isDisabled(target);
|
|
74
|
+
if (!isPrevented && (disabled || instance.dispatchUIEvent(target, 'mousedown', init))) {
|
|
78
75
|
this.startSelecting(instance, init.detail);
|
|
79
76
|
focusElement(target);
|
|
80
77
|
}
|
|
81
78
|
if (!disabled && getMouseEventButton(keyDef.button) === 2) {
|
|
82
|
-
instance.dispatchUIEvent(target, 'contextmenu', this.getEventInit('contextmenu', keyDef.button
|
|
79
|
+
instance.dispatchUIEvent(target, 'contextmenu', this.getEventInit('contextmenu', keyDef.button));
|
|
83
80
|
}
|
|
84
81
|
}
|
|
85
|
-
up(instance, keyDef,
|
|
82
|
+
up(instance, keyDef, /** Whether `preventDefault()` has been called on the `pointerdown` event */ isPrevented) {
|
|
86
83
|
const button = this.buttons.up(keyDef);
|
|
87
84
|
if (button === undefined) {
|
|
88
85
|
return;
|
|
89
86
|
}
|
|
90
87
|
const target = this.getTarget(instance);
|
|
91
88
|
if (!isDisabled(target)) {
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
if (!isPrevented) {
|
|
90
|
+
const mouseUpInit = this.getEventInit('mouseup', keyDef.button);
|
|
91
|
+
instance.dispatchUIEvent(target, 'mouseup', mouseUpInit);
|
|
92
|
+
this.endSelecting();
|
|
93
|
+
}
|
|
94
94
|
const clickTarget = getTreeDiff(this.buttonDownTarget[button], target)[2][0];
|
|
95
95
|
if (clickTarget) {
|
|
96
|
-
const init = this.getEventInit('click', keyDef.button
|
|
96
|
+
const init = this.getEventInit('click', keyDef.button);
|
|
97
97
|
if (init.detail) {
|
|
98
98
|
instance.dispatchUIEvent(clickTarget, init.button === 0 ? 'click' : 'auxclick', init);
|
|
99
99
|
if (init.button === 0 && init.detail === 2) {
|
|
@@ -109,15 +109,10 @@ function _define_property(obj, key, value) {
|
|
|
109
109
|
resetClickCount() {
|
|
110
110
|
this.clickCount.reset();
|
|
111
111
|
}
|
|
112
|
-
getEventInit(type, button
|
|
112
|
+
getEventInit(type, button) {
|
|
113
113
|
const init = {
|
|
114
114
|
...this.position.coords
|
|
115
115
|
};
|
|
116
|
-
if (pointer) {
|
|
117
|
-
init.pointerId = pointer.pointerId;
|
|
118
|
-
init.pointerType = pointer.pointerType;
|
|
119
|
-
init.isPrimary = pointer.isPrimary;
|
|
120
|
-
}
|
|
121
116
|
init.button = getMouseEventButton(button);
|
|
122
117
|
init.buttons = this.buttons.getButtons();
|
|
123
118
|
if (type === 'mousedown') {
|
|
@@ -131,7 +126,7 @@ function _define_property(obj, key, value) {
|
|
|
131
126
|
}
|
|
132
127
|
getTarget(instance) {
|
|
133
128
|
var _this_position_target;
|
|
134
|
-
return (_this_position_target = this.position.target) !== null && _this_position_target !==
|
|
129
|
+
return (_this_position_target = this.position.target) !== null && _this_position_target !== undefined ? _this_position_target : instance.config.document.body;
|
|
135
130
|
}
|
|
136
131
|
startSelecting(instance, clickCount) {
|
|
137
132
|
var _this_position_caret, _this_position_caret1;
|
|
@@ -139,8 +134,8 @@ function _define_property(obj, key, value) {
|
|
|
139
134
|
this.selecting = setSelectionPerMouseDown({
|
|
140
135
|
document: instance.config.document,
|
|
141
136
|
target: this.getTarget(instance),
|
|
142
|
-
node: (_this_position_caret = this.position.caret) === null || _this_position_caret ===
|
|
143
|
-
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 ===
|
|
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,
|
|
144
139
|
clickCount
|
|
145
140
|
});
|
|
146
141
|
}
|
|
@@ -152,8 +147,8 @@ function _define_property(obj, key, value) {
|
|
|
152
147
|
modifySelectionPerMouseMove(this.selecting, {
|
|
153
148
|
document: instance.config.document,
|
|
154
149
|
target: this.getTarget(instance),
|
|
155
|
-
node: (_this_position_caret = this.position.caret) === null || _this_position_caret ===
|
|
156
|
-
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 ===
|
|
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
|
|
157
152
|
});
|
|
158
153
|
}
|
|
159
154
|
endSelecting() {
|
|
@@ -162,7 +157,7 @@ function _define_property(obj, key, value) {
|
|
|
162
157
|
constructor(){
|
|
163
158
|
_define_property(this, "position", {});
|
|
164
159
|
_define_property(this, "buttons", new Buttons());
|
|
165
|
-
_define_property(this, "selecting",
|
|
160
|
+
_define_property(this, "selecting", undefined);
|
|
166
161
|
_define_property(this, "buttonDownTarget", {});
|
|
167
162
|
// According to spec the `detail` on click events should be the number
|
|
168
163
|
// of *consecutive* clicks with a specific button.
|
|
@@ -185,11 +180,11 @@ function _define_property(obj, key, value) {
|
|
|
185
180
|
getOnDown(button) {
|
|
186
181
|
var _this_count_button;
|
|
187
182
|
this.down = {
|
|
188
|
-
[button]: (_this_count_button = this.count[button]) !== null && _this_count_button !==
|
|
183
|
+
[button]: (_this_count_button = this.count[button]) !== null && _this_count_button !== undefined ? _this_count_button : 0
|
|
189
184
|
};
|
|
190
185
|
var _this_count_button1;
|
|
191
186
|
this.count = {
|
|
192
|
-
[button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !==
|
|
187
|
+
[button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !== undefined ? _this_count_button1 : 0
|
|
193
188
|
};
|
|
194
189
|
return Number(this.count[button]) + 1;
|
|
195
190
|
}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import '../../utils/click/isClickableInput.js';
|
|
2
1
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import '../../utils/edit/isEditable.js';
|
|
4
|
-
import '../../utils/edit/maxLength.js';
|
|
5
|
-
import '../../utils/keyDef/readNextDescriptor.js';
|
|
6
2
|
import { getTreeDiff } from '../../utils/misc/getTreeDiff.js';
|
|
7
|
-
import '../../utils/misc/level.js';
|
|
8
3
|
import { assertPointerEvents, hasPointerEvents } from '../../utils/pointer/cssPointerEvents.js';
|
|
9
4
|
import { isDifferentPointerPosition } from './shared.js';
|
|
5
|
+
import { getMouseEventButton } from './buttons.js';
|
|
10
6
|
|
|
11
7
|
function _define_property(obj, key, value) {
|
|
12
8
|
if (key in obj) {
|
|
@@ -22,8 +18,7 @@ function _define_property(obj, key, value) {
|
|
|
22
18
|
return obj;
|
|
23
19
|
}
|
|
24
20
|
class Pointer {
|
|
25
|
-
init(instance
|
|
26
|
-
this.position = position;
|
|
21
|
+
init(instance) {
|
|
27
22
|
const target = this.getTarget(instance);
|
|
28
23
|
const [, enter] = getTreeDiff(null, target);
|
|
29
24
|
const init = this.getEventInit();
|
|
@@ -40,7 +35,7 @@ class Pointer {
|
|
|
40
35
|
return;
|
|
41
36
|
}
|
|
42
37
|
const nextTarget = this.getTarget(instance);
|
|
43
|
-
const init = this.getEventInit();
|
|
38
|
+
const init = this.getEventInit(-1);
|
|
44
39
|
const [leave, enter] = getTreeDiff(prevTarget, nextTarget);
|
|
45
40
|
return {
|
|
46
41
|
leave: ()=>{
|
|
@@ -63,23 +58,24 @@ class Pointer {
|
|
|
63
58
|
}
|
|
64
59
|
};
|
|
65
60
|
}
|
|
66
|
-
down(instance,
|
|
61
|
+
down(instance, button = 0) {
|
|
67
62
|
if (this.isDown) {
|
|
68
63
|
return;
|
|
69
64
|
}
|
|
70
65
|
const target = this.getTarget(instance);
|
|
71
66
|
assertPointerEvents(instance, target);
|
|
72
67
|
this.isDown = true;
|
|
73
|
-
this.isPrevented = !instance.dispatchUIEvent(target, 'pointerdown', this.getEventInit());
|
|
68
|
+
this.isPrevented = !instance.dispatchUIEvent(target, 'pointerdown', this.getEventInit(button));
|
|
74
69
|
}
|
|
75
|
-
up(instance,
|
|
70
|
+
up(instance, button = 0) {
|
|
76
71
|
if (!this.isDown) {
|
|
77
72
|
return;
|
|
78
73
|
}
|
|
79
74
|
const target = this.getTarget(instance);
|
|
80
75
|
assertPointerEvents(instance, target);
|
|
76
|
+
this.isPrevented = false;
|
|
81
77
|
this.isDown = false;
|
|
82
|
-
instance.dispatchUIEvent(target, 'pointerup', this.getEventInit());
|
|
78
|
+
instance.dispatchUIEvent(target, 'pointerup', this.getEventInit(button));
|
|
83
79
|
}
|
|
84
80
|
release(instance) {
|
|
85
81
|
const target = this.getTarget(instance);
|
|
@@ -95,20 +91,28 @@ class Pointer {
|
|
|
95
91
|
}
|
|
96
92
|
getTarget(instance) {
|
|
97
93
|
var _this_position_target;
|
|
98
|
-
return (_this_position_target = this.position.target) !== null && _this_position_target !==
|
|
94
|
+
return (_this_position_target = this.position.target) !== null && _this_position_target !== undefined ? _this_position_target : instance.config.document.body;
|
|
99
95
|
}
|
|
100
|
-
getEventInit(
|
|
96
|
+
getEventInit(/**
|
|
97
|
+
* The `button` that caused the event.
|
|
98
|
+
*
|
|
99
|
+
* This should be `-1` if the event is not caused by a button or touch/pen contact,
|
|
100
|
+
* e.g. a moving pointer.
|
|
101
|
+
*/ button) {
|
|
101
102
|
return {
|
|
102
103
|
...this.position.coords,
|
|
103
104
|
pointerId: this.pointerId,
|
|
104
105
|
pointerType: this.pointerType,
|
|
105
|
-
isPrimary: this.isPrimary
|
|
106
|
+
isPrimary: this.isPrimary,
|
|
107
|
+
button: getMouseEventButton(button),
|
|
108
|
+
buttons: this.buttons.getButtons()
|
|
106
109
|
};
|
|
107
110
|
}
|
|
108
|
-
constructor({ pointerId, pointerType, isPrimary }){
|
|
109
|
-
_define_property(this, "pointerId",
|
|
110
|
-
_define_property(this, "pointerType",
|
|
111
|
-
_define_property(this, "isPrimary",
|
|
111
|
+
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);
|
|
112
116
|
_define_property(this, "isMultitouch", false);
|
|
113
117
|
_define_property(this, "isCancelled", false);
|
|
114
118
|
_define_property(this, "isDown", false);
|
|
@@ -118,6 +122,7 @@ class Pointer {
|
|
|
118
122
|
this.pointerType = pointerType;
|
|
119
123
|
this.isPrimary = isPrimary;
|
|
120
124
|
this.isMultitouch = !isPrimary;
|
|
125
|
+
this.buttons = buttons;
|
|
121
126
|
}
|
|
122
127
|
}
|
|
123
128
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function isDifferentPointerPosition(positionA, positionB) {
|
|
2
|
-
var _positionA_coords, _positionB_coords, _positionA_coords1, _positionB_coords1, _positionA_caret, _positionB_caret, _positionA_caret1, _positionB_caret1;
|
|
3
|
-
return positionA.target !== positionB.target || ((_positionA_coords = positionA.coords) === null || _positionA_coords ===
|
|
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);
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
export { isDifferentPointerPosition };
|
|
@@ -5,14 +5,9 @@ import '../event/behavior/keypress.js';
|
|
|
5
5
|
import '../event/behavior/keyup.js';
|
|
6
6
|
import '../event/behavior/paste.js';
|
|
7
7
|
import '@testing-library/dom';
|
|
8
|
-
import '../utils/click/isClickableInput.js';
|
|
9
8
|
import '../utils/dataTransfer/Clipboard.js';
|
|
10
9
|
import { isEditable } from '../utils/edit/isEditable.js';
|
|
11
|
-
import '../utils/edit/maxLength.js';
|
|
12
10
|
import { isDisabled } from '../utils/misc/isDisabled.js';
|
|
13
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
14
|
-
import '../utils/misc/level.js';
|
|
15
|
-
import '../options.js';
|
|
16
11
|
import { focusElement } from '../event/focus.js';
|
|
17
12
|
import { input } from '../event/input.js';
|
|
18
13
|
import { selectAll, isAllSelected } from '../event/selection/selectAll.js';
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { getConfig } from '@testing-library/dom';
|
|
2
|
-
import '../utils/click/isClickableInput.js';
|
|
3
|
-
import '../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../utils/edit/isEditable.js';
|
|
5
|
-
import '../utils/edit/maxLength.js';
|
|
6
2
|
import { isElementType } from '../utils/misc/isElementType.js';
|
|
3
|
+
import '../utils/dataTransfer/Clipboard.js';
|
|
7
4
|
import { isDisabled } from '../utils/misc/isDisabled.js';
|
|
8
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
9
|
-
import '../utils/misc/level.js';
|
|
10
5
|
import { wait } from '../utils/misc/wait.js';
|
|
11
6
|
import { hasPointerEvents } from '../utils/pointer/cssPointerEvents.js';
|
|
12
7
|
import '../event/behavior/click.js';
|
package/dist/esm/utility/type.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { releaseAllKeys } from '../keyboard/index.js';
|
|
2
|
-
import '../utils/click/isClickableInput.js';
|
|
3
2
|
import '../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../utils/edit/isEditable.js';
|
|
5
|
-
import '../utils/edit/maxLength.js';
|
|
6
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
7
|
-
import '../utils/misc/level.js';
|
|
8
|
-
import '../options.js';
|
|
9
3
|
import { setSelectionRange } from '../event/selection/setSelectionRange.js';
|
|
10
4
|
|
|
11
5
|
async function type(element, text, { skipClick = this.config.skipClick, skipAutoClose = this.config.skipAutoClose, initialSelectionStart, initialSelectionEnd } = {}) {
|
|
@@ -16,7 +10,7 @@ async function type(element, text, { skipClick = this.config.skipClick, skipAuto
|
|
|
16
10
|
await this.click(element);
|
|
17
11
|
}
|
|
18
12
|
if (initialSelectionStart !== undefined) {
|
|
19
|
-
setSelectionRange(element, initialSelectionStart, initialSelectionEnd !== null && initialSelectionEnd !==
|
|
13
|
+
setSelectionRange(element, initialSelectionStart, initialSelectionEnd !== null && initialSelectionEnd !== undefined ? initialSelectionEnd : initialSelectionStart);
|
|
20
14
|
}
|
|
21
15
|
await this.keyboard(text);
|
|
22
16
|
if (!skipAutoClose) {
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
import '../utils/
|
|
1
|
+
import { isElementType } from '../utils/misc/isElementType.js';
|
|
2
2
|
import { createFileList } from '../utils/dataTransfer/FileList.js';
|
|
3
3
|
import '../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../utils/edit/isEditable.js';
|
|
5
|
-
import '../utils/edit/maxLength.js';
|
|
6
4
|
import { setFiles } from '../utils/edit/setFiles.js';
|
|
7
|
-
import { isElementType } from '../utils/misc/isElementType.js';
|
|
8
5
|
import { isDisabled } from '../utils/misc/isDisabled.js';
|
|
9
6
|
import { getWindow } from '../utils/misc/getWindow.js';
|
|
10
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
11
|
-
import '../utils/misc/level.js';
|
|
12
|
-
import '../options.js';
|
|
13
7
|
|
|
14
8
|
async function upload(element, fileOrFiles) {
|
|
15
9
|
const input = isElementType(element, 'label') ? element.control : element;
|
|
16
10
|
if (!input || !isElementType(input, 'input', {
|
|
17
11
|
type: 'file'
|
|
18
12
|
})) {
|
|
19
|
-
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input ===
|
|
13
|
+
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === undefined ? undefined : input.tagName} element does not accept file uploads`);
|
|
20
14
|
}
|
|
21
15
|
if (isDisabled(element)) return;
|
|
22
16
|
const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [
|
|
@@ -25,9 +19,9 @@ async function upload(element, fileOrFiles) {
|
|
|
25
19
|
const fileDialog = ()=>{
|
|
26
20
|
var _input_files;
|
|
27
21
|
// do not fire an input event if the file selection does not change
|
|
28
|
-
if (files.length === ((_input_files = input.files) === null || _input_files ===
|
|
22
|
+
if (files.length === ((_input_files = input.files) === null || _input_files === undefined ? undefined : _input_files.length) && files.every((f, i)=>{
|
|
29
23
|
var _input_files;
|
|
30
|
-
return f === ((_input_files = input.files) === null || _input_files ===
|
|
24
|
+
return f === ((_input_files = input.files) === null || _input_files === undefined ? undefined : _input_files.item(i));
|
|
31
25
|
})) {
|
|
32
26
|
return;
|
|
33
27
|
}
|
|
@@ -39,6 +33,10 @@ async function upload(element, fileOrFiles) {
|
|
|
39
33
|
await this.click(element);
|
|
40
34
|
input.removeEventListener('fileDialog', fileDialog);
|
|
41
35
|
}
|
|
36
|
+
// When matching files, browsers ignore case and consider jpeg/jpg interchangeable.
|
|
37
|
+
function normalize(nameOrType) {
|
|
38
|
+
return nameOrType.toLowerCase().replace(/(\.|\/)jpg\b/g, '$1jpeg');
|
|
39
|
+
}
|
|
42
40
|
function isAcceptableFile(file, accept) {
|
|
43
41
|
if (!accept) {
|
|
44
42
|
return true;
|
|
@@ -48,14 +46,14 @@ function isAcceptableFile(file, accept) {
|
|
|
48
46
|
'image/*',
|
|
49
47
|
'video/*'
|
|
50
48
|
];
|
|
51
|
-
return accept.split(
|
|
49
|
+
return normalize(accept).trim().split(/\s*,\s*/).some((acceptToken)=>{
|
|
50
|
+
// tokens starting with a dot represent a file extension
|
|
52
51
|
if (acceptToken.startsWith('.')) {
|
|
53
|
-
|
|
54
|
-
return file.name.endsWith(acceptToken);
|
|
52
|
+
return normalize(file.name).endsWith(acceptToken);
|
|
55
53
|
} else if (wildcards.includes(acceptToken)) {
|
|
56
|
-
return file.type.startsWith(acceptToken.
|
|
54
|
+
return normalize(file.type).startsWith(acceptToken.replace('*', ''));
|
|
57
55
|
}
|
|
58
|
-
return file.type === acceptToken;
|
|
56
|
+
return normalize(file.type) === acceptToken;
|
|
59
57
|
});
|
|
60
58
|
}
|
|
61
59
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { isElementType } from '../misc/isElementType.js';
|
|
2
2
|
|
|
3
|
-
var clickableInputTypes
|
|
4
|
-
(function(clickableInputTypes) {
|
|
3
|
+
var clickableInputTypes = /*#__PURE__*/ function(clickableInputTypes) {
|
|
5
4
|
clickableInputTypes["button"] = "button";
|
|
6
5
|
clickableInputTypes["color"] = "color";
|
|
7
6
|
clickableInputTypes["file"] = "file";
|
|
@@ -10,7 +9,8 @@ var clickableInputTypes;
|
|
|
10
9
|
clickableInputTypes["submit"] = "submit";
|
|
11
10
|
clickableInputTypes["checkbox"] = "checkbox";
|
|
12
11
|
clickableInputTypes["radio"] = "radio";
|
|
13
|
-
|
|
12
|
+
return clickableInputTypes;
|
|
13
|
+
}(clickableInputTypes || {});
|
|
14
14
|
function isClickableInput(element) {
|
|
15
15
|
return isElementType(element, 'button') || isElementType(element, 'input') && element.type in clickableInputTypes;
|
|
16
16
|
}
|
|
@@ -44,7 +44,7 @@ function createClipboardItem(window, ...blobs) {
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
constructor(d){
|
|
47
|
-
_define_property(this, "data",
|
|
47
|
+
_define_property(this, "data", undefined);
|
|
48
48
|
this.data = d;
|
|
49
49
|
}
|
|
50
50
|
}(dataMap);
|
|
@@ -74,15 +74,14 @@ function createClipboardStub(window, control) {
|
|
|
74
74
|
];
|
|
75
75
|
}
|
|
76
76
|
constructor(...args){
|
|
77
|
-
super(...args);
|
|
78
|
-
_define_property(this, "items", []);
|
|
77
|
+
super(...args), _define_property(this, "items", []);
|
|
79
78
|
}
|
|
80
79
|
}(), {
|
|
81
80
|
[ClipboardStubControl]: control
|
|
82
81
|
});
|
|
83
82
|
}
|
|
84
83
|
function isClipboardStub(clipboard) {
|
|
85
|
-
return !!(clipboard === null || clipboard ===
|
|
84
|
+
return !!(clipboard === null || clipboard === undefined ? undefined : clipboard[ClipboardStubControl]);
|
|
86
85
|
}
|
|
87
86
|
function attachClipboardStubToView(window) {
|
|
88
87
|
if (isClipboardStub(window.navigator.clipboard)) {
|
|
@@ -124,7 +123,7 @@ function detachClipboardStubFromView(window) {
|
|
|
124
123
|
}
|
|
125
124
|
async function readDataTransferFromClipboard(document) {
|
|
126
125
|
const window = document.defaultView;
|
|
127
|
-
const clipboard = window === null || window ===
|
|
126
|
+
const clipboard = window === null || window === undefined ? undefined : window.navigator.clipboard;
|
|
128
127
|
const items = clipboard && await clipboard.read();
|
|
129
128
|
if (!items) {
|
|
130
129
|
throw new Error('The Clipboard API is unavailable.');
|
|
@@ -143,7 +142,7 @@ async function writeDataTransferToClipboard(document, clipboardData) {
|
|
|
143
142
|
const items = [];
|
|
144
143
|
for(let i = 0; i < clipboardData.items.length; i++){
|
|
145
144
|
const dtItem = clipboardData.items[i];
|
|
146
|
-
const blob = getBlobFromDataTransferItem(window, dtItem);
|
|
145
|
+
const blob = await getBlobFromDataTransferItem(window, dtItem);
|
|
147
146
|
items.push(createClipboardItem(window, blob));
|
|
148
147
|
}
|
|
149
148
|
const written = clipboard && await clipboard.write(items).then(()=>true, // Can happen with other implementations that e.g. require permissions
|
|
@@ -28,8 +28,8 @@ class DataTransferItemStub {
|
|
|
28
28
|
throw new Error('not implemented');
|
|
29
29
|
}
|
|
30
30
|
constructor(dataOrFile, type){
|
|
31
|
-
_define_property(this, "kind",
|
|
32
|
-
_define_property(this, "type",
|
|
31
|
+
_define_property(this, "kind", undefined);
|
|
32
|
+
_define_property(this, "type", undefined);
|
|
33
33
|
_define_property(this, "file", null);
|
|
34
34
|
_define_property(this, "data", undefined);
|
|
35
35
|
if (typeof dataOrFile === 'string') {
|
|
@@ -67,9 +67,9 @@ function createDataTransferStub(window) {
|
|
|
67
67
|
return new class DataTransferStub {
|
|
68
68
|
getData(format) {
|
|
69
69
|
var _this_items_find;
|
|
70
|
-
const match = (_this_items_find = this.items.find(getTypeMatcher(format, true))) !== null && _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));
|
|
71
71
|
let text = '';
|
|
72
|
-
match === null || match ===
|
|
72
|
+
match === null || match === undefined ? undefined : match.getAsString((t)=>{
|
|
73
73
|
text = t;
|
|
74
74
|
});
|
|
75
75
|
return text;
|
|
@@ -119,16 +119,12 @@ function createDataTransfer(window, files = []) {
|
|
|
119
119
|
});
|
|
120
120
|
return dt;
|
|
121
121
|
}
|
|
122
|
-
function getBlobFromDataTransferItem(window, item) {
|
|
122
|
+
async function getBlobFromDataTransferItem(window, item) {
|
|
123
123
|
if (item.kind === 'file') {
|
|
124
124
|
return item.getAsFile();
|
|
125
125
|
}
|
|
126
|
-
let data = '';
|
|
127
|
-
item.getAsString((s)=>{
|
|
128
|
-
data = s;
|
|
129
|
-
});
|
|
130
126
|
return new window.Blob([
|
|
131
|
-
|
|
127
|
+
await new Promise((r)=>item.getAsString(r))
|
|
132
128
|
], {
|
|
133
129
|
type: item.type
|
|
134
130
|
});
|
|
@@ -4,8 +4,7 @@ import { isContentEditable } from './isContentEditable.js';
|
|
|
4
4
|
function isEditable(element) {
|
|
5
5
|
return isEditableInputOrTextArea(element) && !element.readOnly || isContentEditable(element);
|
|
6
6
|
}
|
|
7
|
-
var editableInputTypes
|
|
8
|
-
(function(editableInputTypes) {
|
|
7
|
+
var editableInputTypes = /*#__PURE__*/ function(editableInputTypes) {
|
|
9
8
|
editableInputTypes["text"] = "text";
|
|
10
9
|
editableInputTypes["date"] = "date";
|
|
11
10
|
editableInputTypes["datetime-local"] = "datetime-local";
|
|
@@ -18,7 +17,8 @@ var editableInputTypes;
|
|
|
18
17
|
editableInputTypes["time"] = "time";
|
|
19
18
|
editableInputTypes["url"] = "url";
|
|
20
19
|
editableInputTypes["week"] = "week";
|
|
21
|
-
|
|
20
|
+
return editableInputTypes;
|
|
21
|
+
}(editableInputTypes || {});
|
|
22
22
|
function isEditableInputOrTextArea(element) {
|
|
23
23
|
return isElementType(element, 'textarea') || isElementType(element, 'input') && element.type in editableInputTypes;
|
|
24
24
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { isElementType } from '../misc/isElementType.js';
|
|
2
2
|
|
|
3
|
-
var maxLengthSupportedTypes
|
|
4
|
-
(function(maxLengthSupportedTypes) {
|
|
3
|
+
var maxLengthSupportedTypes = /*#__PURE__*/ function(maxLengthSupportedTypes) {
|
|
5
4
|
maxLengthSupportedTypes["email"] = "email";
|
|
6
5
|
maxLengthSupportedTypes["password"] = "password";
|
|
7
6
|
maxLengthSupportedTypes["search"] = "search";
|
|
8
7
|
maxLengthSupportedTypes["telephone"] = "telephone";
|
|
9
8
|
maxLengthSupportedTypes["text"] = "text";
|
|
10
9
|
maxLengthSupportedTypes["url"] = "url";
|
|
11
|
-
|
|
10
|
+
return maxLengthSupportedTypes;
|
|
11
|
+
}(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
15
|
var _element_getAttribute;
|
|
16
|
-
const attr = (_element_getAttribute = element.getAttribute('maxlength')) !== null && _element_getAttribute !==
|
|
16
|
+
const attr = (_element_getAttribute = element.getAttribute('maxlength')) !== null && _element_getAttribute !== undefined ? _element_getAttribute : '';
|
|
17
17
|
return /^\d+$/.test(attr) && Number(attr) >= 0 ? Number(attr) : undefined;
|
|
18
18
|
}
|
|
19
19
|
function supportsMaxLength(element) {
|
|
@@ -12,7 +12,7 @@ function restoreProperty(obj, prop, descriptor) {
|
|
|
12
12
|
}
|
|
13
13
|
function setFiles(el, files) {
|
|
14
14
|
var _el_fakeFiles;
|
|
15
|
-
(_el_fakeFiles = el[fakeFiles]) === null || _el_fakeFiles ===
|
|
15
|
+
(_el_fakeFiles = el[fakeFiles]) === null || _el_fakeFiles === undefined ? undefined : _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');
|
|
@@ -37,7 +37,7 @@ function setFiles(el, files) {
|
|
|
37
37
|
restore();
|
|
38
38
|
} else {
|
|
39
39
|
var _valueDescr_set;
|
|
40
|
-
valueDescr === null || valueDescr ===
|
|
40
|
+
valueDescr === null || valueDescr === undefined ? undefined : (_valueDescr_set = valueDescr.set) === null || _valueDescr_set === undefined ? undefined : _valueDescr_set.call(el, v);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
},
|
|
@@ -7,7 +7,7 @@ function getNextCursorPosition(node, offset, direction, inputType) {
|
|
|
7
7
|
// Firefox always moves to zero offset and jumps over last offset.
|
|
8
8
|
// Chrome jumps over zero offset per default but over last offset when Shift is pressed.
|
|
9
9
|
// The cursor always moves to zero offset if the focus area (contenteditable or body) ends there.
|
|
10
|
-
// When walking
|
|
10
|
+
// When walking forward both ignore zero offset.
|
|
11
11
|
// When walking over input elements the cursor moves before or after that element.
|
|
12
12
|
// When walking over line breaks the cursor moves inside any following text node.
|
|
13
13
|
if (isTextNode(node) && offset + direction >= 0 && offset + direction <= node.nodeValue.length) {
|
|
@@ -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 ===
|
|
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))) {
|
|
111
111
|
node = node.parentNode;
|
|
112
112
|
} else {
|
|
113
113
|
break;
|
|
@@ -2,7 +2,7 @@ import { isDisabled } from '../misc/isDisabled.js';
|
|
|
2
2
|
|
|
3
3
|
function getActiveElement(document) {
|
|
4
4
|
const activeElement = document.activeElement;
|
|
5
|
-
if (activeElement === null || activeElement ===
|
|
5
|
+
if (activeElement === null || activeElement === undefined ? undefined : activeElement.shadowRoot) {
|
|
6
6
|
return getActiveElement(activeElement.shadowRoot);
|
|
7
7
|
} else {
|
|
8
8
|
// Browser does not yield disabled elements as document.activeElement - jsdom does
|
|
@@ -14,7 +14,7 @@ function getActiveElement(document) {
|
|
|
14
14
|
}
|
|
15
15
|
function getActiveElementOrBody(document) {
|
|
16
16
|
var _getActiveElement;
|
|
17
|
-
return (_getActiveElement = getActiveElement(document)) !== null && _getActiveElement !==
|
|
17
|
+
return (_getActiveElement = getActiveElement(document)) !== null && _getActiveElement !== undefined ? _getActiveElement : /* istanbul ignore next */ document.body;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export { getActiveElement, getActiveElementOrBody };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var bracketDict
|
|
2
|
-
(function(bracketDict) {
|
|
1
|
+
var bracketDict = /*#__PURE__*/ function(bracketDict) {
|
|
3
2
|
bracketDict["{"] = "}";
|
|
4
3
|
bracketDict["["] = "]";
|
|
5
|
-
|
|
4
|
+
return bracketDict;
|
|
5
|
+
}(bracketDict || {});
|
|
6
6
|
/**
|
|
7
7
|
* Read the next key definition from user input
|
|
8
8
|
*
|
|
@@ -42,11 +42,11 @@ function readTag(text, pos, startBracket, context) {
|
|
|
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 ===
|
|
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];
|
|
46
46
|
assertDescriptor(descriptor, text, pos, context);
|
|
47
47
|
pos += descriptor.length;
|
|
48
48
|
var _text_slice_match_;
|
|
49
|
-
const repeatModifier = (_text_slice_match_ = (_text_slice_match1 = text.slice(pos).match(/^>\d+/)) === null || _text_slice_match1 ===
|
|
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_ : '';
|
|
50
50
|
pos += repeatModifier.length;
|
|
51
51
|
const releaseSelfModifier = text[pos] === '/' || !repeatModifier && text[pos] === '>' ? text[pos] : '';
|
|
52
52
|
pos += releaseSelfModifier.length;
|
|
@@ -82,7 +82,7 @@ function hasReleaseSelf(releaseSelfModifier, repeatModifier) {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
function getErrorMessage(expected, found, text, context) {
|
|
85
|
-
return `Expected ${expected} but found "${found !== null && found !==
|
|
85
|
+
return `Expected ${expected} but found "${found !== null && found !== undefined ? found : ''}" in "${text}"
|
|
86
86
|
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
87
|
for more information about how userEvent parses your input.`;
|
|
88
88
|
}
|