@testing-library/user-event 14.4.2 → 14.5.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/_interop/dtl.js +30 -0
- package/dist/cjs/_interop/dtlEventMap.js +30 -0
- package/dist/cjs/_interop/dtlHelpers.js +30 -0
- package/dist/cjs/clipboard/copy.js +6 -16
- package/dist/cjs/clipboard/cut.js +6 -16
- package/dist/cjs/clipboard/paste.js +6 -16
- package/dist/cjs/convenience/click.js +1 -4
- package/dist/cjs/convenience/hover.js +2 -12
- package/dist/cjs/convenience/tab.js +1 -1
- 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 +89 -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 -47
- package/dist/cjs/event/behavior/keypress.js +12 -12
- package/dist/cjs/event/behavior/keyup.js +6 -8
- package/dist/cjs/event/behavior/paste.js +7 -13
- package/dist/cjs/event/createEvent.js +43 -50
- package/dist/cjs/event/dispatchEvent.js +21 -3
- package/dist/cjs/event/eventMap.js +2 -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 +52 -50
- 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 +41 -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 +50 -0
- package/dist/cjs/event/selection/moveSelection.js +48 -0
- package/dist/cjs/{utils/focus → event/selection}/resolveCaretPosition.js +10 -18
- package/dist/cjs/event/selection/selectAll.js +48 -0
- package/dist/cjs/event/selection/setSelection.js +30 -0
- package/dist/cjs/event/selection/setSelectionPerMouse.js +91 -0
- package/dist/cjs/event/selection/setSelectionRange.js +40 -0
- package/dist/cjs/event/selection/updateSelectionOnFocus.js +46 -0
- package/dist/cjs/event/wrapEvent.js +3 -2
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/keyboard/index.js +13 -23
- package/dist/cjs/keyboard/parseKeyDef.js +9 -17
- package/dist/cjs/options.js +0 -28
- package/dist/cjs/pointer/index.js +28 -38
- package/dist/cjs/pointer/keyMap.js +1 -1
- package/dist/cjs/pointer/parseKeyDef.js +2 -10
- package/dist/cjs/setup/api.js +19 -17
- package/dist/cjs/setup/directApi.js +6 -6
- package/dist/cjs/setup/index.js +0 -2
- package/dist/cjs/setup/setup.js +70 -42
- package/dist/cjs/setup/wrapAsync.js +3 -2
- package/dist/cjs/system/index.js +15 -2
- package/dist/cjs/system/keyboard.js +34 -21
- package/dist/cjs/system/pointer/buttons.js +14 -1
- package/dist/cjs/system/pointer/device.js +14 -1
- package/dist/cjs/system/pointer/index.js +60 -45
- package/dist/cjs/system/pointer/mouse.js +77 -56
- package/dist/cjs/system/pointer/pointer.js +56 -42
- package/dist/cjs/system/pointer/shared.js +10 -0
- package/dist/cjs/utility/clear.js +10 -11
- package/dist/cjs/utility/selectOptions.js +28 -29
- package/dist/cjs/utility/type.js +6 -15
- package/dist/cjs/utility/upload.js +9 -18
- package/dist/cjs/utils/dataTransfer/Clipboard.js +26 -24
- package/dist/cjs/utils/dataTransfer/DataTransfer.js +25 -9
- package/dist/cjs/utils/edit/isEditable.js +6 -10
- package/dist/cjs/utils/edit/maxLength.js +6 -17
- package/dist/cjs/utils/edit/setFiles.js +4 -4
- package/dist/cjs/utils/edit/{buildTimeValue.js → timeValue.js} +6 -0
- package/dist/cjs/utils/focus/cursor.js +2 -18
- package/dist/cjs/utils/focus/getActiveElement.js +4 -3
- package/dist/cjs/utils/focus/selection.js +1 -271
- package/dist/cjs/utils/focus/selector.js +1 -1
- package/dist/cjs/utils/index.js +7 -32
- package/dist/cjs/utils/keyDef/readNextDescriptor.js +5 -5
- package/dist/cjs/utils/misc/getTreeDiff.js +3 -3
- package/dist/cjs/utils/misc/getWindow.js +3 -2
- package/dist/cjs/utils/misc/isDisabled.js +3 -3
- package/dist/cjs/utils/misc/isVisible.js +3 -2
- package/dist/cjs/utils/misc/level.js +4 -9
- package/dist/cjs/utils/misc/wait.js +1 -1
- package/dist/cjs/utils/pointer/cssPointerEvents.js +31 -40
- package/dist/esm/_interop/dtl.js +6 -0
- package/dist/esm/_interop/dtlEventMap.js +6 -0
- package/dist/esm/_interop/dtlHelpers.js +6 -0
- package/dist/esm/clipboard/copy.js +6 -16
- package/dist/esm/clipboard/cut.js +6 -16
- package/dist/esm/clipboard/paste.js +6 -16
- package/dist/esm/convenience/click.js +1 -4
- package/dist/esm/convenience/hover.js +2 -12
- package/dist/esm/convenience/tab.js +1 -1
- 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 +87 -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 -40
- package/dist/esm/event/behavior/keypress.js +12 -12
- package/dist/esm/event/behavior/keyup.js +6 -8
- package/dist/esm/event/behavior/paste.js +7 -13
- package/dist/esm/event/createEvent.js +43 -50
- package/dist/esm/event/dispatchEvent.js +20 -4
- package/dist/esm/event/eventMap.js +2 -2
- package/dist/esm/event/focus.js +39 -0
- package/dist/esm/event/index.js +14 -19
- package/dist/esm/{utils/edit → event}/input.js +39 -37
- 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 +37 -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 +46 -0
- package/dist/esm/event/selection/moveSelection.js +44 -0
- package/dist/esm/{utils/focus → event/selection}/resolveCaretPosition.js +9 -17
- package/dist/esm/event/selection/selectAll.js +43 -0
- package/dist/esm/event/selection/setSelection.js +26 -0
- package/dist/esm/event/selection/setSelectionPerMouse.js +87 -0
- package/dist/esm/event/selection/setSelectionRange.js +36 -0
- package/dist/esm/event/selection/updateSelectionOnFocus.js +42 -0
- package/dist/esm/event/wrapEvent.js +2 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/keyboard/index.js +13 -23
- package/dist/esm/keyboard/parseKeyDef.js +9 -17
- package/dist/esm/options.js +1 -26
- package/dist/esm/pointer/index.js +28 -38
- package/dist/esm/pointer/keyMap.js +1 -1
- package/dist/esm/pointer/parseKeyDef.js +2 -10
- package/dist/esm/setup/api.js +33 -12
- package/dist/esm/setup/directApi.js +6 -6
- package/dist/esm/setup/index.js +0 -1
- package/dist/esm/setup/setup.js +66 -39
- package/dist/esm/setup/wrapAsync.js +2 -1
- package/dist/esm/system/index.js +15 -2
- package/dist/esm/system/keyboard.js +34 -21
- package/dist/esm/system/pointer/buttons.js +14 -1
- package/dist/esm/system/pointer/device.js +14 -1
- package/dist/esm/system/pointer/index.js +61 -45
- package/dist/esm/system/pointer/mouse.js +74 -53
- package/dist/esm/system/pointer/pointer.js +55 -41
- package/dist/esm/system/pointer/shared.js +6 -0
- package/dist/esm/utility/clear.js +10 -11
- package/dist/esm/utility/selectOptions.js +24 -25
- package/dist/esm/utility/type.js +5 -14
- package/dist/esm/utility/upload.js +9 -18
- package/dist/esm/utils/dataTransfer/Clipboard.js +26 -24
- package/dist/esm/utils/dataTransfer/DataTransfer.js +25 -9
- package/dist/esm/utils/edit/isEditable.js +4 -8
- package/dist/esm/utils/edit/maxLength.js +5 -17
- package/dist/esm/utils/edit/setFiles.js +4 -4
- package/dist/esm/utils/edit/{buildTimeValue.js → timeValue.js} +6 -1
- package/dist/esm/utils/focus/cursor.js +2 -18
- package/dist/esm/utils/focus/getActiveElement.js +4 -3
- package/dist/esm/utils/focus/selection.js +3 -265
- package/dist/esm/utils/focus/selector.js +1 -1
- package/dist/esm/utils/index.js +4 -11
- package/dist/esm/utils/keyDef/readNextDescriptor.js +5 -5
- package/dist/esm/utils/misc/getTreeDiff.js +3 -3
- package/dist/esm/utils/misc/getWindow.js +2 -1
- package/dist/esm/utils/misc/isDisabled.js +3 -3
- package/dist/esm/utils/misc/isVisible.js +3 -2
- package/dist/esm/utils/misc/level.js +4 -9
- package/dist/esm/utils/misc/wait.js +1 -1
- package/dist/esm/utils/pointer/cssPointerEvents.js +31 -40
- package/dist/types/_interop/dtl.d.ts +3 -0
- package/dist/types/_interop/dtlEventMap.d.ts +3 -0
- package/dist/types/_interop/dtlHelpers.d.ts +3 -0
- package/dist/types/clipboard/copy.d.ts +1 -1
- package/dist/types/clipboard/cut.d.ts +1 -1
- package/dist/types/clipboard/paste.d.ts +1 -1
- package/dist/types/convenience/click.d.ts +1 -1
- package/dist/types/convenience/hover.d.ts +1 -1
- package/dist/types/convenience/tab.d.ts +1 -1
- package/dist/types/document/UI.d.ts +42 -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 +6 -3
- 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/createEvent.d.ts +1 -1
- package/dist/types/event/dispatchEvent.d.ts +5 -2
- package/dist/types/event/eventMap.d.ts +8 -0
- 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/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/event/types.d.ts +3 -3
- package/dist/types/index.d.ts +3 -1
- package/dist/types/keyboard/index.d.ts +2 -2
- package/dist/types/options.d.ts +2 -10
- package/dist/types/pointer/index.d.ts +7 -7
- package/dist/types/setup/api.d.ts +23 -5
- package/dist/types/setup/directApi.d.ts +5 -5
- package/dist/types/setup/index.d.ts +2 -15
- package/dist/types/setup/setup.d.ts +25 -7
- package/dist/types/system/keyboard.d.ts +4 -4
- package/dist/types/system/pointer/buttons.d.ts +2 -2
- package/dist/types/system/pointer/device.d.ts +1 -1
- package/dist/types/system/pointer/index.d.ts +7 -25
- package/dist/types/system/pointer/mouse.d.ts +6 -6
- package/dist/types/system/pointer/pointer.d.ts +8 -8
- 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 +4 -4
- package/dist/types/utility/upload.d.ts +1 -1
- package/dist/types/utils/click/isClickableInput.d.ts +2 -2
- package/dist/types/utils/dataTransfer/Clipboard.d.ts +1 -1
- package/dist/types/utils/edit/isEditable.d.ts +6 -7
- 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/keyDef/readNextDescriptor.d.ts +1 -1
- package/dist/types/utils/misc/isElementType.d.ts +1 -1
- 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 +24 -12
- package/dist/cjs/document/selection.js +0 -108
- package/dist/cjs/document/setRangeText.js +0 -21
- package/dist/cjs/document/value.js +0 -127
- 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 -29
- package/dist/cjs/utils/focus/selectAll.js +0 -56
- package/dist/cjs/utils/misc/eventWrapper.js +0 -15
- package/dist/esm/document/selection.js +0 -100
- package/dist/esm/document/setRangeText.js +0 -17
- package/dist/esm/document/value.js +0 -117
- 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 -25
- package/dist/esm/utils/focus/selectAll.js +0 -51
- 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
- /package/dist/cjs/{event → _interop}/dom-events.d.js +0 -0
- /package/dist/cjs/{utils/misc → _interop}/dom-helpers.d.js +0 -0
- /package/dist/esm/{event → _interop}/dom-events.d.js +0 -0
- /package/dist/esm/{utils/misc → _interop}/dom-helpers.d.js +0 -0
- /package/dist/types/{utils/focus → document}/copySelection.d.ts +0 -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
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var def = require('@testing-library/dom');
|
|
4
|
+
|
|
5
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
6
|
+
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n["default"] = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var def__default = /*#__PURE__*/_interopDefaultLegacy(def);
|
|
26
|
+
var def__namespace = /*#__PURE__*/_interopNamespace(def);
|
|
27
|
+
|
|
28
|
+
var dtl = def__default["default"] !== null && def__default["default"] !== void 0 ? def__default["default"] : def__namespace;
|
|
29
|
+
|
|
30
|
+
module.exports = dtl;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var def = require('@testing-library/dom/dist/event-map.js');
|
|
4
|
+
|
|
5
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
6
|
+
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n["default"] = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var def__default = /*#__PURE__*/_interopDefaultLegacy(def);
|
|
26
|
+
var def__namespace = /*#__PURE__*/_interopNamespace(def);
|
|
27
|
+
|
|
28
|
+
var dtlEvents = def__default["default"] !== null && def__default["default"] !== void 0 ? def__default["default"] : def__namespace;
|
|
29
|
+
|
|
30
|
+
module.exports = dtlEvents;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var def = require('@testing-library/dom/dist/helpers.js');
|
|
4
|
+
|
|
5
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
6
|
+
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n["default"] = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var def__default = /*#__PURE__*/_interopDefaultLegacy(def);
|
|
26
|
+
var def__namespace = /*#__PURE__*/_interopNamespace(def);
|
|
27
|
+
|
|
28
|
+
var dtlHelpers = def__default["default"] !== null && def__default["default"] !== void 0 ? def__default["default"] : def__namespace;
|
|
29
|
+
|
|
30
|
+
module.exports = dtlHelpers;
|
|
@@ -2,37 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
require('../setup/index.js');
|
|
6
5
|
require('../utils/click/isClickableInput.js');
|
|
7
6
|
var Clipboard = 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('@testing-library/dom');
|
|
16
|
-
require('../utils/edit/maxLength.js');
|
|
17
7
|
require('../utils/edit/isEditable.js');
|
|
8
|
+
require('../utils/edit/maxLength.js');
|
|
18
9
|
require('@testing-library/dom/dist/helpers.js');
|
|
19
|
-
var copySelection = require('../utils/focus/copySelection.js');
|
|
20
10
|
require('../utils/keyDef/readNextDescriptor.js');
|
|
21
11
|
require('../utils/misc/level.js');
|
|
22
12
|
require('../options.js');
|
|
23
|
-
var
|
|
13
|
+
var copySelection = require('../document/copySelection.js');
|
|
24
14
|
|
|
25
15
|
async function copy() {
|
|
26
|
-
const doc = this
|
|
27
|
-
var
|
|
28
|
-
const target = (
|
|
16
|
+
const doc = this.config.document;
|
|
17
|
+
var _doc_activeElement;
|
|
18
|
+
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== void 0 ? _doc_activeElement : /* istanbul ignore next */ doc.body;
|
|
29
19
|
const clipboardData = copySelection.copySelection(target);
|
|
30
20
|
if (clipboardData.items.length === 0) {
|
|
31
21
|
return;
|
|
32
22
|
}
|
|
33
23
|
if (this.dispatchUIEvent(target, 'copy', {
|
|
34
24
|
clipboardData
|
|
35
|
-
}) && this
|
|
25
|
+
}) && this.config.writeToClipboard) {
|
|
36
26
|
await Clipboard.writeDataTransferToClipboard(doc, clipboardData);
|
|
37
27
|
}
|
|
38
28
|
return clipboardData;
|
|
@@ -2,37 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
require('../setup/index.js');
|
|
6
5
|
require('../utils/click/isClickableInput.js');
|
|
7
6
|
var Clipboard = 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('@testing-library/dom');
|
|
16
|
-
require('../utils/edit/maxLength.js');
|
|
17
7
|
require('../utils/edit/isEditable.js');
|
|
8
|
+
require('../utils/edit/maxLength.js');
|
|
18
9
|
require('@testing-library/dom/dist/helpers.js');
|
|
19
|
-
var copySelection = require('../utils/focus/copySelection.js');
|
|
20
10
|
require('../utils/keyDef/readNextDescriptor.js');
|
|
21
11
|
require('../utils/misc/level.js');
|
|
22
12
|
require('../options.js');
|
|
23
|
-
var
|
|
13
|
+
var copySelection = require('../document/copySelection.js');
|
|
24
14
|
|
|
25
15
|
async function cut() {
|
|
26
|
-
const doc = this
|
|
27
|
-
var
|
|
28
|
-
const target = (
|
|
16
|
+
const doc = this.config.document;
|
|
17
|
+
var _doc_activeElement;
|
|
18
|
+
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== void 0 ? _doc_activeElement : /* istanbul ignore next */ doc.body;
|
|
29
19
|
const clipboardData = copySelection.copySelection(target);
|
|
30
20
|
if (clipboardData.items.length === 0) {
|
|
31
21
|
return;
|
|
32
22
|
}
|
|
33
23
|
if (this.dispatchUIEvent(target, 'cut', {
|
|
34
24
|
clipboardData
|
|
35
|
-
}) && this
|
|
25
|
+
}) && this.config.writeToClipboard) {
|
|
36
26
|
await Clipboard.writeDataTransferToClipboard(target.ownerDocument, clipboardData);
|
|
37
27
|
}
|
|
38
28
|
return clipboardData;
|
|
@@ -2,32 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
require('../setup/index.js');
|
|
6
5
|
require('../utils/click/isClickableInput.js');
|
|
7
6
|
var DataTransfer = require('../utils/dataTransfer/DataTransfer.js');
|
|
8
7
|
var Clipboard = require('../utils/dataTransfer/Clipboard.js');
|
|
9
|
-
require('../event/eventMap.js');
|
|
10
|
-
require('../event/behavior/click.js');
|
|
11
|
-
require('../event/behavior/cut.js');
|
|
12
|
-
require('../event/behavior/keydown.js');
|
|
13
|
-
require('../event/behavior/keypress.js');
|
|
14
|
-
require('../event/behavior/keyup.js');
|
|
15
|
-
require('../event/behavior/paste.js');
|
|
16
|
-
require('@testing-library/dom');
|
|
17
|
-
require('../utils/edit/maxLength.js');
|
|
18
8
|
require('../utils/edit/isEditable.js');
|
|
9
|
+
require('../utils/edit/maxLength.js');
|
|
19
10
|
var getWindow = require('../utils/misc/getWindow.js');
|
|
20
11
|
require('../utils/keyDef/readNextDescriptor.js');
|
|
21
12
|
require('../utils/misc/level.js');
|
|
22
13
|
require('../options.js');
|
|
23
|
-
var config = require('../setup/config.js');
|
|
24
14
|
|
|
25
15
|
async function paste(clipboardData) {
|
|
26
|
-
const doc = this
|
|
27
|
-
var
|
|
28
|
-
const target = (
|
|
29
|
-
var
|
|
30
|
-
const dataTransfer = (
|
|
16
|
+
const doc = this.config.document;
|
|
17
|
+
var _doc_activeElement;
|
|
18
|
+
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== void 0 ? _doc_activeElement : /* istanbul ignore next */ doc.body;
|
|
19
|
+
var _ref;
|
|
20
|
+
const dataTransfer = (_ref = typeof clipboardData === 'string' ? getClipboardDataFromString(doc, clipboardData) : clipboardData) !== null && _ref !== void 0 ? _ref : await Clipboard.readDataTransferFromClipboard(doc).catch(()=>{
|
|
31
21
|
throw new Error('`userEvent.paste()` without `clipboardData` requires the `ClipboardAPI` to be available.');
|
|
32
22
|
});
|
|
33
23
|
this.dispatchUIEvent(target, 'paste', {
|
|
@@ -2,12 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
require('../setup/index.js');
|
|
6
|
-
var config = require('../setup/config.js');
|
|
7
|
-
|
|
8
5
|
async function click(element) {
|
|
9
6
|
const pointerIn = [];
|
|
10
|
-
if (!this
|
|
7
|
+
if (!this.config.skipHover) {
|
|
11
8
|
pointerIn.push({
|
|
12
9
|
target: element
|
|
13
10
|
});
|
|
@@ -2,24 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
require('../setup/index.js');
|
|
6
5
|
require('../utils/click/isClickableInput.js');
|
|
7
6
|
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('@testing-library/dom');
|
|
16
|
-
require('../utils/edit/maxLength.js');
|
|
17
7
|
require('../utils/edit/isEditable.js');
|
|
8
|
+
require('../utils/edit/maxLength.js');
|
|
18
9
|
require('@testing-library/dom/dist/helpers.js');
|
|
19
10
|
require('../utils/keyDef/readNextDescriptor.js');
|
|
20
11
|
require('../utils/misc/level.js');
|
|
21
12
|
var cssPointerEvents = require('../utils/pointer/cssPointerEvents.js');
|
|
22
|
-
var config = require('../setup/config.js');
|
|
23
13
|
|
|
24
14
|
async function hover(element) {
|
|
25
15
|
return this.pointer({
|
|
@@ -27,7 +17,7 @@ async function hover(element) {
|
|
|
27
17
|
});
|
|
28
18
|
}
|
|
29
19
|
async function unhover(element) {
|
|
30
|
-
cssPointerEvents.assertPointerEvents(this
|
|
20
|
+
cssPointerEvents.assertPointerEvents(this, this.system.pointer.getMouseTarget(this));
|
|
31
21
|
return this.pointer({
|
|
32
22
|
target: element.ownerDocument.body
|
|
33
23
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
async function tab({ shift
|
|
5
|
+
async function tab({ shift } = {}) {
|
|
6
6
|
return this.keyboard(shift === true ? '{Shift>}{Tab}{/Shift}' : shift === false ? '[/ShiftLeft][/ShiftRight]{Tab}' : '{Tab}');
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const UIValue = Symbol('Displayed value in UI');
|
|
6
|
+
const UISelection = Symbol('Displayed selection in UI');
|
|
7
|
+
const InitialValue = Symbol('Initial value to compare on blur');
|
|
8
|
+
function isUIValue(value) {
|
|
9
|
+
return typeof value === 'object' && UIValue in value;
|
|
10
|
+
}
|
|
11
|
+
function isUISelectionStart(start) {
|
|
12
|
+
return !!start && typeof start === 'object' && UISelection in start;
|
|
13
|
+
}
|
|
14
|
+
function setUIValue(element, value) {
|
|
15
|
+
if (element[InitialValue] === undefined) {
|
|
16
|
+
element[InitialValue] = element.value;
|
|
17
|
+
}
|
|
18
|
+
element[UIValue] = value;
|
|
19
|
+
// eslint-disable-next-line no-new-wrappers
|
|
20
|
+
element.value = Object.assign(new String(value), {
|
|
21
|
+
[UIValue]: true
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function getUIValue(element) {
|
|
25
|
+
return element[UIValue] === undefined ? element.value : String(element[UIValue]);
|
|
26
|
+
}
|
|
27
|
+
/** Flag the IDL value as clean. This does not change the value.*/ function setUIValueClean(element) {
|
|
28
|
+
element[UIValue] = undefined;
|
|
29
|
+
}
|
|
30
|
+
function clearInitialValue(element) {
|
|
31
|
+
element[InitialValue] = undefined;
|
|
32
|
+
}
|
|
33
|
+
function getInitialValue(element) {
|
|
34
|
+
return element[InitialValue];
|
|
35
|
+
}
|
|
36
|
+
function setUISelectionRaw(element, selection) {
|
|
37
|
+
element[UISelection] = selection;
|
|
38
|
+
}
|
|
39
|
+
function setUISelection(element, { focusOffset: focusOffsetParam, anchorOffset: anchorOffsetParam = focusOffsetParam }, mode = 'replace') {
|
|
40
|
+
const valueLength = getUIValue(element).length;
|
|
41
|
+
const sanitizeOffset = (o)=>Math.max(0, Math.min(valueLength, o));
|
|
42
|
+
const anchorOffset = mode === 'replace' || element[UISelection] === undefined ? sanitizeOffset(anchorOffsetParam) : element[UISelection].anchorOffset;
|
|
43
|
+
const focusOffset = sanitizeOffset(focusOffsetParam);
|
|
44
|
+
const startOffset = Math.min(anchorOffset, focusOffset);
|
|
45
|
+
const endOffset = Math.max(anchorOffset, focusOffset);
|
|
46
|
+
element[UISelection] = {
|
|
47
|
+
anchorOffset,
|
|
48
|
+
focusOffset
|
|
49
|
+
};
|
|
50
|
+
if (element.selectionStart === startOffset && element.selectionEnd === endOffset) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// eslint-disable-next-line no-new-wrappers
|
|
54
|
+
const startObj = Object.assign(new Number(startOffset), {
|
|
55
|
+
[UISelection]: true
|
|
56
|
+
});
|
|
57
|
+
try {
|
|
58
|
+
element.setSelectionRange(startObj, endOffset);
|
|
59
|
+
} catch {
|
|
60
|
+
// DOMException for invalid state is expected when calling this
|
|
61
|
+
// on an element without support for setSelectionRange
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function getUISelection(element) {
|
|
65
|
+
var _element_selectionStart, _element_selectionEnd, _element_UISelection;
|
|
66
|
+
const sel = (_element_UISelection = element[UISelection]) !== null && _element_UISelection !== void 0 ? _element_UISelection : {
|
|
67
|
+
anchorOffset: (_element_selectionStart = element.selectionStart) !== null && _element_selectionStart !== void 0 ? _element_selectionStart : 0,
|
|
68
|
+
focusOffset: (_element_selectionEnd = element.selectionEnd) !== null && _element_selectionEnd !== void 0 ? _element_selectionEnd : 0
|
|
69
|
+
};
|
|
70
|
+
return {
|
|
71
|
+
...sel,
|
|
72
|
+
startOffset: Math.min(sel.anchorOffset, sel.focusOffset),
|
|
73
|
+
endOffset: Math.max(sel.anchorOffset, sel.focusOffset)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function hasUISelection(element) {
|
|
77
|
+
return !!element[UISelection];
|
|
78
|
+
}
|
|
79
|
+
/** Flag the IDL selection as clean. This does not change the selection. */ function setUISelectionClean(element) {
|
|
80
|
+
element[UISelection] = undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
exports.clearInitialValue = clearInitialValue;
|
|
84
|
+
exports.getInitialValue = getInitialValue;
|
|
85
|
+
exports.getUISelection = getUISelection;
|
|
86
|
+
exports.getUIValue = getUIValue;
|
|
87
|
+
exports.hasUISelection = hasUISelection;
|
|
88
|
+
exports.isUISelectionStart = isUISelectionStart;
|
|
89
|
+
exports.isUIValue = isUIValue;
|
|
90
|
+
exports.setUISelection = setUISelection;
|
|
91
|
+
exports.setUISelectionClean = setUISelectionClean;
|
|
92
|
+
exports.setUISelectionRaw = setUISelectionRaw;
|
|
93
|
+
exports.setUIValue = setUIValue;
|
|
94
|
+
exports.setUIValueClean = setUIValueClean;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('../utils/click/isClickableInput.js');
|
|
6
|
+
var DataTransfer = require('../utils/dataTransfer/DataTransfer.js');
|
|
7
|
+
require('../utils/dataTransfer/Clipboard.js');
|
|
8
|
+
require('../utils/edit/isEditable.js');
|
|
9
|
+
require('../utils/edit/maxLength.js');
|
|
10
|
+
var getWindow = require('../utils/misc/getWindow.js');
|
|
11
|
+
var selection = require('../utils/focus/selection.js');
|
|
12
|
+
require('../utils/keyDef/readNextDescriptor.js');
|
|
13
|
+
require('../utils/misc/level.js');
|
|
14
|
+
require('../options.js');
|
|
15
|
+
var UI = require('./UI.js');
|
|
16
|
+
|
|
17
|
+
function copySelection(target) {
|
|
18
|
+
const data = selection.hasOwnSelection(target) ? {
|
|
19
|
+
'text/plain': readSelectedValueFromInput(target)
|
|
20
|
+
} : {
|
|
21
|
+
'text/plain': String(target.ownerDocument.getSelection())
|
|
22
|
+
};
|
|
23
|
+
const dt = DataTransfer.createDataTransfer(getWindow.getWindow(target));
|
|
24
|
+
for(const type in data){
|
|
25
|
+
if (data[type]) {
|
|
26
|
+
dt.setData(type, data[type]);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return dt;
|
|
30
|
+
}
|
|
31
|
+
function readSelectedValueFromInput(target) {
|
|
32
|
+
const sel = UI.getUISelection(target);
|
|
33
|
+
const val = UI.getUIValue(target);
|
|
34
|
+
return val.substring(sel.startOffset, sel.endOffset);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
exports.copySelection = copySelection;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('../utils/click/isClickableInput.js');
|
|
6
|
+
require('../utils/dataTransfer/Clipboard.js');
|
|
7
|
+
var isContentEditable = require('../utils/edit/isContentEditable.js');
|
|
8
|
+
require('../utils/edit/isEditable.js');
|
|
9
|
+
require('../utils/edit/maxLength.js');
|
|
10
|
+
require('@testing-library/dom/dist/helpers.js');
|
|
11
|
+
require('../utils/keyDef/readNextDescriptor.js');
|
|
12
|
+
require('../utils/misc/level.js');
|
|
13
|
+
require('../options.js');
|
|
14
|
+
var UI = require('./UI.js');
|
|
15
|
+
|
|
16
|
+
function getValueOrTextContent(element) {
|
|
17
|
+
// istanbul ignore if
|
|
18
|
+
if (!element) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
if (isContentEditable.isContentEditable(element)) {
|
|
22
|
+
return element.textContent;
|
|
23
|
+
}
|
|
24
|
+
return UI.getUIValue(element);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.getValueOrTextContent = getValueOrTextContent;
|
|
@@ -2,73 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
require('
|
|
7
|
-
require('
|
|
8
|
-
require('
|
|
9
|
-
require('../utils/edit/isEditable.js');
|
|
10
|
-
require('@testing-library/dom');
|
|
11
|
-
var isElementType = require('../utils/misc/isElementType.js');
|
|
12
|
-
require('@testing-library/dom/dist/helpers.js');
|
|
13
|
-
require('../utils/keyDef/readNextDescriptor.js');
|
|
14
|
-
require('../utils/misc/level.js');
|
|
15
|
-
require('../options.js');
|
|
16
|
-
var selection = require('./selection.js');
|
|
17
|
-
var setRangeText = require('./setRangeText.js');
|
|
18
|
-
var value = require('./value.js');
|
|
5
|
+
var UI = require('./UI.js');
|
|
6
|
+
var getValueOrTextContent = require('./getValueOrTextContent.js');
|
|
7
|
+
var copySelection = require('./copySelection.js');
|
|
8
|
+
var trackValue = require('./trackValue.js');
|
|
19
9
|
|
|
20
|
-
const isPrepared = Symbol('Node prepared with document state workarounds');
|
|
21
|
-
function prepareDocument(document) {
|
|
22
|
-
if (document[isPrepared]) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
document.addEventListener('focus', (e)=>{
|
|
26
|
-
const el = e.target;
|
|
27
|
-
prepareElement(el);
|
|
28
|
-
}, {
|
|
29
|
-
capture: true,
|
|
30
|
-
passive: true
|
|
31
|
-
});
|
|
32
|
-
// Our test environment defaults to `document.body` as `activeElement`.
|
|
33
|
-
// In other environments this might be `null` when preparing.
|
|
34
|
-
// istanbul ignore else
|
|
35
|
-
if (document.activeElement) {
|
|
36
|
-
prepareElement(document.activeElement);
|
|
37
|
-
}
|
|
38
|
-
document.addEventListener('blur', (e)=>{
|
|
39
|
-
const el = e.target;
|
|
40
|
-
const initialValue = value.getInitialValue(el);
|
|
41
|
-
if (initialValue !== undefined) {
|
|
42
|
-
if (el.value !== initialValue) {
|
|
43
|
-
index.dispatchUIEvent({}, el, 'change');
|
|
44
|
-
}
|
|
45
|
-
value.clearInitialValue(el);
|
|
46
|
-
}
|
|
47
|
-
}, {
|
|
48
|
-
capture: true,
|
|
49
|
-
passive: true
|
|
50
|
-
});
|
|
51
|
-
document[isPrepared] = isPrepared;
|
|
52
|
-
}
|
|
53
|
-
function prepareElement(el) {
|
|
54
|
-
if (el[isPrepared]) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
if (isElementType.isElementType(el, [
|
|
58
|
-
'input',
|
|
59
|
-
'textarea'
|
|
60
|
-
])) {
|
|
61
|
-
value.prepareValueInterceptor(el);
|
|
62
|
-
selection.prepareSelectionInterceptor(el);
|
|
63
|
-
setRangeText.prepareRangeTextInterceptor(el);
|
|
64
|
-
}
|
|
65
|
-
el[isPrepared] = isPrepared;
|
|
66
|
-
}
|
|
67
10
|
|
|
68
|
-
|
|
69
|
-
exports.
|
|
70
|
-
exports.
|
|
71
|
-
exports.
|
|
72
|
-
exports.
|
|
73
|
-
exports.setUIValue =
|
|
74
|
-
exports.
|
|
11
|
+
|
|
12
|
+
exports.clearInitialValue = UI.clearInitialValue;
|
|
13
|
+
exports.getUISelection = UI.getUISelection;
|
|
14
|
+
exports.getUIValue = UI.getUIValue;
|
|
15
|
+
exports.setUISelection = UI.setUISelection;
|
|
16
|
+
exports.setUIValue = UI.setUIValue;
|
|
17
|
+
exports.getValueOrTextContent = getValueOrTextContent.getValueOrTextContent;
|
|
18
|
+
exports.copySelection = copySelection.copySelection;
|
|
19
|
+
exports.commitValueAfterInput = trackValue.commitValueAfterInput;
|
|
@@ -2,23 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('../utils/click/isClickableInput.js');
|
|
6
|
+
require('../utils/dataTransfer/Clipboard.js');
|
|
7
|
+
require('../utils/edit/isEditable.js');
|
|
8
|
+
require('../utils/edit/maxLength.js');
|
|
9
|
+
var isElementType = require('../utils/misc/isElementType.js');
|
|
10
|
+
require('@testing-library/dom/dist/helpers.js');
|
|
11
|
+
require('../utils/keyDef/readNextDescriptor.js');
|
|
12
|
+
require('../utils/misc/level.js');
|
|
13
|
+
require('../options.js');
|
|
14
|
+
var trackValue = require('./trackValue.js');
|
|
15
|
+
var UI = require('./UI.js');
|
|
16
|
+
|
|
5
17
|
const Interceptor = Symbol('Interceptor for programmatical calls');
|
|
6
18
|
function prepareInterceptor(element, propName, interceptorImpl) {
|
|
19
|
+
var _prototypeDescriptor, _prototypeDescriptor1;
|
|
7
20
|
const prototypeDescriptor = Object.getOwnPropertyDescriptor(element.constructor.prototype, propName);
|
|
8
21
|
const objectDescriptor = Object.getOwnPropertyDescriptor(element, propName);
|
|
9
|
-
const target = (prototypeDescriptor === null ||
|
|
10
|
-
/* istanbul ignore if */ if (typeof (prototypeDescriptor === null ||
|
|
22
|
+
const target = ((_prototypeDescriptor = prototypeDescriptor) === null || _prototypeDescriptor === void 0 ? void 0 : _prototypeDescriptor.set) ? 'set' : 'value';
|
|
23
|
+
/* istanbul ignore if */ if (typeof ((_prototypeDescriptor1 = prototypeDescriptor) === null || _prototypeDescriptor1 === void 0 ? void 0 : _prototypeDescriptor1[target]) !== 'function' || prototypeDescriptor[target][Interceptor]) {
|
|
11
24
|
throw new Error(`Element ${element.tagName} does not implement "${String(propName)}".`);
|
|
12
25
|
}
|
|
13
26
|
function intercept(...args) {
|
|
14
|
-
|
|
27
|
+
var _then;
|
|
28
|
+
const { applyNative = false, realArgs, then } = interceptorImpl.call(this, ...args);
|
|
15
29
|
const realFunc = (!applyNative && objectDescriptor || prototypeDescriptor)[target];
|
|
16
30
|
if (target === 'set') {
|
|
17
31
|
realFunc.call(this, realArgs);
|
|
18
32
|
} else {
|
|
19
33
|
realFunc.call(this, ...realArgs);
|
|
20
34
|
}
|
|
21
|
-
then === null ||
|
|
35
|
+
(_then = then) === null || _then === void 0 ? void 0 : _then();
|
|
22
36
|
}
|
|
23
37
|
intercept[Interceptor] = Interceptor;
|
|
24
38
|
Object.defineProperty(element, propName, {
|
|
@@ -26,5 +40,76 @@ function prepareInterceptor(element, propName, interceptorImpl) {
|
|
|
26
40
|
[target]: intercept
|
|
27
41
|
});
|
|
28
42
|
}
|
|
43
|
+
function prepareValueInterceptor(element) {
|
|
44
|
+
prepareInterceptor(element, 'value', function interceptorImpl(v) {
|
|
45
|
+
const isUI = UI.isUIValue(v);
|
|
46
|
+
if (isUI) {
|
|
47
|
+
trackValue.startTrackValue(this);
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
applyNative: !!isUI,
|
|
51
|
+
realArgs: sanitizeValue(this, v),
|
|
52
|
+
then: isUI ? undefined : ()=>trackValue.trackOrSetValue(this, String(v))
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function sanitizeValue(element, v) {
|
|
57
|
+
// Workaround for JSDOM
|
|
58
|
+
if (isElementType.isElementType(element, 'input', {
|
|
59
|
+
type: 'number'
|
|
60
|
+
}) && String(v) !== '' && !Number.isNaN(Number(v))) {
|
|
61
|
+
// Setting value to "1." results in `null` in JSDOM
|
|
62
|
+
return String(Number(v));
|
|
63
|
+
}
|
|
64
|
+
return String(v);
|
|
65
|
+
}
|
|
66
|
+
function prepareSelectionInterceptor(element) {
|
|
67
|
+
prepareInterceptor(element, 'setSelectionRange', function interceptorImpl(start, ...others) {
|
|
68
|
+
const isUI = UI.isUISelectionStart(start);
|
|
69
|
+
return {
|
|
70
|
+
applyNative: !!isUI,
|
|
71
|
+
realArgs: [
|
|
72
|
+
Number(start),
|
|
73
|
+
...others
|
|
74
|
+
],
|
|
75
|
+
then: ()=>isUI ? undefined : UI.setUISelectionClean(element)
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
prepareInterceptor(element, 'selectionStart', function interceptorImpl(v) {
|
|
79
|
+
return {
|
|
80
|
+
realArgs: v,
|
|
81
|
+
then: ()=>UI.setUISelectionClean(element)
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
prepareInterceptor(element, 'selectionEnd', function interceptorImpl(v) {
|
|
85
|
+
return {
|
|
86
|
+
realArgs: v,
|
|
87
|
+
then: ()=>UI.setUISelectionClean(element)
|
|
88
|
+
};
|
|
89
|
+
});
|
|
90
|
+
prepareInterceptor(element, 'select', function interceptorImpl() {
|
|
91
|
+
return {
|
|
92
|
+
realArgs: [],
|
|
93
|
+
then: ()=>UI.setUISelectionRaw(element, {
|
|
94
|
+
anchorOffset: 0,
|
|
95
|
+
focusOffset: UI.getUIValue(element).length
|
|
96
|
+
})
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function prepareRangeTextInterceptor(element) {
|
|
101
|
+
prepareInterceptor(element, 'setRangeText', function interceptorImpl(...realArgs) {
|
|
102
|
+
return {
|
|
103
|
+
realArgs,
|
|
104
|
+
then: ()=>{
|
|
105
|
+
UI.setUIValueClean(element);
|
|
106
|
+
UI.setUISelectionClean(element);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
}
|
|
29
111
|
|
|
30
112
|
exports.prepareInterceptor = prepareInterceptor;
|
|
113
|
+
exports.prepareRangeTextInterceptor = prepareRangeTextInterceptor;
|
|
114
|
+
exports.prepareSelectionInterceptor = prepareSelectionInterceptor;
|
|
115
|
+
exports.prepareValueInterceptor = prepareValueInterceptor;
|