@testing-library/user-event 14.5.2 → 14.6.0
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 +1 -7
- package/dist/cjs/event/behavior/cut.js +0 -5
- package/dist/cjs/event/behavior/keydown.js +3 -8
- 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 +34 -27
- 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 +0 -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/parseKeyDef.js +3 -8
- 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 +18 -20
- package/dist/cjs/system/pointer/mouse.js +8 -14
- package/dist/cjs/system/pointer/pointer.js +4 -9
- 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 +4 -10
- 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 +1 -1
- 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 +1 -7
- package/dist/esm/event/behavior/cut.js +0 -5
- package/dist/esm/event/behavior/keydown.js +3 -8
- 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 +34 -27
- 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 +0 -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/parseKeyDef.js +3 -8
- 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 +18 -20
- package/dist/esm/system/pointer/mouse.js +8 -14
- package/dist/esm/system/pointer/pointer.js +4 -9
- 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 +4 -10
- 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 +1 -1
- 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/system/keyboard.d.ts +1 -4
- package/dist/types/utils/dataTransfer/DataTransfer.d.ts +1 -1
- package/package.json +3 -3
package/dist/cjs/setup/setup.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var patchFocus = require('../document/patchFocus.js');
|
|
3
4
|
var prepareDocument = require('../document/prepareDocument.js');
|
|
4
5
|
var dispatchEvent = require('../event/dispatchEvent.js');
|
|
5
|
-
require('../utils/click/isClickableInput.js');
|
|
6
6
|
var Clipboard = require('../utils/dataTransfer/Clipboard.js');
|
|
7
|
-
require('../utils/
|
|
8
|
-
require('../utils/edit/maxLength.js');
|
|
9
|
-
require('../utils/keyDef/readNextDescriptor.js');
|
|
7
|
+
var getWindow = require('../utils/misc/getWindow.js');
|
|
10
8
|
var getDocumentFromNode = require('../utils/misc/getDocumentFromNode.js');
|
|
11
9
|
var level = require('../utils/misc/level.js');
|
|
12
10
|
var wait = require('../utils/misc/wait.js');
|
|
@@ -54,8 +52,9 @@ function createConfig(options = {}, defaults = defaultOptionsSetup, node) {
|
|
|
54
52
|
*/ function setupMain(options = {}) {
|
|
55
53
|
const config = createConfig(options);
|
|
56
54
|
prepareDocument.prepareDocument(config.document);
|
|
55
|
+
patchFocus.patchFocus(getWindow.getWindow(config.document).HTMLElement);
|
|
57
56
|
var _config_document_defaultView;
|
|
58
|
-
const view = (_config_document_defaultView = config.document.defaultView) !== null && _config_document_defaultView !==
|
|
57
|
+
const view = (_config_document_defaultView = config.document.defaultView) !== null && _config_document_defaultView !== undefined ? _config_document_defaultView : /* istanbul ignore next */ globalThis.window;
|
|
59
58
|
Clipboard.attachClipboardStubToView(view);
|
|
60
59
|
return createInstance(config).api;
|
|
61
60
|
}
|
|
@@ -64,8 +63,9 @@ function createConfig(options = {}, defaults = defaultOptionsSetup, node) {
|
|
|
64
63
|
*/ function setupDirect({ keyboardState, pointerState, ...options } = {}, node) {
|
|
65
64
|
const config = createConfig(options, defaultOptionsDirect, node);
|
|
66
65
|
prepareDocument.prepareDocument(config.document);
|
|
66
|
+
patchFocus.patchFocus(getWindow.getWindow(config.document).HTMLElement);
|
|
67
67
|
var _ref;
|
|
68
|
-
const system = (_ref = pointerState !== null && pointerState !==
|
|
68
|
+
const system = (_ref = pointerState !== null && pointerState !== undefined ? pointerState : keyboardState) !== null && _ref !== undefined ? _ref : new index.System();
|
|
69
69
|
return {
|
|
70
70
|
api: createInstance(config, system).api,
|
|
71
71
|
system
|
|
@@ -115,7 +115,7 @@ function createInstance(config, system = new index.System()) {
|
|
|
115
115
|
}
|
|
116
116
|
function getDocument(options, node, defaults) {
|
|
117
117
|
var _options_document, _ref;
|
|
118
|
-
return (_ref = (_options_document = options.document) !== null && _options_document !==
|
|
118
|
+
return (_ref = (_options_document = options.document) !== null && _options_document !== undefined ? _options_document : node && getDocumentFromNode.getDocumentFromNode(node)) !== null && _ref !== undefined ? _ref : defaults.document;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
exports.createConfig = createConfig;
|
|
@@ -1,13 +1,7 @@
|
|
|
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
4
|
var getActiveElement = require('../utils/focus/getActiveElement.js');
|
|
8
|
-
require('../utils/keyDef/readNextDescriptor.js');
|
|
9
|
-
require('../utils/misc/level.js');
|
|
10
|
-
require('../options.js');
|
|
11
5
|
|
|
12
6
|
function _define_property(obj, key, value) {
|
|
13
7
|
if (key in obj) {
|
|
@@ -22,13 +16,13 @@ function _define_property(obj, key, value) {
|
|
|
22
16
|
}
|
|
23
17
|
return obj;
|
|
24
18
|
}
|
|
25
|
-
|
|
26
|
-
(function(DOM_KEY_LOCATION) {
|
|
19
|
+
var DOM_KEY_LOCATION = /*#__PURE__*/ function(DOM_KEY_LOCATION) {
|
|
27
20
|
DOM_KEY_LOCATION[DOM_KEY_LOCATION["STANDARD"] = 0] = "STANDARD";
|
|
28
21
|
DOM_KEY_LOCATION[DOM_KEY_LOCATION["LEFT"] = 1] = "LEFT";
|
|
29
22
|
DOM_KEY_LOCATION[DOM_KEY_LOCATION["RIGHT"] = 2] = "RIGHT";
|
|
30
23
|
DOM_KEY_LOCATION[DOM_KEY_LOCATION["NUMPAD"] = 3] = "NUMPAD";
|
|
31
|
-
|
|
24
|
+
return DOM_KEY_LOCATION;
|
|
25
|
+
}({});
|
|
32
26
|
const modifierKeys = [
|
|
33
27
|
'Alt',
|
|
34
28
|
'AltGraph',
|
|
@@ -53,23 +47,17 @@ function isModifierLock(key) {
|
|
|
53
47
|
}
|
|
54
48
|
class KeyboardHost {
|
|
55
49
|
isKeyPressed(keyDef) {
|
|
56
|
-
return
|
|
50
|
+
return this.pressed.has(String(keyDef.code));
|
|
57
51
|
}
|
|
58
52
|
getPressedKeys() {
|
|
59
|
-
return
|
|
53
|
+
return this.pressed.values().map((p)=>p.keyDef);
|
|
60
54
|
}
|
|
61
55
|
/** Press a key */ async keydown(instance, keyDef) {
|
|
62
|
-
var // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
63
|
-
_this_pressed, _code, _this_pressed_code;
|
|
64
56
|
const key = String(keyDef.key);
|
|
65
57
|
const code = String(keyDef.code);
|
|
66
58
|
const target = getActiveElement.getActiveElementOrBody(instance.config.document);
|
|
67
59
|
this.setKeydownTarget(target);
|
|
68
|
-
|
|
69
|
-
(_ = (_this_pressed = this.pressed)[_code = code]) !== null && _ !== void 0 ? _ : _this_pressed[_code] = {
|
|
70
|
-
keyDef,
|
|
71
|
-
unpreventedDefault: false
|
|
72
|
-
};
|
|
60
|
+
this.pressed.add(code, keyDef);
|
|
73
61
|
if (isModifierKey(key)) {
|
|
74
62
|
this.modifiers[key] = true;
|
|
75
63
|
}
|
|
@@ -81,7 +69,9 @@ class KeyboardHost {
|
|
|
81
69
|
this.modifiers[key] = true;
|
|
82
70
|
this.modifierLockStart[key] = true;
|
|
83
71
|
}
|
|
84
|
-
|
|
72
|
+
if (unprevented) {
|
|
73
|
+
this.pressed.setUnprevented(code);
|
|
74
|
+
}
|
|
85
75
|
if (unprevented && this.hasKeyPress(key)) {
|
|
86
76
|
instance.dispatchUIEvent(getActiveElement.getActiveElementOrBody(instance.config.document), 'keypress', {
|
|
87
77
|
key,
|
|
@@ -93,10 +83,9 @@ class KeyboardHost {
|
|
|
93
83
|
/** Release a key */ async keyup(instance, keyDef) {
|
|
94
84
|
const key = String(keyDef.key);
|
|
95
85
|
const code = String(keyDef.code);
|
|
96
|
-
const unprevented = this.pressed
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (isModifierKey(key) && !Object.values(this.pressed).find((p)=>p.keyDef.key === key)) {
|
|
86
|
+
const unprevented = this.pressed.isUnprevented(code);
|
|
87
|
+
this.pressed.delete(code);
|
|
88
|
+
if (isModifierKey(key) && !this.pressed.values().find((p)=>p.keyDef.key === key)) {
|
|
100
89
|
this.modifiers[key] = false;
|
|
101
90
|
}
|
|
102
91
|
instance.dispatchUIEvent(getActiveElement.getActiveElementOrBody(instance.config.document), 'keyup', {
|
|
@@ -121,7 +110,7 @@ class KeyboardHost {
|
|
|
121
110
|
return (key.length === 1 || key === 'Enter') && !this.modifiers.Control && !this.modifiers.Alt;
|
|
122
111
|
}
|
|
123
112
|
constructor(system){
|
|
124
|
-
_define_property(this, "system",
|
|
113
|
+
_define_property(this, "system", undefined);
|
|
125
114
|
_define_property(this, "modifiers", {
|
|
126
115
|
Alt: false,
|
|
127
116
|
AltGraph: false,
|
|
@@ -136,7 +125,39 @@ class KeyboardHost {
|
|
|
136
125
|
Symbol: false,
|
|
137
126
|
SymbolLock: false
|
|
138
127
|
});
|
|
139
|
-
_define_property(this, "pressed", {
|
|
128
|
+
_define_property(this, "pressed", new class {
|
|
129
|
+
add(code, keyDef) {
|
|
130
|
+
var _this_registry, _code;
|
|
131
|
+
var _;
|
|
132
|
+
(_ = (_this_registry = this.registry)[_code = code]) !== null && _ !== undefined ? _ : _this_registry[_code] = {
|
|
133
|
+
keyDef,
|
|
134
|
+
unpreventedDefault: false
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
has(code) {
|
|
138
|
+
return !!this.registry[code];
|
|
139
|
+
}
|
|
140
|
+
setUnprevented(code) {
|
|
141
|
+
const o = this.registry[code];
|
|
142
|
+
if (o) {
|
|
143
|
+
o.unpreventedDefault = true;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
isUnprevented(code) {
|
|
147
|
+
var _this_registry_code;
|
|
148
|
+
return !!((_this_registry_code = this.registry[code]) === null || _this_registry_code === undefined ? undefined : _this_registry_code.unpreventedDefault);
|
|
149
|
+
}
|
|
150
|
+
delete(code) {
|
|
151
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
152
|
+
delete this.registry[code];
|
|
153
|
+
}
|
|
154
|
+
values() {
|
|
155
|
+
return Object.values(this.registry);
|
|
156
|
+
}
|
|
157
|
+
constructor(){
|
|
158
|
+
_define_property(this, "registry", {});
|
|
159
|
+
}
|
|
160
|
+
}());
|
|
140
161
|
_define_property(this, "carryChar", '');
|
|
141
162
|
_define_property(this, "lastKeydownTarget", undefined);
|
|
142
163
|
_define_property(this, "modifierLockStart", {});
|
|
@@ -144,4 +165,5 @@ class KeyboardHost {
|
|
|
144
165
|
}
|
|
145
166
|
}
|
|
146
167
|
|
|
168
|
+
exports.DOM_KEY_LOCATION = DOM_KEY_LOCATION;
|
|
147
169
|
exports.KeyboardHost = KeyboardHost;
|
|
@@ -45,12 +45,12 @@ class PointerHost {
|
|
|
45
45
|
// the order in which they interweave/follow on a user interaction depends on the implementation.
|
|
46
46
|
const pointermove = pointer.move(instance, position);
|
|
47
47
|
const mousemove = pointer.pointerType === 'touch' || pointer.isPrevented && pointer.isDown ? undefined : this.mouse.move(instance, position);
|
|
48
|
-
pointermove === null || pointermove ===
|
|
49
|
-
mousemove === null || mousemove ===
|
|
50
|
-
pointermove === null || pointermove ===
|
|
51
|
-
mousemove === null || mousemove ===
|
|
52
|
-
pointermove === null || pointermove ===
|
|
53
|
-
mousemove === null || mousemove ===
|
|
48
|
+
pointermove === null || pointermove === undefined ? undefined : pointermove.leave();
|
|
49
|
+
mousemove === null || mousemove === undefined ? undefined : mousemove.leave();
|
|
50
|
+
pointermove === null || pointermove === undefined ? undefined : pointermove.enter();
|
|
51
|
+
mousemove === null || mousemove === undefined ? undefined : mousemove.enter();
|
|
52
|
+
pointermove === null || pointermove === undefined ? undefined : pointermove.move();
|
|
53
|
+
mousemove === null || mousemove === undefined ? undefined : mousemove.move();
|
|
54
54
|
}
|
|
55
55
|
async release(instance, keyDef, position) {
|
|
56
56
|
const device = this.devices.get(keyDef.pointerType);
|
|
@@ -71,16 +71,16 @@ class PointerHost {
|
|
|
71
71
|
if (!pointer.isPrevented) {
|
|
72
72
|
if (pointer.pointerType === 'touch' && !pointer.isMultitouch) {
|
|
73
73
|
const mousemove = this.mouse.move(instance, pointer.position);
|
|
74
|
-
mousemove === null || mousemove ===
|
|
75
|
-
mousemove === null || mousemove ===
|
|
76
|
-
mousemove === null || mousemove ===
|
|
74
|
+
mousemove === null || mousemove === undefined ? undefined : mousemove.leave();
|
|
75
|
+
mousemove === null || mousemove === undefined ? undefined : mousemove.enter();
|
|
76
|
+
mousemove === null || mousemove === undefined ? undefined : mousemove.move();
|
|
77
77
|
this.mouse.down(instance, keyDef, pointer);
|
|
78
78
|
}
|
|
79
79
|
if (!pointer.isMultitouch) {
|
|
80
80
|
const mousemove = this.mouse.move(instance, pointer.position);
|
|
81
|
-
mousemove === null || mousemove ===
|
|
82
|
-
mousemove === null || mousemove ===
|
|
83
|
-
mousemove === null || mousemove ===
|
|
81
|
+
mousemove === null || mousemove === undefined ? undefined : mousemove.leave();
|
|
82
|
+
mousemove === null || mousemove === undefined ? undefined : mousemove.enter();
|
|
83
|
+
mousemove === null || mousemove === undefined ? undefined : mousemove.move();
|
|
84
84
|
this.mouse.up(instance, keyDef, pointer);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -96,23 +96,21 @@ class PointerHost {
|
|
|
96
96
|
}
|
|
97
97
|
getMouseTarget(instance) {
|
|
98
98
|
var _this_mouse_position_target;
|
|
99
|
-
return (_this_mouse_position_target = this.mouse.position.target) !== null && _this_mouse_position_target !==
|
|
99
|
+
return (_this_mouse_position_target = this.mouse.position.target) !== null && _this_mouse_position_target !== undefined ? _this_mouse_position_target : instance.config.document.body;
|
|
100
100
|
}
|
|
101
101
|
setMousePosition(position) {
|
|
102
102
|
this.mouse.position = position;
|
|
103
103
|
this.pointers.get('mouse').position = position;
|
|
104
104
|
}
|
|
105
105
|
constructor(system){
|
|
106
|
-
_define_property(this, "system",
|
|
107
|
-
_define_property(this, "mouse",
|
|
108
|
-
_define_property(this, "buttons",
|
|
106
|
+
_define_property(this, "system", undefined);
|
|
107
|
+
_define_property(this, "mouse", undefined);
|
|
108
|
+
_define_property(this, "buttons", undefined);
|
|
109
109
|
_define_property(this, "devices", new class {
|
|
110
110
|
get(k) {
|
|
111
|
-
var
|
|
112
|
-
_this_registry, _k;
|
|
111
|
+
var _this_registry, _k;
|
|
113
112
|
var _;
|
|
114
|
-
(_ = (_this_registry = this.registry)[_k = k]) !== null && _ !==
|
|
115
|
-
return this.registry[k];
|
|
113
|
+
return (_ = (_this_registry = this.registry)[_k = k]) !== null && _ !== undefined ? _ : _this_registry[_k] = new device.Device();
|
|
116
114
|
}
|
|
117
115
|
constructor(){
|
|
118
116
|
_define_property(this, "registry", {});
|
|
@@ -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');
|
|
@@ -133,7 +127,7 @@ function _define_property(obj, key, value) {
|
|
|
133
127
|
}
|
|
134
128
|
getTarget(instance) {
|
|
135
129
|
var _this_position_target;
|
|
136
|
-
return (_this_position_target = this.position.target) !== null && _this_position_target !==
|
|
130
|
+
return (_this_position_target = this.position.target) !== null && _this_position_target !== undefined ? _this_position_target : instance.config.document.body;
|
|
137
131
|
}
|
|
138
132
|
startSelecting(instance, clickCount) {
|
|
139
133
|
var _this_position_caret, _this_position_caret1;
|
|
@@ -141,8 +135,8 @@ function _define_property(obj, key, value) {
|
|
|
141
135
|
this.selecting = setSelectionPerMouse.setSelectionPerMouseDown({
|
|
142
136
|
document: instance.config.document,
|
|
143
137
|
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 ===
|
|
138
|
+
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === undefined ? undefined : _this_position_caret.node,
|
|
139
|
+
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === undefined ? undefined : _this_position_caret1.offset,
|
|
146
140
|
clickCount
|
|
147
141
|
});
|
|
148
142
|
}
|
|
@@ -154,8 +148,8 @@ function _define_property(obj, key, value) {
|
|
|
154
148
|
modifySelectionPerMouse.modifySelectionPerMouseMove(this.selecting, {
|
|
155
149
|
document: instance.config.document,
|
|
156
150
|
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 ===
|
|
151
|
+
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === undefined ? undefined : _this_position_caret.node,
|
|
152
|
+
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === undefined ? undefined : _this_position_caret1.offset
|
|
159
153
|
});
|
|
160
154
|
}
|
|
161
155
|
endSelecting() {
|
|
@@ -164,7 +158,7 @@ function _define_property(obj, key, value) {
|
|
|
164
158
|
constructor(){
|
|
165
159
|
_define_property(this, "position", {});
|
|
166
160
|
_define_property(this, "buttons", new buttons.Buttons());
|
|
167
|
-
_define_property(this, "selecting",
|
|
161
|
+
_define_property(this, "selecting", undefined);
|
|
168
162
|
_define_property(this, "buttonDownTarget", {});
|
|
169
163
|
// According to spec the `detail` on click events should be the number
|
|
170
164
|
// of *consecutive* clicks with a specific button.
|
|
@@ -187,11 +181,11 @@ function _define_property(obj, key, value) {
|
|
|
187
181
|
getOnDown(button) {
|
|
188
182
|
var _this_count_button;
|
|
189
183
|
this.down = {
|
|
190
|
-
[button]: (_this_count_button = this.count[button]) !== null && _this_count_button !==
|
|
184
|
+
[button]: (_this_count_button = this.count[button]) !== null && _this_count_button !== undefined ? _this_count_button : 0
|
|
191
185
|
};
|
|
192
186
|
var _this_count_button1;
|
|
193
187
|
this.count = {
|
|
194
|
-
[button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !==
|
|
188
|
+
[button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !== undefined ? _this_count_button1 : 0
|
|
195
189
|
};
|
|
196
190
|
return Number(this.count[button]) + 1;
|
|
197
191
|
}
|
|
@@ -1,12 +1,7 @@
|
|
|
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');
|
|
12
7
|
|
|
@@ -97,7 +92,7 @@ class Pointer {
|
|
|
97
92
|
}
|
|
98
93
|
getTarget(instance) {
|
|
99
94
|
var _this_position_target;
|
|
100
|
-
return (_this_position_target = this.position.target) !== null && _this_position_target !==
|
|
95
|
+
return (_this_position_target = this.position.target) !== null && _this_position_target !== undefined ? _this_position_target : instance.config.document.body;
|
|
101
96
|
}
|
|
102
97
|
getEventInit() {
|
|
103
98
|
return {
|
|
@@ -108,9 +103,9 @@ class Pointer {
|
|
|
108
103
|
};
|
|
109
104
|
}
|
|
110
105
|
constructor({ pointerId, pointerType, isPrimary }){
|
|
111
|
-
_define_property(this, "pointerId",
|
|
112
|
-
_define_property(this, "pointerType",
|
|
113
|
-
_define_property(this, "isPrimary",
|
|
106
|
+
_define_property(this, "pointerId", undefined);
|
|
107
|
+
_define_property(this, "pointerType", undefined);
|
|
108
|
+
_define_property(this, "isPrimary", undefined);
|
|
114
109
|
_define_property(this, "isMultitouch", false);
|
|
115
110
|
_define_property(this, "isCancelled", false);
|
|
116
111
|
_define_property(this, "isDown", false);
|
|
@@ -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
|
}
|
|
@@ -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) {
|