@testing-library/user-event 14.4.0 → 14.4.3
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 +6 -15
- package/dist/cjs/clipboard/cut.js +6 -15
- package/dist/cjs/clipboard/paste.js +6 -14
- package/dist/cjs/convenience/click.js +1 -4
- package/dist/cjs/convenience/hover.js +2 -12
- package/dist/cjs/document/UI.js +94 -0
- package/dist/cjs/document/copySelection.js +37 -0
- package/dist/cjs/document/getValueOrTextContent.js +27 -0
- package/dist/cjs/document/index.js +13 -68
- package/dist/cjs/document/interceptor.js +87 -4
- package/dist/cjs/document/prepareDocument.js +67 -0
- package/dist/cjs/document/trackValue.js +65 -0
- package/dist/cjs/event/behavior/click.js +8 -12
- package/dist/cjs/event/behavior/cut.js +5 -11
- package/dist/cjs/event/behavior/keydown.js +43 -43
- package/dist/cjs/event/behavior/keypress.js +9 -10
- package/dist/cjs/event/behavior/keyup.js +6 -7
- package/dist/cjs/event/behavior/paste.js +7 -12
- package/dist/cjs/event/createEvent.js +37 -28
- package/dist/cjs/event/dispatchEvent.js +21 -2
- package/dist/cjs/event/focus.js +44 -0
- package/dist/cjs/event/index.js +24 -17
- package/dist/cjs/{utils/edit → event}/input.js +50 -47
- package/dist/cjs/{utils/edit/walkRadio.js → event/radio.js} +13 -7
- package/dist/cjs/event/selection/getInputRange.js +20 -0
- package/dist/cjs/event/selection/getTargetTypeAndSelection.js +40 -0
- package/dist/cjs/event/selection/index.js +26 -0
- package/dist/cjs/event/selection/modifySelection.js +30 -0
- package/dist/cjs/event/selection/modifySelectionPerMouse.js +49 -0
- package/dist/cjs/event/selection/moveSelection.js +47 -0
- package/dist/cjs/{utils/focus → event/selection}/resolveCaretPosition.js +11 -19
- package/dist/cjs/event/selection/selectAll.js +47 -0
- package/dist/cjs/event/selection/setSelection.js +30 -0
- package/dist/cjs/event/selection/setSelectionPerMouse.js +90 -0
- package/dist/cjs/event/selection/setSelectionRange.js +40 -0
- package/dist/cjs/event/selection/updateSelectionOnFocus.js +45 -0
- package/dist/cjs/keyboard/index.js +13 -23
- package/dist/cjs/keyboard/parseKeyDef.js +8 -13
- package/dist/cjs/options.js +0 -28
- package/dist/cjs/pointer/index.js +28 -34
- package/dist/cjs/pointer/parseKeyDef.js +1 -9
- package/dist/cjs/setup/directApi.js +6 -6
- package/dist/cjs/setup/index.js +0 -2
- package/dist/cjs/setup/setup.js +69 -38
- package/dist/cjs/system/index.js +4 -2
- package/dist/cjs/system/keyboard.js +32 -32
- package/dist/cjs/system/pointer/buttons.js +3 -1
- package/dist/cjs/system/pointer/device.js +3 -1
- package/dist/cjs/system/pointer/index.js +82 -79
- package/dist/cjs/system/pointer/mouse.js +97 -81
- package/dist/cjs/system/pointer/pointer.js +45 -46
- package/dist/cjs/system/pointer/shared.js +10 -0
- package/dist/cjs/utility/clear.js +10 -11
- package/dist/cjs/utility/selectOptions.js +17 -19
- package/dist/cjs/utility/type.js +6 -15
- package/dist/cjs/utility/upload.js +9 -15
- package/dist/cjs/utils/dataTransfer/Clipboard.js +11 -21
- package/dist/cjs/utils/dataTransfer/DataTransfer.js +22 -19
- package/dist/cjs/utils/edit/isEditable.js +6 -10
- package/dist/cjs/utils/edit/maxLength.js +6 -16
- package/dist/cjs/utils/edit/setFiles.js +4 -2
- package/dist/cjs/utils/edit/{buildTimeValue.js → timeValue.js} +6 -0
- package/dist/cjs/utils/focus/cursor.js +2 -17
- package/dist/cjs/utils/focus/getActiveElement.js +3 -2
- package/dist/cjs/utils/focus/selection.js +1 -266
- package/dist/cjs/utils/index.js +7 -32
- package/dist/cjs/utils/keyDef/readNextDescriptor.js +5 -3
- package/dist/cjs/utils/misc/isDisabled.js +2 -1
- package/dist/cjs/utils/misc/isVisible.js +1 -1
- package/dist/cjs/utils/misc/level.js +4 -6
- package/dist/cjs/utils/pointer/cssPointerEvents.js +26 -32
- package/dist/esm/clipboard/copy.js +6 -15
- package/dist/esm/clipboard/cut.js +6 -15
- package/dist/esm/clipboard/paste.js +6 -14
- package/dist/esm/convenience/click.js +1 -4
- package/dist/esm/convenience/hover.js +2 -12
- package/dist/esm/document/UI.js +79 -0
- package/dist/esm/document/copySelection.js +33 -0
- package/dist/esm/document/getValueOrTextContent.js +23 -0
- package/dist/esm/document/index.js +4 -66
- package/dist/esm/document/interceptor.js +85 -5
- package/dist/esm/document/prepareDocument.js +63 -0
- package/dist/esm/document/trackValue.js +59 -0
- package/dist/esm/event/behavior/click.js +8 -12
- package/dist/esm/event/behavior/cut.js +5 -11
- package/dist/esm/event/behavior/keydown.js +36 -36
- package/dist/esm/event/behavior/keypress.js +9 -10
- package/dist/esm/event/behavior/keyup.js +6 -7
- package/dist/esm/event/behavior/paste.js +7 -12
- package/dist/esm/event/createEvent.js +37 -28
- package/dist/esm/event/dispatchEvent.js +20 -3
- package/dist/esm/event/focus.js +39 -0
- package/dist/esm/event/index.js +14 -19
- package/dist/esm/{utils/edit → event}/input.js +37 -34
- package/dist/esm/{utils/edit/walkRadio.js → event/radio.js} +13 -7
- package/dist/esm/event/selection/getInputRange.js +16 -0
- package/dist/esm/event/selection/getTargetTypeAndSelection.js +36 -0
- package/dist/esm/event/selection/index.js +9 -0
- package/dist/esm/event/selection/modifySelection.js +26 -0
- package/dist/esm/event/selection/modifySelectionPerMouse.js +45 -0
- package/dist/esm/event/selection/moveSelection.js +43 -0
- package/dist/esm/{utils/focus → event/selection}/resolveCaretPosition.js +11 -19
- package/dist/esm/event/selection/selectAll.js +42 -0
- package/dist/esm/event/selection/setSelection.js +26 -0
- package/dist/esm/event/selection/setSelectionPerMouse.js +86 -0
- package/dist/esm/event/selection/setSelectionRange.js +36 -0
- package/dist/esm/event/selection/updateSelectionOnFocus.js +41 -0
- package/dist/esm/keyboard/index.js +13 -23
- package/dist/esm/keyboard/parseKeyDef.js +8 -13
- package/dist/esm/options.js +1 -26
- package/dist/esm/pointer/index.js +28 -34
- package/dist/esm/pointer/parseKeyDef.js +1 -9
- package/dist/esm/setup/directApi.js +6 -6
- package/dist/esm/setup/index.js +0 -1
- package/dist/esm/setup/setup.js +63 -33
- package/dist/esm/system/index.js +4 -2
- package/dist/esm/system/keyboard.js +32 -32
- package/dist/esm/system/pointer/buttons.js +3 -1
- package/dist/esm/system/pointer/device.js +3 -1
- package/dist/esm/system/pointer/index.js +83 -79
- package/dist/esm/system/pointer/mouse.js +95 -79
- package/dist/esm/system/pointer/pointer.js +44 -45
- package/dist/esm/system/pointer/shared.js +6 -0
- package/dist/esm/utility/clear.js +10 -11
- package/dist/esm/utility/selectOptions.js +17 -19
- package/dist/esm/utility/type.js +6 -15
- package/dist/esm/utility/upload.js +9 -15
- package/dist/esm/utils/dataTransfer/Clipboard.js +11 -21
- package/dist/esm/utils/dataTransfer/DataTransfer.js +22 -19
- package/dist/esm/utils/edit/isEditable.js +4 -8
- package/dist/esm/utils/edit/maxLength.js +5 -16
- package/dist/esm/utils/edit/setFiles.js +4 -2
- package/dist/esm/utils/edit/{buildTimeValue.js → timeValue.js} +6 -1
- package/dist/esm/utils/focus/cursor.js +2 -17
- package/dist/esm/utils/focus/getActiveElement.js +3 -2
- package/dist/esm/utils/focus/selection.js +3 -260
- package/dist/esm/utils/index.js +4 -11
- package/dist/esm/utils/keyDef/readNextDescriptor.js +5 -3
- package/dist/esm/utils/misc/isDisabled.js +2 -1
- package/dist/esm/utils/misc/isVisible.js +1 -1
- package/dist/esm/utils/misc/level.js +4 -6
- package/dist/esm/utils/pointer/cssPointerEvents.js +26 -32
- 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/document/UI.d.ts +42 -0
- package/dist/types/{utils/focus → document}/copySelection.d.ts +0 -0
- package/dist/types/document/getValueOrTextContent.d.ts +1 -0
- package/dist/types/document/index.d.ts +5 -10
- package/dist/types/document/interceptor.d.ts +3 -0
- package/dist/types/document/prepareDocument.d.ts +8 -0
- package/dist/types/document/trackValue.d.ts +17 -0
- package/dist/types/event/behavior/registry.d.ts +2 -2
- package/dist/types/event/dispatchEvent.d.ts +5 -2
- package/dist/types/event/focus.d.ts +5 -0
- package/dist/types/event/index.d.ts +6 -4
- package/dist/types/event/input.d.ts +2 -0
- package/dist/types/event/radio.d.ts +4 -0
- package/dist/types/event/selection/getInputRange.d.ts +5 -0
- package/dist/types/event/selection/getTargetTypeAndSelection.d.ts +10 -0
- package/dist/types/event/selection/index.d.ts +15 -0
- package/dist/types/event/selection/modifySelection.d.ts +8 -0
- package/dist/types/event/selection/modifySelectionPerMouse.d.ts +7 -0
- package/dist/types/event/selection/moveSelection.d.ts +4 -0
- package/dist/types/{utils/focus → event/selection}/resolveCaretPosition.d.ts +0 -0
- package/dist/types/{utils/focus → event/selection}/selectAll.d.ts +0 -0
- package/dist/types/event/selection/setSelection.d.ts +10 -0
- package/dist/types/event/selection/setSelectionPerMouse.d.ts +8 -0
- package/dist/types/event/selection/setSelectionRange.d.ts +6 -0
- package/dist/types/event/selection/updateSelectionOnFocus.d.ts +5 -0
- package/dist/types/keyboard/index.d.ts +2 -2
- package/dist/types/options.d.ts +0 -8
- package/dist/types/pointer/index.d.ts +3 -3
- package/dist/types/setup/directApi.d.ts +1 -1
- package/dist/types/setup/index.d.ts +2 -15
- package/dist/types/setup/setup.d.ts +25 -7
- package/dist/types/system/keyboard.d.ts +3 -3
- package/dist/types/system/pointer/buttons.d.ts +1 -1
- package/dist/types/system/pointer/index.d.ts +7 -25
- package/dist/types/system/pointer/mouse.d.ts +5 -5
- package/dist/types/system/pointer/pointer.d.ts +7 -7
- package/dist/types/system/pointer/shared.d.ts +20 -0
- 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 +3 -3
- package/dist/types/utility/upload.d.ts +1 -1
- package/dist/types/utils/click/isClickableInput.d.ts +2 -2
- package/dist/types/utils/edit/isEditable.d.ts +5 -6
- package/dist/types/utils/edit/maxLength.d.ts +14 -1
- package/dist/types/utils/edit/{isValidDateOrTimeValue.d.ts → timeValue.d.ts} +1 -0
- package/dist/types/utils/focus/selection.d.ts +4 -69
- package/dist/types/utils/index.d.ts +2 -9
- package/dist/types/utils/misc/level.d.ts +4 -13
- package/dist/types/utils/misc/wait.d.ts +2 -2
- package/dist/types/utils/pointer/cssPointerEvents.d.ts +4 -4
- package/package.json +29 -4
- package/dist/cjs/document/selection.js +0 -107
- package/dist/cjs/document/setRangeText.js +0 -21
- package/dist/cjs/document/value.js +0 -125
- package/dist/cjs/setup/config.js +0 -7
- package/dist/cjs/utils/edit/getValue.js +0 -35
- package/dist/cjs/utils/edit/isValidDateOrTimeValue.js +0 -11
- package/dist/cjs/utils/focus/blur.js +0 -16
- package/dist/cjs/utils/focus/copySelection.js +0 -46
- package/dist/cjs/utils/focus/focus.js +0 -26
- package/dist/cjs/utils/focus/selectAll.js +0 -54
- package/dist/cjs/utils/misc/eventWrapper.js +0 -15
- package/dist/esm/document/selection.js +0 -99
- package/dist/esm/document/setRangeText.js +0 -17
- package/dist/esm/document/value.js +0 -115
- package/dist/esm/setup/config.js +0 -3
- package/dist/esm/utils/edit/getValue.js +0 -31
- package/dist/esm/utils/edit/isValidDateOrTimeValue.js +0 -7
- package/dist/esm/utils/focus/blur.js +0 -12
- package/dist/esm/utils/focus/copySelection.js +0 -42
- package/dist/esm/utils/focus/focus.js +0 -22
- package/dist/esm/utils/focus/selectAll.js +0 -49
- package/dist/esm/utils/misc/eventWrapper.js +0 -11
- package/dist/types/document/selection.d.ts +0 -29
- package/dist/types/document/setRangeText.d.ts +0 -1
- package/dist/types/document/value.d.ts +0 -26
- package/dist/types/setup/config.d.ts +0 -6
- package/dist/types/utils/edit/buildTimeValue.d.ts +0 -1
- package/dist/types/utils/edit/getValue.d.ts +0 -1
- package/dist/types/utils/edit/input.d.ts +0 -2
- package/dist/types/utils/edit/walkRadio.d.ts +0 -4
- package/dist/types/utils/focus/blur.d.ts +0 -2
- package/dist/types/utils/focus/focus.d.ts +0 -5
- package/dist/types/utils/misc/eventWrapper.d.ts +0 -1
|
@@ -2,127 +2,95 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
require('../../event/behavior/click.js');
|
|
6
|
+
require('../../event/behavior/cut.js');
|
|
7
|
+
require('../../event/behavior/keydown.js');
|
|
8
|
+
require('../../event/behavior/keypress.js');
|
|
9
|
+
require('../../event/behavior/keyup.js');
|
|
10
|
+
require('../../event/behavior/paste.js');
|
|
11
|
+
require('@testing-library/dom');
|
|
12
|
+
require('../../event/eventMap.js');
|
|
6
13
|
require('../../utils/click/isClickableInput.js');
|
|
7
14
|
require('../../utils/dataTransfer/Clipboard.js');
|
|
8
|
-
require('../../utils/edit/maxLength.js');
|
|
9
15
|
require('../../utils/edit/isEditable.js');
|
|
10
|
-
|
|
11
|
-
require('@testing-library/dom/dist/helpers.js');
|
|
16
|
+
require('../../utils/edit/maxLength.js');
|
|
12
17
|
var isDisabled = require('../../utils/misc/isDisabled.js');
|
|
13
|
-
require('@testing-library/dom');
|
|
14
|
-
var selection = require('../../utils/focus/selection.js');
|
|
18
|
+
require('@testing-library/dom/dist/helpers.js');
|
|
15
19
|
require('../../utils/keyDef/readNextDescriptor.js');
|
|
16
20
|
var getTreeDiff = require('../../utils/misc/getTreeDiff.js');
|
|
17
21
|
require('../../utils/misc/level.js');
|
|
18
22
|
require('../../options.js');
|
|
19
|
-
var
|
|
23
|
+
var focus = require('../../event/focus.js');
|
|
24
|
+
var setSelectionPerMouse = require('../../event/selection/setSelectionPerMouse.js');
|
|
25
|
+
var modifySelectionPerMouse = require('../../event/selection/modifySelectionPerMouse.js');
|
|
20
26
|
var buttons = require('./buttons.js');
|
|
27
|
+
var shared = require('./shared.js');
|
|
21
28
|
|
|
22
29
|
/**
|
|
23
30
|
* This object is the single "virtual" mouse that might be controlled by multiple different pointer devices.
|
|
24
31
|
*/ class Mouse {
|
|
25
|
-
position
|
|
26
|
-
buttons = new buttons.Buttons();
|
|
27
|
-
buttonDownTarget = {};
|
|
28
|
-
// According to spec the `detail` on click events should be the number
|
|
29
|
-
// of *consecutive* clicks with a specific button.
|
|
30
|
-
// On `mousedown` and `mouseup` it should be this number increased by one.
|
|
31
|
-
// But the browsers don't implement it this way.
|
|
32
|
-
// If another button is pressed,
|
|
33
|
-
// in Webkit: the `mouseup` on the previously pressed button has `detail: 0` and no `click`/`auxclick`.
|
|
34
|
-
// in Gecko: the `mouseup` and click events have the same detail as the `mousedown`.
|
|
35
|
-
// If there is a delay while a button is pressed,
|
|
36
|
-
// the `mouseup` and `click` are normal, but a following `mousedown` starts a new click count.
|
|
37
|
-
// We'll follow the minimal implementation of Webkit.
|
|
38
|
-
clickCount = new class {
|
|
39
|
-
down = {};
|
|
40
|
-
count = {};
|
|
41
|
-
incOnClick(button) {
|
|
42
|
-
const current = this.down[button] === undefined ? undefined : Number(this.down[button]) + 1;
|
|
43
|
-
this.count = this.count[button] === undefined ? {} : {
|
|
44
|
-
[button]: Number(this.count[button]) + 1
|
|
45
|
-
};
|
|
46
|
-
return current;
|
|
47
|
-
}
|
|
48
|
-
getOnDown(button) {
|
|
49
|
-
this.down = {
|
|
50
|
-
[button]: this.count[button] ?? 0
|
|
51
|
-
};
|
|
52
|
-
this.count = {
|
|
53
|
-
[button]: this.count[button] ?? 0
|
|
54
|
-
};
|
|
55
|
-
return Number(this.count[button]) + 1;
|
|
56
|
-
}
|
|
57
|
-
getOnUp(button) {
|
|
58
|
-
return this.down[button] === undefined ? undefined : Number(this.down[button]) + 1;
|
|
59
|
-
}
|
|
60
|
-
reset() {
|
|
61
|
-
this.count = {};
|
|
62
|
-
}
|
|
63
|
-
}();
|
|
64
|
-
move(config, position) {
|
|
32
|
+
move(instance, position) {
|
|
65
33
|
const prevPosition = this.position;
|
|
66
|
-
const prevTarget = this.getTarget(
|
|
34
|
+
const prevTarget = this.getTarget(instance);
|
|
67
35
|
this.position = position;
|
|
68
|
-
if (!
|
|
36
|
+
if (!shared.isDifferentPointerPosition(prevPosition, position)) {
|
|
69
37
|
return;
|
|
70
38
|
}
|
|
71
|
-
const nextTarget = this.getTarget(
|
|
39
|
+
const nextTarget = this.getTarget(instance);
|
|
72
40
|
const init = this.getEventInit('mousemove');
|
|
73
41
|
const [leave, enter] = getTreeDiff.getTreeDiff(prevTarget, nextTarget);
|
|
74
42
|
return {
|
|
75
43
|
leave: ()=>{
|
|
76
44
|
if (prevTarget !== nextTarget) {
|
|
77
|
-
|
|
78
|
-
leave.forEach((el)=>
|
|
45
|
+
instance.dispatchUIEvent(prevTarget, 'mouseout', init);
|
|
46
|
+
leave.forEach((el)=>instance.dispatchUIEvent(el, 'mouseleave', init));
|
|
79
47
|
}
|
|
80
48
|
},
|
|
81
49
|
enter: ()=>{
|
|
82
50
|
if (prevTarget !== nextTarget) {
|
|
83
|
-
|
|
84
|
-
enter.forEach((el)=>
|
|
51
|
+
instance.dispatchUIEvent(nextTarget, 'mouseover', init);
|
|
52
|
+
enter.forEach((el)=>instance.dispatchUIEvent(el, 'mouseenter', init));
|
|
85
53
|
}
|
|
86
54
|
},
|
|
87
55
|
move: ()=>{
|
|
88
|
-
|
|
89
|
-
this.modifySelecting(
|
|
56
|
+
instance.dispatchUIEvent(nextTarget, 'mousemove', init);
|
|
57
|
+
this.modifySelecting(instance);
|
|
90
58
|
}
|
|
91
59
|
};
|
|
92
60
|
}
|
|
93
|
-
down(
|
|
61
|
+
down(instance, keyDef, pointer) {
|
|
94
62
|
const button = this.buttons.down(keyDef);
|
|
95
63
|
if (button === undefined) {
|
|
96
64
|
return;
|
|
97
65
|
}
|
|
98
|
-
const target = this.getTarget(
|
|
66
|
+
const target = this.getTarget(instance);
|
|
99
67
|
this.buttonDownTarget[button] = target;
|
|
100
68
|
const disabled = isDisabled.isDisabled(target);
|
|
101
69
|
const init = this.getEventInit('mousedown', keyDef.button);
|
|
102
|
-
if (disabled ||
|
|
103
|
-
this.startSelecting(
|
|
104
|
-
focus.
|
|
70
|
+
if (disabled || instance.dispatchUIEvent(target, 'mousedown', init)) {
|
|
71
|
+
this.startSelecting(instance, init.detail);
|
|
72
|
+
focus.focusElement(target);
|
|
105
73
|
}
|
|
106
74
|
if (!disabled && buttons.getMouseEventButton(keyDef.button) === 2) {
|
|
107
|
-
|
|
75
|
+
instance.dispatchUIEvent(target, 'contextmenu', this.getEventInit('contextmenu', keyDef.button, pointer));
|
|
108
76
|
}
|
|
109
77
|
}
|
|
110
|
-
up(
|
|
78
|
+
up(instance, keyDef, pointer) {
|
|
111
79
|
const button = this.buttons.up(keyDef);
|
|
112
80
|
if (button === undefined) {
|
|
113
81
|
return;
|
|
114
82
|
}
|
|
115
|
-
const target = this.getTarget(
|
|
83
|
+
const target = this.getTarget(instance);
|
|
116
84
|
if (!isDisabled.isDisabled(target)) {
|
|
117
|
-
|
|
85
|
+
instance.dispatchUIEvent(target, 'mouseup', this.getEventInit('mouseup', keyDef.button));
|
|
118
86
|
this.endSelecting();
|
|
119
87
|
const clickTarget = getTreeDiff.getTreeDiff(this.buttonDownTarget[button], target)[2][0];
|
|
120
88
|
if (clickTarget) {
|
|
121
89
|
const init = this.getEventInit('click', keyDef.button, pointer);
|
|
122
90
|
if (init.detail) {
|
|
123
|
-
|
|
91
|
+
instance.dispatchUIEvent(clickTarget, init.button === 0 ? 'click' : 'auxclick', init);
|
|
124
92
|
if (init.button === 0 && init.detail === 2) {
|
|
125
|
-
|
|
93
|
+
instance.dispatchUIEvent(clickTarget, 'dblclick', {
|
|
126
94
|
...this.getEventInit('dblclick', keyDef.button),
|
|
127
95
|
detail: init.detail
|
|
128
96
|
});
|
|
@@ -154,33 +122,81 @@ var buttons = require('./buttons.js');
|
|
|
154
122
|
}
|
|
155
123
|
return init;
|
|
156
124
|
}
|
|
157
|
-
getTarget(
|
|
158
|
-
|
|
125
|
+
getTarget(instance) {
|
|
126
|
+
var _target;
|
|
127
|
+
return (_target = this.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
|
|
159
128
|
}
|
|
160
|
-
startSelecting(
|
|
129
|
+
startSelecting(instance, clickCount) {
|
|
130
|
+
var ref, ref1;
|
|
161
131
|
// TODO: support extending range (shift)
|
|
162
|
-
this.selecting =
|
|
163
|
-
document: config.document,
|
|
164
|
-
target: this.getTarget(
|
|
165
|
-
node: this.position.caret
|
|
166
|
-
offset: this.position.caret
|
|
132
|
+
this.selecting = setSelectionPerMouse.setSelectionPerMouseDown({
|
|
133
|
+
document: instance.config.document,
|
|
134
|
+
target: this.getTarget(instance),
|
|
135
|
+
node: (ref = this.position.caret) === null || ref === void 0 ? void 0 : ref.node,
|
|
136
|
+
offset: (ref1 = this.position.caret) === null || ref1 === void 0 ? void 0 : ref1.offset,
|
|
167
137
|
clickCount
|
|
168
138
|
});
|
|
169
139
|
}
|
|
170
|
-
modifySelecting(
|
|
140
|
+
modifySelecting(instance) {
|
|
141
|
+
var ref, ref1;
|
|
171
142
|
if (!this.selecting) {
|
|
172
143
|
return;
|
|
173
144
|
}
|
|
174
|
-
|
|
175
|
-
document: config.document,
|
|
176
|
-
target: this.getTarget(
|
|
177
|
-
node: this.position.caret
|
|
178
|
-
offset: this.position.caret
|
|
145
|
+
modifySelectionPerMouse.modifySelectionPerMouseMove(this.selecting, {
|
|
146
|
+
document: instance.config.document,
|
|
147
|
+
target: this.getTarget(instance),
|
|
148
|
+
node: (ref = this.position.caret) === null || ref === void 0 ? void 0 : ref.node,
|
|
149
|
+
offset: (ref1 = this.position.caret) === null || ref1 === void 0 ? void 0 : ref1.offset
|
|
179
150
|
});
|
|
180
151
|
}
|
|
181
152
|
endSelecting() {
|
|
182
153
|
this.selecting = undefined;
|
|
183
154
|
}
|
|
155
|
+
constructor(){
|
|
156
|
+
this.position = {};
|
|
157
|
+
this.buttons = new buttons.Buttons();
|
|
158
|
+
this.buttonDownTarget = {};
|
|
159
|
+
// According to spec the `detail` on click events should be the number
|
|
160
|
+
// of *consecutive* clicks with a specific button.
|
|
161
|
+
// On `mousedown` and `mouseup` it should be this number increased by one.
|
|
162
|
+
// But the browsers don't implement it this way.
|
|
163
|
+
// If another button is pressed,
|
|
164
|
+
// in Webkit: the `mouseup` on the previously pressed button has `detail: 0` and no `click`/`auxclick`.
|
|
165
|
+
// in Gecko: the `mouseup` and click events have the same detail as the `mousedown`.
|
|
166
|
+
// If there is a delay while a button is pressed,
|
|
167
|
+
// the `mouseup` and `click` are normal, but a following `mousedown` starts a new click count.
|
|
168
|
+
// We'll follow the minimal implementation of Webkit.
|
|
169
|
+
this.clickCount = new class {
|
|
170
|
+
incOnClick(button) {
|
|
171
|
+
const current = this.down[button] === undefined ? undefined : Number(this.down[button]) + 1;
|
|
172
|
+
this.count = this.count[button] === undefined ? {} : {
|
|
173
|
+
[button]: Number(this.count[button]) + 1
|
|
174
|
+
};
|
|
175
|
+
return current;
|
|
176
|
+
}
|
|
177
|
+
getOnDown(button) {
|
|
178
|
+
var _button;
|
|
179
|
+
this.down = {
|
|
180
|
+
[button]: (_button = this.count[button]) !== null && _button !== void 0 ? _button : 0
|
|
181
|
+
};
|
|
182
|
+
var _button1;
|
|
183
|
+
this.count = {
|
|
184
|
+
[button]: (_button1 = this.count[button]) !== null && _button1 !== void 0 ? _button1 : 0
|
|
185
|
+
};
|
|
186
|
+
return Number(this.count[button]) + 1;
|
|
187
|
+
}
|
|
188
|
+
getOnUp(button) {
|
|
189
|
+
return this.down[button] === undefined ? undefined : Number(this.down[button]) + 1;
|
|
190
|
+
}
|
|
191
|
+
reset() {
|
|
192
|
+
this.count = {};
|
|
193
|
+
}
|
|
194
|
+
constructor(){
|
|
195
|
+
this.down = {};
|
|
196
|
+
this.count = {};
|
|
197
|
+
}
|
|
198
|
+
}();
|
|
199
|
+
}
|
|
184
200
|
}
|
|
185
201
|
|
|
186
202
|
exports.Mouse = Mouse;
|
|
@@ -2,104 +2,92 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('../../event/index.js');
|
|
6
5
|
require('../../utils/click/isClickableInput.js');
|
|
7
6
|
require('../../utils/dataTransfer/Clipboard.js');
|
|
8
|
-
require('../../utils/edit/maxLength.js');
|
|
9
7
|
require('../../utils/edit/isEditable.js');
|
|
10
|
-
require('
|
|
8
|
+
require('../../utils/edit/maxLength.js');
|
|
11
9
|
require('@testing-library/dom/dist/helpers.js');
|
|
12
10
|
require('../../utils/keyDef/readNextDescriptor.js');
|
|
13
11
|
var getTreeDiff = require('../../utils/misc/getTreeDiff.js');
|
|
14
12
|
require('../../utils/misc/level.js');
|
|
15
13
|
var cssPointerEvents = require('../../utils/pointer/cssPointerEvents.js');
|
|
16
|
-
var
|
|
14
|
+
var shared = require('./shared.js');
|
|
17
15
|
|
|
18
16
|
class Pointer {
|
|
19
|
-
|
|
20
|
-
this.pointerId = pointerId;
|
|
21
|
-
this.pointerType = pointerType;
|
|
22
|
-
this.isPrimary = isPrimary;
|
|
23
|
-
this.isMultitouch = !isPrimary;
|
|
24
|
-
}
|
|
25
|
-
isMultitouch = false;
|
|
26
|
-
isCancelled = false;
|
|
27
|
-
isDown = false;
|
|
28
|
-
isPrevented = false;
|
|
29
|
-
position = {};
|
|
30
|
-
init(config, position) {
|
|
17
|
+
init(instance, position) {
|
|
31
18
|
this.position = position;
|
|
32
|
-
const target = this.getTarget(
|
|
19
|
+
const target = this.getTarget(instance);
|
|
33
20
|
const [, enter] = getTreeDiff.getTreeDiff(null, target);
|
|
34
21
|
const init = this.getEventInit();
|
|
35
|
-
cssPointerEvents.assertPointerEvents(
|
|
36
|
-
|
|
37
|
-
enter.forEach((el)=>
|
|
22
|
+
cssPointerEvents.assertPointerEvents(instance, target);
|
|
23
|
+
instance.dispatchUIEvent(target, 'pointerover', init);
|
|
24
|
+
enter.forEach((el)=>instance.dispatchUIEvent(el, 'pointerenter', init));
|
|
38
25
|
return this;
|
|
39
26
|
}
|
|
40
|
-
move(
|
|
27
|
+
move(instance, position) {
|
|
41
28
|
const prevPosition = this.position;
|
|
42
|
-
const prevTarget = this.getTarget(
|
|
29
|
+
const prevTarget = this.getTarget(instance);
|
|
43
30
|
this.position = position;
|
|
44
|
-
if (!
|
|
31
|
+
if (!shared.isDifferentPointerPosition(prevPosition, position)) {
|
|
45
32
|
return;
|
|
46
33
|
}
|
|
47
|
-
const nextTarget = this.getTarget(
|
|
34
|
+
const nextTarget = this.getTarget(instance);
|
|
48
35
|
const init = this.getEventInit();
|
|
49
36
|
const [leave, enter] = getTreeDiff.getTreeDiff(prevTarget, nextTarget);
|
|
50
37
|
return {
|
|
51
38
|
leave: ()=>{
|
|
52
|
-
if (cssPointerEvents.hasPointerEvents(
|
|
39
|
+
if (cssPointerEvents.hasPointerEvents(instance, prevTarget)) {
|
|
53
40
|
if (prevTarget !== nextTarget) {
|
|
54
|
-
|
|
55
|
-
leave.forEach((el)=>
|
|
41
|
+
instance.dispatchUIEvent(prevTarget, 'pointerout', init);
|
|
42
|
+
leave.forEach((el)=>instance.dispatchUIEvent(el, 'pointerleave', init));
|
|
56
43
|
}
|
|
57
44
|
}
|
|
58
45
|
},
|
|
59
46
|
enter: ()=>{
|
|
60
|
-
cssPointerEvents.assertPointerEvents(
|
|
47
|
+
cssPointerEvents.assertPointerEvents(instance, nextTarget);
|
|
61
48
|
if (prevTarget !== nextTarget) {
|
|
62
|
-
|
|
63
|
-
enter.forEach((el)=>
|
|
49
|
+
instance.dispatchUIEvent(nextTarget, 'pointerover', init);
|
|
50
|
+
enter.forEach((el)=>instance.dispatchUIEvent(el, 'pointerenter', init));
|
|
64
51
|
}
|
|
65
52
|
},
|
|
66
53
|
move: ()=>{
|
|
67
|
-
|
|
54
|
+
instance.dispatchUIEvent(nextTarget, 'pointermove', init);
|
|
68
55
|
}
|
|
69
56
|
};
|
|
70
57
|
}
|
|
71
|
-
down(
|
|
58
|
+
down(instance, _keyDef) {
|
|
72
59
|
if (this.isDown) {
|
|
73
60
|
return;
|
|
74
61
|
}
|
|
75
|
-
const target = this.getTarget(
|
|
76
|
-
cssPointerEvents.assertPointerEvents(
|
|
62
|
+
const target = this.getTarget(instance);
|
|
63
|
+
cssPointerEvents.assertPointerEvents(instance, target);
|
|
77
64
|
this.isDown = true;
|
|
78
|
-
this.isPrevented = !
|
|
65
|
+
this.isPrevented = !instance.dispatchUIEvent(target, 'pointerdown', this.getEventInit());
|
|
79
66
|
}
|
|
80
|
-
up(
|
|
67
|
+
up(instance, _keyDef) {
|
|
81
68
|
if (!this.isDown) {
|
|
82
69
|
return;
|
|
83
70
|
}
|
|
84
|
-
const target = this.getTarget(
|
|
85
|
-
cssPointerEvents.assertPointerEvents(
|
|
71
|
+
const target = this.getTarget(instance);
|
|
72
|
+
cssPointerEvents.assertPointerEvents(instance, target);
|
|
86
73
|
this.isDown = false;
|
|
87
|
-
|
|
74
|
+
instance.dispatchUIEvent(target, 'pointerup', this.getEventInit());
|
|
88
75
|
}
|
|
89
|
-
release(
|
|
90
|
-
const target = this.getTarget(
|
|
76
|
+
release(instance) {
|
|
77
|
+
const target = this.getTarget(instance);
|
|
91
78
|
const [leave] = getTreeDiff.getTreeDiff(target, null);
|
|
92
79
|
const init = this.getEventInit();
|
|
93
80
|
// Currently there is no PointerEventsCheckLevel that would
|
|
94
81
|
// make this check not use the *asserted* cached value from `up`.
|
|
95
|
-
/* istanbul ignore else */ if (cssPointerEvents.hasPointerEvents(
|
|
96
|
-
|
|
97
|
-
leave.forEach((el)=>
|
|
82
|
+
/* istanbul ignore else */ if (cssPointerEvents.hasPointerEvents(instance, target)) {
|
|
83
|
+
instance.dispatchUIEvent(target, 'pointerout', init);
|
|
84
|
+
leave.forEach((el)=>instance.dispatchUIEvent(el, 'pointerleave', init));
|
|
98
85
|
}
|
|
99
86
|
this.isCancelled = true;
|
|
100
87
|
}
|
|
101
|
-
getTarget(
|
|
102
|
-
|
|
88
|
+
getTarget(instance) {
|
|
89
|
+
var _target;
|
|
90
|
+
return (_target = this.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
|
|
103
91
|
}
|
|
104
92
|
getEventInit() {
|
|
105
93
|
return {
|
|
@@ -109,6 +97,17 @@ class Pointer {
|
|
|
109
97
|
isPrimary: this.isPrimary
|
|
110
98
|
};
|
|
111
99
|
}
|
|
100
|
+
constructor({ pointerId , pointerType , isPrimary }){
|
|
101
|
+
this.isMultitouch = false;
|
|
102
|
+
this.isCancelled = false;
|
|
103
|
+
this.isDown = false;
|
|
104
|
+
this.isPrevented = false;
|
|
105
|
+
this.position = {};
|
|
106
|
+
this.pointerId = pointerId;
|
|
107
|
+
this.pointerType = pointerType;
|
|
108
|
+
this.isPrimary = isPrimary;
|
|
109
|
+
this.isMultitouch = !isPrimary;
|
|
110
|
+
}
|
|
112
111
|
}
|
|
113
112
|
|
|
114
113
|
exports.Pointer = Pointer;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
function isDifferentPointerPosition(positionA, positionB) {
|
|
6
|
+
var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
|
|
7
|
+
return positionA.target !== positionB.target || ((ref = positionA.coords) === null || ref === void 0 ? void 0 : ref.x) !== ((ref1 = positionB.coords) === null || ref1 === void 0 ? void 0 : ref1.y) || ((ref2 = positionA.coords) === null || ref2 === void 0 ? void 0 : ref2.y) !== ((ref3 = positionB.coords) === null || ref3 === void 0 ? void 0 : ref3.y) || ((ref4 = positionA.caret) === null || ref4 === void 0 ? void 0 : ref4.node) !== ((ref5 = positionB.caret) === null || ref5 === void 0 ? void 0 : ref5.node) || ((ref6 = positionA.caret) === null || ref6 === void 0 ? void 0 : ref6.offset) !== ((ref7 = positionB.caret) === null || ref7 === void 0 ? void 0 : ref7.offset);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
exports.isDifferentPointerPosition = isDifferentPointerPosition;
|
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
require('../setup/index.js');
|
|
6
|
-
require('../utils/click/isClickableInput.js');
|
|
7
|
-
require('../utils/dataTransfer/Clipboard.js');
|
|
8
|
-
require('../event/eventMap.js');
|
|
9
5
|
require('../event/behavior/click.js');
|
|
10
6
|
require('../event/behavior/cut.js');
|
|
11
7
|
require('../event/behavior/keydown.js');
|
|
@@ -13,22 +9,25 @@ require('../event/behavior/keypress.js');
|
|
|
13
9
|
require('../event/behavior/keyup.js');
|
|
14
10
|
require('../event/behavior/paste.js');
|
|
15
11
|
require('@testing-library/dom');
|
|
16
|
-
|
|
12
|
+
require('../event/eventMap.js');
|
|
13
|
+
require('../utils/click/isClickableInput.js');
|
|
14
|
+
require('../utils/dataTransfer/Clipboard.js');
|
|
17
15
|
var isEditable = require('../utils/edit/isEditable.js');
|
|
18
|
-
|
|
19
|
-
require('@testing-library/dom/dist/helpers.js');
|
|
16
|
+
require('../utils/edit/maxLength.js');
|
|
20
17
|
var isDisabled = require('../utils/misc/isDisabled.js');
|
|
21
|
-
|
|
18
|
+
require('@testing-library/dom/dist/helpers.js');
|
|
22
19
|
require('../utils/keyDef/readNextDescriptor.js');
|
|
23
20
|
require('../utils/misc/level.js');
|
|
24
21
|
require('../options.js');
|
|
25
|
-
var
|
|
22
|
+
var focus = require('../event/focus.js');
|
|
23
|
+
var input = require('../event/input.js');
|
|
24
|
+
var selectAll = require('../event/selection/selectAll.js');
|
|
26
25
|
|
|
27
26
|
async function clear(element) {
|
|
28
27
|
if (!isEditable.isEditable(element) || isDisabled.isDisabled(element)) {
|
|
29
28
|
throw new Error('clear()` is only supported on editable elements.');
|
|
30
29
|
}
|
|
31
|
-
focus.
|
|
30
|
+
focus.focusElement(element);
|
|
32
31
|
if (element.ownerDocument.activeElement !== element) {
|
|
33
32
|
throw new Error('The element to be cleared could not be focused.');
|
|
34
33
|
}
|
|
@@ -36,7 +35,7 @@ async function clear(element) {
|
|
|
36
35
|
if (!selectAll.isAllSelected(element)) {
|
|
37
36
|
throw new Error('The element content to be cleared could not be selected.');
|
|
38
37
|
}
|
|
39
|
-
input.input(this
|
|
38
|
+
input.input(this, element, '', 'deleteContentBackward');
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
exports.clear = clear;
|
|
@@ -5,25 +5,23 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var dom = require('@testing-library/dom');
|
|
6
6
|
require('../utils/click/isClickableInput.js');
|
|
7
7
|
require('../utils/dataTransfer/Clipboard.js');
|
|
8
|
-
require('../event/eventMap.js');
|
|
9
|
-
require('../event/behavior/click.js');
|
|
10
|
-
require('../event/behavior/cut.js');
|
|
11
|
-
require('../event/behavior/keydown.js');
|
|
12
|
-
require('../event/behavior/keypress.js');
|
|
13
|
-
require('../event/behavior/keyup.js');
|
|
14
|
-
require('../event/behavior/paste.js');
|
|
15
|
-
require('../utils/edit/maxLength.js');
|
|
16
8
|
require('../utils/edit/isEditable.js');
|
|
17
|
-
|
|
18
|
-
require('@testing-library/dom/dist/helpers.js');
|
|
19
|
-
var isDisabled = require('../utils/misc/isDisabled.js');
|
|
9
|
+
require('../utils/edit/maxLength.js');
|
|
20
10
|
var isElementType = require('../utils/misc/isElementType.js');
|
|
11
|
+
var isDisabled = require('../utils/misc/isDisabled.js');
|
|
12
|
+
require('@testing-library/dom/dist/helpers.js');
|
|
21
13
|
require('../utils/keyDef/readNextDescriptor.js');
|
|
22
14
|
require('../utils/misc/level.js');
|
|
23
15
|
var wait = require('../utils/misc/wait.js');
|
|
24
16
|
var cssPointerEvents = require('../utils/pointer/cssPointerEvents.js');
|
|
25
|
-
require('../
|
|
26
|
-
|
|
17
|
+
require('../event/behavior/click.js');
|
|
18
|
+
require('../event/behavior/cut.js');
|
|
19
|
+
require('../event/behavior/keydown.js');
|
|
20
|
+
require('../event/behavior/keypress.js');
|
|
21
|
+
require('../event/behavior/keyup.js');
|
|
22
|
+
require('../event/behavior/paste.js');
|
|
23
|
+
require('../event/eventMap.js');
|
|
24
|
+
var focus = require('../event/focus.js');
|
|
27
25
|
|
|
28
26
|
async function selectOptions(select, values) {
|
|
29
27
|
return selectOptionsBase.call(this, true, select, values);
|
|
@@ -64,7 +62,7 @@ async function selectOptionsBase(newValue, select, values) {
|
|
|
64
62
|
if (isElementType.isElementType(select, 'select')) {
|
|
65
63
|
if (select.multiple) {
|
|
66
64
|
for (const option of selectedOptions){
|
|
67
|
-
const withPointerEvents = this
|
|
65
|
+
const withPointerEvents = this.config.pointerEventsCheck === 0 ? true : cssPointerEvents.hasPointerEvents(this, option);
|
|
68
66
|
// events fired for multiple select are weird. Can't use hover...
|
|
69
67
|
if (withPointerEvents) {
|
|
70
68
|
this.dispatchUIEvent(option, 'pointerover');
|
|
@@ -76,7 +74,7 @@ async function selectOptionsBase(newValue, select, values) {
|
|
|
76
74
|
this.dispatchUIEvent(option, 'pointerdown');
|
|
77
75
|
this.dispatchUIEvent(option, 'mousedown');
|
|
78
76
|
}
|
|
79
|
-
focus.
|
|
77
|
+
focus.focusElement(select);
|
|
80
78
|
if (withPointerEvents) {
|
|
81
79
|
this.dispatchUIEvent(option, 'pointerup');
|
|
82
80
|
this.dispatchUIEvent(option, 'mouseup');
|
|
@@ -85,15 +83,15 @@ async function selectOptionsBase(newValue, select, values) {
|
|
|
85
83
|
if (withPointerEvents) {
|
|
86
84
|
this.dispatchUIEvent(option, 'click');
|
|
87
85
|
}
|
|
88
|
-
await wait.wait(this
|
|
86
|
+
await wait.wait(this.config);
|
|
89
87
|
}
|
|
90
88
|
} else if (selectedOptions.length === 1) {
|
|
91
|
-
const withPointerEvents1 = this
|
|
89
|
+
const withPointerEvents1 = this.config.pointerEventsCheck === 0 ? true : cssPointerEvents.hasPointerEvents(this, select);
|
|
92
90
|
// the click to open the select options
|
|
93
91
|
if (withPointerEvents1) {
|
|
94
92
|
await this.click(select);
|
|
95
93
|
} else {
|
|
96
|
-
focus.
|
|
94
|
+
focus.focusElement(select);
|
|
97
95
|
}
|
|
98
96
|
selectOption(selectedOptions[0]);
|
|
99
97
|
if (withPointerEvents1) {
|
|
@@ -107,7 +105,7 @@ async function selectOptionsBase(newValue, select, values) {
|
|
|
107
105
|
this.dispatchUIEvent(select, 'mouseup');
|
|
108
106
|
this.dispatchUIEvent(select, 'click');
|
|
109
107
|
}
|
|
110
|
-
await wait.wait(this
|
|
108
|
+
await wait.wait(this.config);
|
|
111
109
|
} else {
|
|
112
110
|
throw dom.getConfig().getElementError(`Cannot select multiple options on a non-multiple select`, select);
|
|
113
111
|
}
|
package/dist/cjs/utility/type.js
CHANGED
|
@@ -2,27 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var index = require('../keyboard/index.js');
|
|
5
6
|
require('../utils/click/isClickableInput.js');
|
|
6
7
|
require('../utils/dataTransfer/Clipboard.js');
|
|
7
|
-
require('../event/eventMap.js');
|
|
8
|
-
require('../event/behavior/click.js');
|
|
9
|
-
require('../event/behavior/cut.js');
|
|
10
|
-
require('../event/behavior/keydown.js');
|
|
11
|
-
require('../event/behavior/keypress.js');
|
|
12
|
-
require('../event/behavior/keyup.js');
|
|
13
|
-
require('../event/behavior/paste.js');
|
|
14
|
-
require('@testing-library/dom');
|
|
15
|
-
require('../utils/edit/maxLength.js');
|
|
16
8
|
require('../utils/edit/isEditable.js');
|
|
17
|
-
|
|
9
|
+
require('../utils/edit/maxLength.js');
|
|
18
10
|
require('@testing-library/dom/dist/helpers.js');
|
|
19
11
|
require('../utils/keyDef/readNextDescriptor.js');
|
|
20
12
|
require('../utils/misc/level.js');
|
|
21
13
|
require('../options.js');
|
|
22
|
-
var
|
|
23
|
-
var config = require('../setup/config.js');
|
|
14
|
+
var setSelectionRange = require('../event/selection/setSelectionRange.js');
|
|
24
15
|
|
|
25
|
-
async function type(element, text, { skipClick =this
|
|
16
|
+
async function type(element, text, { skipClick =this.config.skipClick , skipAutoClose =this.config.skipAutoClose , initialSelectionStart , initialSelectionEnd } = {}) {
|
|
26
17
|
// TODO: properly type guard
|
|
27
18
|
// we use this workaround for now to prevent changing behavior
|
|
28
19
|
if (element.disabled) return;
|
|
@@ -30,11 +21,11 @@ async function type(element, text, { skipClick =this[config.Config].skipClick ,
|
|
|
30
21
|
await this.click(element);
|
|
31
22
|
}
|
|
32
23
|
if (initialSelectionStart !== undefined) {
|
|
33
|
-
|
|
24
|
+
setSelectionRange.setSelectionRange(element, initialSelectionStart, initialSelectionEnd !== null && initialSelectionEnd !== void 0 ? initialSelectionEnd : initialSelectionStart);
|
|
34
25
|
}
|
|
35
26
|
await this.keyboard(text);
|
|
36
27
|
if (!skipAutoClose) {
|
|
37
|
-
await index.releaseAllKeys(this
|
|
28
|
+
await index.releaseAllKeys(this);
|
|
38
29
|
}
|
|
39
30
|
}
|
|
40
31
|
|