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