@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
package/dist/cjs/utils/index.js
CHANGED
|
@@ -7,26 +7,19 @@ var Blob = require('./dataTransfer/Blob.js');
|
|
|
7
7
|
var DataTransfer = require('./dataTransfer/DataTransfer.js');
|
|
8
8
|
var FileList = require('./dataTransfer/FileList.js');
|
|
9
9
|
var Clipboard = require('./dataTransfer/Clipboard.js');
|
|
10
|
-
var
|
|
11
|
-
var input = require('./edit/input.js');
|
|
10
|
+
var timeValue = require('./edit/timeValue.js');
|
|
12
11
|
var isContentEditable = require('./edit/isContentEditable.js');
|
|
13
12
|
var isEditable = require('./edit/isEditable.js');
|
|
13
|
+
var maxLength = require('./edit/maxLength.js');
|
|
14
14
|
var setFiles = require('./edit/setFiles.js');
|
|
15
|
-
var walkRadio = require('./edit/walkRadio.js');
|
|
16
|
-
var blur = require('./focus/blur.js');
|
|
17
|
-
var copySelection = require('./focus/copySelection.js');
|
|
18
15
|
var cursor = require('./focus/cursor.js');
|
|
19
|
-
var focus = require('./focus/focus.js');
|
|
20
16
|
var getActiveElement = require('./focus/getActiveElement.js');
|
|
21
17
|
var getTabDestination = require('./focus/getTabDestination.js');
|
|
22
18
|
var isFocusable = require('./focus/isFocusable.js');
|
|
23
|
-
var selectAll = require('./focus/selectAll.js');
|
|
24
|
-
var resolveCaretPosition = require('./focus/resolveCaretPosition.js');
|
|
25
19
|
var selection = require('./focus/selection.js');
|
|
26
20
|
var selector = require('./focus/selector.js');
|
|
27
21
|
var readNextDescriptor = require('./keyDef/readNextDescriptor.js');
|
|
28
22
|
var cloneEvent = require('./misc/cloneEvent.js');
|
|
29
|
-
var eventWrapper = require('./misc/eventWrapper.js');
|
|
30
23
|
var findClosest = require('./misc/findClosest.js');
|
|
31
24
|
var getDocumentFromNode = require('./misc/getDocumentFromNode.js');
|
|
32
25
|
var getTreeDiff = require('./misc/getTreeDiff.js');
|
|
@@ -52,43 +45,25 @@ exports.detachClipboardStubFromView = Clipboard.detachClipboardStubFromView;
|
|
|
52
45
|
exports.readDataTransferFromClipboard = Clipboard.readDataTransferFromClipboard;
|
|
53
46
|
exports.resetClipboardStubOnView = Clipboard.resetClipboardStubOnView;
|
|
54
47
|
exports.writeDataTransferToClipboard = Clipboard.writeDataTransferToClipboard;
|
|
55
|
-
exports.
|
|
56
|
-
exports.
|
|
48
|
+
exports.buildTimeValue = timeValue.buildTimeValue;
|
|
49
|
+
exports.isValidDateOrTimeValue = timeValue.isValidDateOrTimeValue;
|
|
57
50
|
exports.getContentEditable = isContentEditable.getContentEditable;
|
|
58
51
|
exports.isContentEditable = isContentEditable.isContentEditable;
|
|
59
|
-
Object.defineProperty(exports, 'editableInputTypes', {
|
|
60
|
-
enumerable: true,
|
|
61
|
-
get: function () { return isEditable.editableInputTypes; }
|
|
62
|
-
});
|
|
63
52
|
exports.isEditable = isEditable.isEditable;
|
|
64
|
-
exports.
|
|
53
|
+
exports.isEditableInputOrTextArea = isEditable.isEditableInputOrTextArea;
|
|
54
|
+
exports.getMaxLength = maxLength.getMaxLength;
|
|
55
|
+
exports.supportsMaxLength = maxLength.supportsMaxLength;
|
|
65
56
|
exports.setFiles = setFiles.setFiles;
|
|
66
|
-
exports.walkRadio = walkRadio.walkRadio;
|
|
67
|
-
exports.blur = blur.blur;
|
|
68
|
-
exports.copySelection = copySelection.copySelection;
|
|
69
57
|
exports.getNextCursorPosition = cursor.getNextCursorPosition;
|
|
70
|
-
exports.focus = focus.focus;
|
|
71
58
|
exports.getActiveElement = getActiveElement.getActiveElement;
|
|
72
59
|
exports.getActiveElementOrBody = getActiveElement.getActiveElementOrBody;
|
|
73
60
|
exports.getTabDestination = getTabDestination.getTabDestination;
|
|
74
61
|
exports.isFocusable = isFocusable.isFocusable;
|
|
75
|
-
exports.isAllSelected = selectAll.isAllSelected;
|
|
76
|
-
exports.selectAll = selectAll.selectAll;
|
|
77
|
-
exports.resolveCaretPosition = resolveCaretPosition.resolveCaretPosition;
|
|
78
|
-
exports.getInputRange = selection.getInputRange;
|
|
79
62
|
exports.hasNoSelection = selection.hasNoSelection;
|
|
80
63
|
exports.hasOwnSelection = selection.hasOwnSelection;
|
|
81
|
-
exports.modifySelection = selection.modifySelection;
|
|
82
|
-
exports.modifySelectionPerMouseMove = selection.modifySelectionPerMouseMove;
|
|
83
|
-
exports.moveSelection = selection.moveSelection;
|
|
84
|
-
exports.setSelection = selection.setSelection;
|
|
85
|
-
exports.setSelectionPerMouseDown = selection.setSelectionPerMouseDown;
|
|
86
|
-
exports.setSelectionRange = selection.setSelectionRange;
|
|
87
|
-
exports.updateSelectionOnFocus = selection.updateSelectionOnFocus;
|
|
88
64
|
exports.FOCUSABLE_SELECTOR = selector.FOCUSABLE_SELECTOR;
|
|
89
65
|
exports.readNextDescriptor = readNextDescriptor.readNextDescriptor;
|
|
90
66
|
exports.cloneEvent = cloneEvent.cloneEvent;
|
|
91
|
-
exports.eventWrapper = eventWrapper.eventWrapper;
|
|
92
67
|
exports.findClosest = findClosest.findClosest;
|
|
93
68
|
exports.getDocumentFromNode = getDocumentFromNode.getDocumentFromNode;
|
|
94
69
|
exports.getTreeDiff = getTreeDiff.getTreeDiff;
|
|
@@ -41,14 +41,16 @@ function readPrintableChar(text, pos, context) {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
function readTag(text, pos, startBracket, context) {
|
|
44
|
+
var ref, ref1;
|
|
44
45
|
const releasePreviousModifier = text[pos] === '/' ? '/' : '';
|
|
45
46
|
pos += releasePreviousModifier.length;
|
|
46
47
|
const escapedDescriptor = startBracket === '{' && text[pos] === '\\';
|
|
47
48
|
pos += Number(escapedDescriptor);
|
|
48
|
-
const descriptor = escapedDescriptor ? text[pos] : text.slice(pos).match(startBracket === '{' ? /^\w+|^[^}>/]/ : /^\w+/)
|
|
49
|
+
const descriptor = escapedDescriptor ? text[pos] : (ref = text.slice(pos).match(startBracket === '{' ? /^\w+|^[^}>/]/ : /^\w+/)) === null || ref === void 0 ? void 0 : ref[0];
|
|
49
50
|
assertDescriptor(descriptor, text, pos, context);
|
|
50
51
|
pos += descriptor.length;
|
|
51
|
-
|
|
52
|
+
var ref2;
|
|
53
|
+
const repeatModifier = (ref2 = (ref1 = text.slice(pos).match(/^>\d+/)) === null || ref1 === void 0 ? void 0 : ref1[0]) !== null && ref2 !== void 0 ? ref2 : '';
|
|
52
54
|
pos += repeatModifier.length;
|
|
53
55
|
const releaseSelfModifier = text[pos] === '/' || !repeatModifier && text[pos] === '>' ? text[pos] : '';
|
|
54
56
|
pos += releaseSelfModifier.length;
|
|
@@ -84,7 +86,7 @@ function hasReleaseSelf(releaseSelfModifier, repeatModifier) {
|
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
88
|
function getErrorMessage(expected, found, text, context) {
|
|
87
|
-
return `Expected ${expected} but found "${found
|
|
89
|
+
return `Expected ${expected} but found "${found !== null && found !== void 0 ? found : ''}" in "${text}"
|
|
88
90
|
See ${context === 'pointer' ? `https://testing-library.com/docs/user-event/pointer#pressing-a-button-or-touching-the-screen` : `https://testing-library.com/docs/user-event/keyboard`}
|
|
89
91
|
for more information about how userEvent parses your input.`;
|
|
90
92
|
}
|
|
@@ -19,7 +19,8 @@ function isDisabled(element) {
|
|
|
19
19
|
return true;
|
|
20
20
|
}
|
|
21
21
|
} else if (isElementType.isElementType(el, 'fieldset')) {
|
|
22
|
-
|
|
22
|
+
var ref;
|
|
23
|
+
if (el.hasAttribute('disabled') && !((ref = el.querySelector(':scope > legend')) === null || ref === void 0 ? void 0 : ref.contains(element))) {
|
|
23
24
|
return true;
|
|
24
25
|
}
|
|
25
26
|
} else if (el.tagName.includes('-')) {
|
|
@@ -6,7 +6,7 @@ var getWindow = require('./getWindow.js');
|
|
|
6
6
|
|
|
7
7
|
function isVisible(element) {
|
|
8
8
|
const window = getWindow.getWindow(element);
|
|
9
|
-
for(let el = element; el
|
|
9
|
+
for(let el = element; el === null || el === void 0 ? void 0 : el.ownerDocument; el = el.parentElement){
|
|
10
10
|
const { display , visibility } = window.getComputedStyle(el);
|
|
11
11
|
if (display === 'none') {
|
|
12
12
|
return false;
|
|
@@ -7,13 +7,11 @@ exports.ApiLevel = void 0;
|
|
|
7
7
|
ApiLevel[ApiLevel["Trigger"] = 2] = "Trigger";
|
|
8
8
|
ApiLevel[ApiLevel["Call"] = 1] = "Call";
|
|
9
9
|
})(exports.ApiLevel || (exports.ApiLevel = {}));
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
config[Level] ??= {};
|
|
13
|
-
config[Level][level] = {};
|
|
10
|
+
function setLevelRef(instance, level) {
|
|
11
|
+
instance.levelRefs[level] = {};
|
|
14
12
|
}
|
|
15
|
-
function getLevelRef(
|
|
16
|
-
return
|
|
13
|
+
function getLevelRef(instance, level) {
|
|
14
|
+
return instance.levelRefs[level];
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
exports.getLevelRef = getLevelRef;
|
|
@@ -3,29 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var options = require('../../options.js');
|
|
6
|
-
require('../click/isClickableInput.js');
|
|
7
|
-
require('../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('../edit/maxLength.js');
|
|
17
|
-
require('../edit/isEditable.js');
|
|
18
|
-
var isElementType = require('../misc/isElementType.js');
|
|
19
6
|
var getWindow = require('../misc/getWindow.js');
|
|
20
|
-
require('../
|
|
7
|
+
var isElementType = require('../misc/isElementType.js');
|
|
21
8
|
var level = require('../misc/level.js');
|
|
22
9
|
|
|
23
|
-
function hasPointerEvents(
|
|
24
|
-
|
|
10
|
+
function hasPointerEvents(instance, element) {
|
|
11
|
+
var ref;
|
|
12
|
+
return ((ref = checkPointerEvents(instance, element)) === null || ref === void 0 ? void 0 : ref.pointerEvents) !== 'none';
|
|
25
13
|
}
|
|
26
14
|
function closestPointerEventsDeclaration(element) {
|
|
27
15
|
const window = getWindow.getWindow(element);
|
|
28
|
-
for(let el = element, tree = []; el
|
|
16
|
+
for(let el = element, tree = []; el === null || el === void 0 ? void 0 : el.ownerDocument; el = el.parentElement){
|
|
29
17
|
tree.push(el);
|
|
30
18
|
const pointerEvents = window.getComputedStyle(el).pointerEvents;
|
|
31
19
|
if (pointerEvents && ![
|
|
@@ -41,23 +29,23 @@ function closestPointerEventsDeclaration(element) {
|
|
|
41
29
|
return undefined;
|
|
42
30
|
}
|
|
43
31
|
const PointerEventsCheck = Symbol('Last check for pointer-events');
|
|
44
|
-
function checkPointerEvents(
|
|
32
|
+
function checkPointerEvents(instance, element) {
|
|
45
33
|
const lastCheck = element[PointerEventsCheck];
|
|
46
|
-
const needsCheck = config.pointerEventsCheck !== options.PointerEventsCheckLevel.Never && (!lastCheck || hasBitFlag(config.pointerEventsCheck, options.PointerEventsCheckLevel.EachApiCall) && lastCheck[level.ApiLevel.Call] !== level.getLevelRef(
|
|
34
|
+
const needsCheck = instance.config.pointerEventsCheck !== options.PointerEventsCheckLevel.Never && (!lastCheck || hasBitFlag(instance.config.pointerEventsCheck, options.PointerEventsCheckLevel.EachApiCall) && lastCheck[level.ApiLevel.Call] !== level.getLevelRef(instance, level.ApiLevel.Call) || hasBitFlag(instance.config.pointerEventsCheck, options.PointerEventsCheckLevel.EachTrigger) && lastCheck[level.ApiLevel.Trigger] !== level.getLevelRef(instance, level.ApiLevel.Trigger));
|
|
47
35
|
if (!needsCheck) {
|
|
48
|
-
return lastCheck
|
|
36
|
+
return lastCheck === null || lastCheck === void 0 ? void 0 : lastCheck.result;
|
|
49
37
|
}
|
|
50
38
|
const declaration = closestPointerEventsDeclaration(element);
|
|
51
39
|
element[PointerEventsCheck] = {
|
|
52
|
-
[level.ApiLevel.Call]: level.getLevelRef(
|
|
53
|
-
[level.ApiLevel.Trigger]: level.getLevelRef(
|
|
40
|
+
[level.ApiLevel.Call]: level.getLevelRef(instance, level.ApiLevel.Call),
|
|
41
|
+
[level.ApiLevel.Trigger]: level.getLevelRef(instance, level.ApiLevel.Trigger),
|
|
54
42
|
result: declaration
|
|
55
43
|
};
|
|
56
44
|
return declaration;
|
|
57
45
|
}
|
|
58
|
-
function assertPointerEvents(
|
|
59
|
-
const declaration = checkPointerEvents(
|
|
60
|
-
if (declaration
|
|
46
|
+
function assertPointerEvents(instance, element) {
|
|
47
|
+
const declaration = checkPointerEvents(instance, element);
|
|
48
|
+
if ((declaration === null || declaration === void 0 ? void 0 : declaration.pointerEvents) === 'none') {
|
|
61
49
|
throw new Error([
|
|
62
50
|
`Unable to perform pointer interaction as the element ${declaration.tree.length > 1 ? 'inherits' : 'has'} \`pointer-events: none\`:`,
|
|
63
51
|
'',
|
|
@@ -77,11 +65,13 @@ function printTree(tree) {
|
|
|
77
65
|
].filter(Boolean).join('')).join('\n');
|
|
78
66
|
}
|
|
79
67
|
function getLabelDescr(element) {
|
|
68
|
+
var ref;
|
|
80
69
|
let label;
|
|
81
70
|
if (element.hasAttribute('aria-label')) {
|
|
82
71
|
label = element.getAttribute('aria-label');
|
|
83
72
|
} else if (element.hasAttribute('aria-labelledby')) {
|
|
84
|
-
|
|
73
|
+
var ref1, ref2;
|
|
74
|
+
label = (ref1 = element.ownerDocument.getElementById(element.getAttribute('aria-labelledby'))) === null || ref1 === void 0 ? void 0 : (ref2 = ref1.textContent) === null || ref2 === void 0 ? void 0 : ref2.trim();
|
|
85
75
|
} else if (isElementType.isElementType(element, [
|
|
86
76
|
'button',
|
|
87
77
|
'input',
|
|
@@ -90,14 +80,18 @@ function getLabelDescr(element) {
|
|
|
90
80
|
'progress',
|
|
91
81
|
'select',
|
|
92
82
|
'textarea',
|
|
93
|
-
]) && element.labels
|
|
94
|
-
label = Array.from(element.labels).map((el)=>
|
|
83
|
+
]) && ((ref = element.labels) === null || ref === void 0 ? void 0 : ref.length)) {
|
|
84
|
+
label = Array.from(element.labels).map((el)=>{
|
|
85
|
+
var ref;
|
|
86
|
+
return (ref = el.textContent) === null || ref === void 0 ? void 0 : ref.trim();
|
|
87
|
+
}).join('|');
|
|
95
88
|
} else if (isElementType.isElementType(element, 'button')) {
|
|
96
|
-
|
|
89
|
+
var ref3;
|
|
90
|
+
label = (ref3 = element.textContent) === null || ref3 === void 0 ? void 0 : ref3.trim();
|
|
97
91
|
}
|
|
98
|
-
label = label
|
|
99
|
-
if (Number(label
|
|
100
|
-
label = `${label
|
|
92
|
+
label = label === null || label === void 0 ? void 0 : label.replace(/\n/g, ' ');
|
|
93
|
+
if (Number(label === null || label === void 0 ? void 0 : label.length) > 30) {
|
|
94
|
+
label = `${label === null || label === void 0 ? void 0 : label.substring(0, 29)}…`;
|
|
101
95
|
}
|
|
102
96
|
return label ? `(label=${label})` : '';
|
|
103
97
|
}
|
|
@@ -1,33 +1,24 @@
|
|
|
1
|
-
import '../setup/index.js';
|
|
2
1
|
import '../utils/click/isClickableInput.js';
|
|
3
2
|
import { writeDataTransferToClipboard } from '../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../event/eventMap.js';
|
|
5
|
-
import '../event/behavior/click.js';
|
|
6
|
-
import '../event/behavior/cut.js';
|
|
7
|
-
import '../event/behavior/keydown.js';
|
|
8
|
-
import '../event/behavior/keypress.js';
|
|
9
|
-
import '../event/behavior/keyup.js';
|
|
10
|
-
import '../event/behavior/paste.js';
|
|
11
|
-
import '@testing-library/dom';
|
|
12
|
-
import '../utils/edit/maxLength.js';
|
|
13
3
|
import '../utils/edit/isEditable.js';
|
|
4
|
+
import '../utils/edit/maxLength.js';
|
|
14
5
|
import '@testing-library/dom/dist/helpers.js';
|
|
15
|
-
import { copySelection } from '../utils/focus/copySelection.js';
|
|
16
6
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
17
7
|
import '../utils/misc/level.js';
|
|
18
8
|
import '../options.js';
|
|
19
|
-
import {
|
|
9
|
+
import { copySelection } from '../document/copySelection.js';
|
|
20
10
|
|
|
21
11
|
async function copy() {
|
|
22
|
-
const doc = this
|
|
23
|
-
|
|
12
|
+
const doc = this.config.document;
|
|
13
|
+
var _activeElement;
|
|
14
|
+
const target = (_activeElement = doc.activeElement) !== null && _activeElement !== void 0 ? _activeElement : /* istanbul ignore next */ doc.body;
|
|
24
15
|
const clipboardData = copySelection(target);
|
|
25
16
|
if (clipboardData.items.length === 0) {
|
|
26
17
|
return;
|
|
27
18
|
}
|
|
28
19
|
if (this.dispatchUIEvent(target, 'copy', {
|
|
29
20
|
clipboardData
|
|
30
|
-
}) && this
|
|
21
|
+
}) && this.config.writeToClipboard) {
|
|
31
22
|
await writeDataTransferToClipboard(doc, clipboardData);
|
|
32
23
|
}
|
|
33
24
|
return clipboardData;
|
|
@@ -1,33 +1,24 @@
|
|
|
1
|
-
import '../setup/index.js';
|
|
2
1
|
import '../utils/click/isClickableInput.js';
|
|
3
2
|
import { writeDataTransferToClipboard } from '../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../event/eventMap.js';
|
|
5
|
-
import '../event/behavior/click.js';
|
|
6
|
-
import '../event/behavior/cut.js';
|
|
7
|
-
import '../event/behavior/keydown.js';
|
|
8
|
-
import '../event/behavior/keypress.js';
|
|
9
|
-
import '../event/behavior/keyup.js';
|
|
10
|
-
import '../event/behavior/paste.js';
|
|
11
|
-
import '@testing-library/dom';
|
|
12
|
-
import '../utils/edit/maxLength.js';
|
|
13
3
|
import '../utils/edit/isEditable.js';
|
|
4
|
+
import '../utils/edit/maxLength.js';
|
|
14
5
|
import '@testing-library/dom/dist/helpers.js';
|
|
15
|
-
import { copySelection } from '../utils/focus/copySelection.js';
|
|
16
6
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
17
7
|
import '../utils/misc/level.js';
|
|
18
8
|
import '../options.js';
|
|
19
|
-
import {
|
|
9
|
+
import { copySelection } from '../document/copySelection.js';
|
|
20
10
|
|
|
21
11
|
async function cut() {
|
|
22
|
-
const doc = this
|
|
23
|
-
|
|
12
|
+
const doc = this.config.document;
|
|
13
|
+
var _activeElement;
|
|
14
|
+
const target = (_activeElement = doc.activeElement) !== null && _activeElement !== void 0 ? _activeElement : /* istanbul ignore next */ doc.body;
|
|
24
15
|
const clipboardData = copySelection(target);
|
|
25
16
|
if (clipboardData.items.length === 0) {
|
|
26
17
|
return;
|
|
27
18
|
}
|
|
28
19
|
if (this.dispatchUIEvent(target, 'cut', {
|
|
29
20
|
clipboardData
|
|
30
|
-
}) && this
|
|
21
|
+
}) && this.config.writeToClipboard) {
|
|
31
22
|
await writeDataTransferToClipboard(target.ownerDocument, clipboardData);
|
|
32
23
|
}
|
|
33
24
|
return clipboardData;
|
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
import '../setup/index.js';
|
|
2
1
|
import '../utils/click/isClickableInput.js';
|
|
3
2
|
import { createDataTransfer } from '../utils/dataTransfer/DataTransfer.js';
|
|
4
3
|
import { readDataTransferFromClipboard } from '../utils/dataTransfer/Clipboard.js';
|
|
5
|
-
import '../event/eventMap.js';
|
|
6
|
-
import '../event/behavior/click.js';
|
|
7
|
-
import '../event/behavior/cut.js';
|
|
8
|
-
import '../event/behavior/keydown.js';
|
|
9
|
-
import '../event/behavior/keypress.js';
|
|
10
|
-
import '../event/behavior/keyup.js';
|
|
11
|
-
import '../event/behavior/paste.js';
|
|
12
|
-
import '@testing-library/dom';
|
|
13
|
-
import '../utils/edit/maxLength.js';
|
|
14
4
|
import '../utils/edit/isEditable.js';
|
|
5
|
+
import '../utils/edit/maxLength.js';
|
|
15
6
|
import { getWindow } from '../utils/misc/getWindow.js';
|
|
16
7
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
17
8
|
import '../utils/misc/level.js';
|
|
18
9
|
import '../options.js';
|
|
19
|
-
import { Config } from '../setup/config.js';
|
|
20
10
|
|
|
21
11
|
async function paste(clipboardData) {
|
|
22
|
-
const doc = this
|
|
23
|
-
|
|
24
|
-
const
|
|
12
|
+
const doc = this.config.document;
|
|
13
|
+
var _activeElement;
|
|
14
|
+
const target = (_activeElement = doc.activeElement) !== null && _activeElement !== void 0 ? _activeElement : /* istanbul ignore next */ doc.body;
|
|
15
|
+
var ref;
|
|
16
|
+
const dataTransfer = (ref = typeof clipboardData === 'string' ? getClipboardDataFromString(doc, clipboardData) : clipboardData) !== null && ref !== void 0 ? ref : await readDataTransferFromClipboard(doc).catch(()=>{
|
|
25
17
|
throw new Error('`userEvent.paste()` without `clipboardData` requires the `ClipboardAPI` to be available.');
|
|
26
18
|
});
|
|
27
19
|
this.dispatchUIEvent(target, 'paste', {
|
|
@@ -1,21 +1,11 @@
|
|
|
1
|
-
import '../setup/index.js';
|
|
2
1
|
import '../utils/click/isClickableInput.js';
|
|
3
2
|
import '../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../event/eventMap.js';
|
|
5
|
-
import '../event/behavior/click.js';
|
|
6
|
-
import '../event/behavior/cut.js';
|
|
7
|
-
import '../event/behavior/keydown.js';
|
|
8
|
-
import '../event/behavior/keypress.js';
|
|
9
|
-
import '../event/behavior/keyup.js';
|
|
10
|
-
import '../event/behavior/paste.js';
|
|
11
|
-
import '@testing-library/dom';
|
|
12
|
-
import '../utils/edit/maxLength.js';
|
|
13
3
|
import '../utils/edit/isEditable.js';
|
|
4
|
+
import '../utils/edit/maxLength.js';
|
|
14
5
|
import '@testing-library/dom/dist/helpers.js';
|
|
15
6
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
16
7
|
import '../utils/misc/level.js';
|
|
17
8
|
import { assertPointerEvents } from '../utils/pointer/cssPointerEvents.js';
|
|
18
|
-
import { Config } from '../setup/config.js';
|
|
19
9
|
|
|
20
10
|
async function hover(element) {
|
|
21
11
|
return this.pointer({
|
|
@@ -23,7 +13,7 @@ async function hover(element) {
|
|
|
23
13
|
});
|
|
24
14
|
}
|
|
25
15
|
async function unhover(element) {
|
|
26
|
-
assertPointerEvents(this
|
|
16
|
+
assertPointerEvents(this, this.system.pointer.getMouseTarget(this));
|
|
27
17
|
return this.pointer({
|
|
28
18
|
target: element.ownerDocument.body
|
|
29
19
|
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const UIValue = Symbol('Displayed value in UI');
|
|
2
|
+
const UISelection = Symbol('Displayed selection in UI');
|
|
3
|
+
const InitialValue = Symbol('Initial value to compare on blur');
|
|
4
|
+
function isUIValue(value) {
|
|
5
|
+
return typeof value === 'object' && UIValue in value;
|
|
6
|
+
}
|
|
7
|
+
function isUISelectionStart(start) {
|
|
8
|
+
return !!start && typeof start === 'object' && UISelection in start;
|
|
9
|
+
}
|
|
10
|
+
function setUIValue(element, value) {
|
|
11
|
+
if (element[InitialValue] === undefined) {
|
|
12
|
+
element[InitialValue] = element.value;
|
|
13
|
+
}
|
|
14
|
+
element[UIValue] = value;
|
|
15
|
+
// eslint-disable-next-line no-new-wrappers
|
|
16
|
+
element.value = Object.assign(new String(value), {
|
|
17
|
+
[UIValue]: true
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function getUIValue(element) {
|
|
21
|
+
return element[UIValue] === undefined ? element.value : String(element[UIValue]);
|
|
22
|
+
}
|
|
23
|
+
/** Flag the IDL value as clean. This does not change the value.*/ function setUIValueClean(element) {
|
|
24
|
+
element[UIValue] = undefined;
|
|
25
|
+
}
|
|
26
|
+
function clearInitialValue(element) {
|
|
27
|
+
element[InitialValue] = undefined;
|
|
28
|
+
}
|
|
29
|
+
function getInitialValue(element) {
|
|
30
|
+
return element[InitialValue];
|
|
31
|
+
}
|
|
32
|
+
function setUISelectionRaw(element, selection) {
|
|
33
|
+
element[UISelection] = selection;
|
|
34
|
+
}
|
|
35
|
+
function setUISelection(element, { focusOffset: focusOffsetParam , anchorOffset: anchorOffsetParam = focusOffsetParam }, mode = 'replace') {
|
|
36
|
+
const valueLength = getUIValue(element).length;
|
|
37
|
+
const sanitizeOffset = (o)=>Math.max(0, Math.min(valueLength, o));
|
|
38
|
+
const anchorOffset = mode === 'replace' || element[UISelection] === undefined ? sanitizeOffset(anchorOffsetParam) : element[UISelection].anchorOffset;
|
|
39
|
+
const focusOffset = sanitizeOffset(focusOffsetParam);
|
|
40
|
+
const startOffset = Math.min(anchorOffset, focusOffset);
|
|
41
|
+
const endOffset = Math.max(anchorOffset, focusOffset);
|
|
42
|
+
element[UISelection] = {
|
|
43
|
+
anchorOffset,
|
|
44
|
+
focusOffset
|
|
45
|
+
};
|
|
46
|
+
if (element.selectionStart === startOffset && element.selectionEnd === endOffset) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
// eslint-disable-next-line no-new-wrappers
|
|
50
|
+
const startObj = Object.assign(new Number(startOffset), {
|
|
51
|
+
[UISelection]: true
|
|
52
|
+
});
|
|
53
|
+
try {
|
|
54
|
+
element.setSelectionRange(startObj, endOffset);
|
|
55
|
+
} catch {
|
|
56
|
+
// DOMException for invalid state is expected when calling this
|
|
57
|
+
// on an element without support for setSelectionRange
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function getUISelection(element) {
|
|
61
|
+
var _selectionStart, _selectionEnd, _UISelection;
|
|
62
|
+
const sel = (_UISelection = element[UISelection]) !== null && _UISelection !== void 0 ? _UISelection : {
|
|
63
|
+
anchorOffset: (_selectionStart = element.selectionStart) !== null && _selectionStart !== void 0 ? _selectionStart : 0,
|
|
64
|
+
focusOffset: (_selectionEnd = element.selectionEnd) !== null && _selectionEnd !== void 0 ? _selectionEnd : 0
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
...sel,
|
|
68
|
+
startOffset: Math.min(sel.anchorOffset, sel.focusOffset),
|
|
69
|
+
endOffset: Math.max(sel.anchorOffset, sel.focusOffset)
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function hasUISelection(element) {
|
|
73
|
+
return !!element[UISelection];
|
|
74
|
+
}
|
|
75
|
+
/** Flag the IDL selection as clean. This does not change the selection. */ function setUISelectionClean(element) {
|
|
76
|
+
element[UISelection] = undefined;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { clearInitialValue, getInitialValue, getUISelection, getUIValue, hasUISelection, isUISelectionStart, isUIValue, setUISelection, setUISelectionClean, setUISelectionRaw, setUIValue, setUIValueClean };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import '../utils/click/isClickableInput.js';
|
|
2
|
+
import { createDataTransfer } from '../utils/dataTransfer/DataTransfer.js';
|
|
3
|
+
import '../utils/dataTransfer/Clipboard.js';
|
|
4
|
+
import '../utils/edit/isEditable.js';
|
|
5
|
+
import '../utils/edit/maxLength.js';
|
|
6
|
+
import { getWindow } from '../utils/misc/getWindow.js';
|
|
7
|
+
import { hasOwnSelection } from '../utils/focus/selection.js';
|
|
8
|
+
import '../utils/keyDef/readNextDescriptor.js';
|
|
9
|
+
import '../utils/misc/level.js';
|
|
10
|
+
import '../options.js';
|
|
11
|
+
import { getUISelection, getUIValue } from './UI.js';
|
|
12
|
+
|
|
13
|
+
function copySelection(target) {
|
|
14
|
+
const data = hasOwnSelection(target) ? {
|
|
15
|
+
'text/plain': readSelectedValueFromInput(target)
|
|
16
|
+
} : {
|
|
17
|
+
'text/plain': String(target.ownerDocument.getSelection())
|
|
18
|
+
};
|
|
19
|
+
const dt = createDataTransfer(getWindow(target));
|
|
20
|
+
for(const type in data){
|
|
21
|
+
if (data[type]) {
|
|
22
|
+
dt.setData(type, data[type]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return dt;
|
|
26
|
+
}
|
|
27
|
+
function readSelectedValueFromInput(target) {
|
|
28
|
+
const sel = getUISelection(target);
|
|
29
|
+
const val = getUIValue(target);
|
|
30
|
+
return val.substring(sel.startOffset, sel.endOffset);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { copySelection };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import '../utils/click/isClickableInput.js';
|
|
2
|
+
import '../utils/dataTransfer/Clipboard.js';
|
|
3
|
+
import { isContentEditable } from '../utils/edit/isContentEditable.js';
|
|
4
|
+
import '../utils/edit/isEditable.js';
|
|
5
|
+
import '../utils/edit/maxLength.js';
|
|
6
|
+
import '@testing-library/dom/dist/helpers.js';
|
|
7
|
+
import '../utils/keyDef/readNextDescriptor.js';
|
|
8
|
+
import '../utils/misc/level.js';
|
|
9
|
+
import '../options.js';
|
|
10
|
+
import { getUIValue } from './UI.js';
|
|
11
|
+
|
|
12
|
+
function getValueOrTextContent(element) {
|
|
13
|
+
// istanbul ignore if
|
|
14
|
+
if (!element) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
if (isContentEditable(element)) {
|
|
18
|
+
return element.textContent;
|
|
19
|
+
}
|
|
20
|
+
return getUIValue(element);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { getValueOrTextContent };
|
|
@@ -1,66 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import '../utils/edit/isEditable.js';
|
|
6
|
-
import '@testing-library/dom';
|
|
7
|
-
import { isElementType } from '../utils/misc/isElementType.js';
|
|
8
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
9
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
10
|
-
import '../utils/misc/level.js';
|
|
11
|
-
import '../options.js';
|
|
12
|
-
import { prepareSelectionInterceptor } from './selection.js';
|
|
13
|
-
export { getUISelection, setUISelection } from './selection.js';
|
|
14
|
-
import { prepareRangeTextInterceptor } from './setRangeText.js';
|
|
15
|
-
import { getInitialValue, clearInitialValue, prepareValueInterceptor } from './value.js';
|
|
16
|
-
export { clearInitialValue, commitValueAfterInput, getUIValue, setUIValue } from './value.js';
|
|
17
|
-
|
|
18
|
-
const isPrepared = Symbol('Node prepared with document state workarounds');
|
|
19
|
-
function prepareDocument(document) {
|
|
20
|
-
if (document[isPrepared]) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
document.addEventListener('focus', (e)=>{
|
|
24
|
-
const el = e.target;
|
|
25
|
-
prepareElement(el);
|
|
26
|
-
}, {
|
|
27
|
-
capture: true,
|
|
28
|
-
passive: true
|
|
29
|
-
});
|
|
30
|
-
// Our test environment defaults to `document.body` as `activeElement`.
|
|
31
|
-
// In other environments this might be `null` when preparing.
|
|
32
|
-
// istanbul ignore else
|
|
33
|
-
if (document.activeElement) {
|
|
34
|
-
prepareElement(document.activeElement);
|
|
35
|
-
}
|
|
36
|
-
document.addEventListener('blur', (e)=>{
|
|
37
|
-
const el = e.target;
|
|
38
|
-
const initialValue = getInitialValue(el);
|
|
39
|
-
if (initialValue !== undefined) {
|
|
40
|
-
if (el.value !== initialValue) {
|
|
41
|
-
dispatchUIEvent({}, el, 'change');
|
|
42
|
-
}
|
|
43
|
-
clearInitialValue(el);
|
|
44
|
-
}
|
|
45
|
-
}, {
|
|
46
|
-
capture: true,
|
|
47
|
-
passive: true
|
|
48
|
-
});
|
|
49
|
-
document[isPrepared] = isPrepared;
|
|
50
|
-
}
|
|
51
|
-
function prepareElement(el) {
|
|
52
|
-
if (el[isPrepared]) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (isElementType(el, [
|
|
56
|
-
'input',
|
|
57
|
-
'textarea'
|
|
58
|
-
])) {
|
|
59
|
-
prepareValueInterceptor(el);
|
|
60
|
-
prepareSelectionInterceptor(el);
|
|
61
|
-
prepareRangeTextInterceptor(el);
|
|
62
|
-
}
|
|
63
|
-
el[isPrepared] = isPrepared;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export { prepareDocument };
|
|
1
|
+
export { clearInitialValue, getUISelection, getUIValue, setUISelection, setUIValue } from './UI.js';
|
|
2
|
+
export { getValueOrTextContent } from './getValueOrTextContent.js';
|
|
3
|
+
export { copySelection } from './copySelection.js';
|
|
4
|
+
export { commitValueAfterInput } from './trackValue.js';
|