@testing-library/user-event 14.5.0 → 14.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/_interop/dtl.js +4 -7
- package/dist/cjs/_interop/dtlEventMap.js +4 -7
- package/dist/cjs/_interop/dtlHelpers.js +4 -7
- package/dist/cjs/document/interceptor.js +3 -5
- package/dist/cjs/document/trackValue.js +2 -2
- package/dist/cjs/event/behavior/keydown.js +2 -2
- package/dist/cjs/event/behavior/keypress.js +1 -2
- package/dist/cjs/event/behavior/keyup.js +2 -2
- package/dist/cjs/event/dispatchEvent.js +2 -2
- package/dist/cjs/event/eventMap.js +22 -2
- package/dist/cjs/event/focus.js +1 -4
- package/dist/cjs/event/selection/getTargetTypeAndSelection.js +2 -3
- package/dist/cjs/event/selection/modifySelectionPerMouse.js +2 -3
- package/dist/cjs/event/selection/moveSelection.js +1 -2
- package/dist/cjs/event/selection/selectAll.js +1 -2
- package/dist/cjs/event/selection/setSelectionPerMouse.js +2 -3
- package/dist/cjs/event/selection/updateSelectionOnFocus.js +1 -2
- package/dist/cjs/event/wrapEvent.js +22 -2
- package/dist/cjs/pointer/index.js +4 -4
- package/dist/cjs/setup/wrapAsync.js +22 -2
- package/dist/cjs/system/pointer/index.js +12 -15
- package/dist/cjs/utility/selectOptions.js +22 -2
- package/dist/cjs/utility/upload.js +1 -2
- package/dist/cjs/utils/dataTransfer/Clipboard.js +2 -4
- package/dist/cjs/utils/dataTransfer/DataTransfer.js +1 -2
- package/dist/cjs/utils/edit/setFiles.js +2 -2
- package/dist/cjs/utils/focus/getActiveElement.js +1 -2
- package/dist/cjs/utils/misc/getWindow.js +22 -2
- package/dist/cjs/utils/misc/isVisible.js +1 -2
- package/dist/cjs/utils/pointer/cssPointerEvents.js +7 -11
- package/dist/esm/_interop/dtl.js +2 -6
- package/dist/esm/_interop/dtlEventMap.js +2 -6
- package/dist/esm/_interop/dtlHelpers.js +2 -6
- package/dist/esm/document/interceptor.js +3 -5
- package/dist/esm/document/trackValue.js +2 -2
- package/dist/esm/event/behavior/keydown.js +2 -2
- package/dist/esm/event/behavior/keypress.js +1 -2
- package/dist/esm/event/behavior/keyup.js +2 -2
- package/dist/esm/event/dispatchEvent.js +2 -2
- package/dist/esm/event/eventMap.js +2 -2
- package/dist/esm/event/focus.js +1 -4
- package/dist/esm/event/selection/getTargetTypeAndSelection.js +2 -3
- package/dist/esm/event/selection/modifySelectionPerMouse.js +2 -3
- package/dist/esm/event/selection/moveSelection.js +1 -2
- package/dist/esm/event/selection/selectAll.js +1 -2
- package/dist/esm/event/selection/setSelectionPerMouse.js +2 -3
- package/dist/esm/event/selection/updateSelectionOnFocus.js +1 -2
- package/dist/esm/event/wrapEvent.js +2 -2
- package/dist/esm/pointer/index.js +4 -4
- package/dist/esm/setup/wrapAsync.js +2 -2
- package/dist/esm/system/pointer/index.js +12 -15
- package/dist/esm/utility/selectOptions.js +2 -2
- package/dist/esm/utility/upload.js +1 -2
- package/dist/esm/utils/dataTransfer/Clipboard.js +2 -4
- package/dist/esm/utils/dataTransfer/DataTransfer.js +1 -2
- package/dist/esm/utils/edit/setFiles.js +2 -2
- package/dist/esm/utils/focus/getActiveElement.js +1 -2
- package/dist/esm/utils/misc/getWindow.js +2 -2
- package/dist/esm/utils/misc/isVisible.js +1 -2
- package/dist/esm/utils/pointer/cssPointerEvents.js +7 -11
- package/dist/types/_interop/dtl.d.ts +2 -3
- package/dist/types/_interop/dtlEventMap.d.ts +2 -3
- package/dist/types/_interop/dtlHelpers.d.ts +2 -3
- package/package.json +1 -1
|
@@ -12,9 +12,8 @@ function hasPointerEvents(instance, element) {
|
|
|
12
12
|
return ((_checkPointerEvents = checkPointerEvents(instance, element)) === null || _checkPointerEvents === void 0 ? void 0 : _checkPointerEvents.pointerEvents) !== 'none';
|
|
13
13
|
}
|
|
14
14
|
function closestPointerEventsDeclaration(element) {
|
|
15
|
-
var _el;
|
|
16
15
|
const window = getWindow.getWindow(element);
|
|
17
|
-
for(let el = element, tree = [];
|
|
16
|
+
for(let el = element, tree = []; el === null || el === void 0 ? void 0 : el.ownerDocument; el = el.parentElement){
|
|
18
17
|
tree.push(el);
|
|
19
18
|
const pointerEvents = window.getComputedStyle(el).pointerEvents;
|
|
20
19
|
if (pointerEvents && ![
|
|
@@ -34,8 +33,7 @@ function checkPointerEvents(instance, element) {
|
|
|
34
33
|
const lastCheck = element[PointerEventsCheck];
|
|
35
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));
|
|
36
35
|
if (!needsCheck) {
|
|
37
|
-
|
|
38
|
-
return (_lastCheck = lastCheck) === null || _lastCheck === void 0 ? void 0 : _lastCheck.result;
|
|
36
|
+
return lastCheck === null || lastCheck === void 0 ? void 0 : lastCheck.result;
|
|
39
37
|
}
|
|
40
38
|
const declaration = closestPointerEventsDeclaration(element);
|
|
41
39
|
element[PointerEventsCheck] = {
|
|
@@ -46,9 +44,8 @@ function checkPointerEvents(instance, element) {
|
|
|
46
44
|
return declaration;
|
|
47
45
|
}
|
|
48
46
|
function assertPointerEvents(instance, element) {
|
|
49
|
-
var _declaration;
|
|
50
47
|
const declaration = checkPointerEvents(instance, element);
|
|
51
|
-
if ((
|
|
48
|
+
if ((declaration === null || declaration === void 0 ? void 0 : declaration.pointerEvents) === 'none') {
|
|
52
49
|
throw new Error([
|
|
53
50
|
`Unable to perform pointer interaction as the element ${declaration.tree.length > 1 ? 'inherits' : 'has'} \`pointer-events: none\`:`,
|
|
54
51
|
'',
|
|
@@ -68,7 +65,7 @@ function printTree(tree) {
|
|
|
68
65
|
].filter(Boolean).join('')).join('\n');
|
|
69
66
|
}
|
|
70
67
|
function getLabelDescr(element) {
|
|
71
|
-
var _element_labels
|
|
68
|
+
var _element_labels;
|
|
72
69
|
let label;
|
|
73
70
|
if (element.hasAttribute('aria-label')) {
|
|
74
71
|
label = element.getAttribute('aria-label');
|
|
@@ -92,10 +89,9 @@ function getLabelDescr(element) {
|
|
|
92
89
|
var _element_textContent;
|
|
93
90
|
label = (_element_textContent = element.textContent) === null || _element_textContent === void 0 ? void 0 : _element_textContent.trim();
|
|
94
91
|
}
|
|
95
|
-
label =
|
|
96
|
-
if (Number(
|
|
97
|
-
|
|
98
|
-
label = `${(_label2 = label) === null || _label2 === void 0 ? void 0 : _label2.substring(0, 29)}…`;
|
|
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)}…`;
|
|
99
95
|
}
|
|
100
96
|
return label ? `(label=${label})` : '';
|
|
101
97
|
}
|
package/dist/esm/_interop/dtl.js
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var dtl = def__default !== null && def__default !== void 0 ? def__default : def;
|
|
5
|
-
|
|
6
|
-
export { dtl as default };
|
|
1
|
+
import * as named from '@testing-library/dom';
|
|
2
|
+
export { named as default };
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var dtlEvents = def__default !== null && def__default !== void 0 ? def__default : def;
|
|
5
|
-
|
|
6
|
-
export { dtlEvents as default };
|
|
1
|
+
import * as named from '@testing-library/dom/dist/event-map.js';
|
|
2
|
+
export { named as default };
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var dtlHelpers = def__default !== null && def__default !== void 0 ? def__default : def;
|
|
5
|
-
|
|
6
|
-
export { dtlHelpers as default };
|
|
1
|
+
import * as named from '@testing-library/dom/dist/helpers.js';
|
|
2
|
+
export { named as default };
|
|
@@ -12,15 +12,13 @@ import { setUISelectionClean, setUISelectionRaw, getUIValue, setUIValueClean, is
|
|
|
12
12
|
|
|
13
13
|
const Interceptor = Symbol('Interceptor for programmatical calls');
|
|
14
14
|
function prepareInterceptor(element, propName, interceptorImpl) {
|
|
15
|
-
var _prototypeDescriptor, _prototypeDescriptor1;
|
|
16
15
|
const prototypeDescriptor = Object.getOwnPropertyDescriptor(element.constructor.prototype, propName);
|
|
17
16
|
const objectDescriptor = Object.getOwnPropertyDescriptor(element, propName);
|
|
18
|
-
const target = (
|
|
19
|
-
/* istanbul ignore if */ if (typeof (
|
|
17
|
+
const target = (prototypeDescriptor === null || prototypeDescriptor === void 0 ? void 0 : prototypeDescriptor.set) ? 'set' : 'value';
|
|
18
|
+
/* istanbul ignore if */ if (typeof (prototypeDescriptor === null || prototypeDescriptor === void 0 ? void 0 : prototypeDescriptor[target]) !== 'function' || prototypeDescriptor[target][Interceptor]) {
|
|
20
19
|
throw new Error(`Element ${element.tagName} does not implement "${String(propName)}".`);
|
|
21
20
|
}
|
|
22
21
|
function intercept(...args) {
|
|
23
|
-
var _then;
|
|
24
22
|
const { applyNative = false, realArgs, then } = interceptorImpl.call(this, ...args);
|
|
25
23
|
const realFunc = (!applyNative && objectDescriptor || prototypeDescriptor)[target];
|
|
26
24
|
if (target === 'set') {
|
|
@@ -28,7 +26,7 @@ function prepareInterceptor(element, propName, interceptorImpl) {
|
|
|
28
26
|
} else {
|
|
29
27
|
realFunc.call(this, ...realArgs);
|
|
30
28
|
}
|
|
31
|
-
|
|
29
|
+
then === null || then === void 0 ? void 0 : then();
|
|
32
30
|
}
|
|
33
31
|
intercept[Interceptor] = Interceptor;
|
|
34
32
|
Object.defineProperty(element, propName, {
|
|
@@ -39,10 +39,10 @@ function trackOrSetValue(element, v) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
function commitValueAfterInput(element, cursorOffset) {
|
|
42
|
-
var _changes_tracked
|
|
42
|
+
var _changes_tracked;
|
|
43
43
|
const changes = element[TrackChanges];
|
|
44
44
|
element[TrackChanges] = undefined;
|
|
45
|
-
if (!(
|
|
45
|
+
if (!(changes === null || changes === void 0 ? void 0 : (_changes_tracked = changes.tracked) === null || _changes_tracked === void 0 ? void 0 : _changes_tracked.length)) {
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
const isJustReactStateUpdate = changes.tracked.length === 2 && changes.tracked[0] === changes.previousValue && changes.tracked[1] === element.value;
|
|
@@ -21,9 +21,9 @@ import { walkRadio } from '../radio.js';
|
|
|
21
21
|
import { behavior } from './registry.js';
|
|
22
22
|
|
|
23
23
|
behavior.keydown = (event, target, instance)=>{
|
|
24
|
-
var _keydownBehavior_event_key
|
|
24
|
+
var _keydownBehavior_event_key;
|
|
25
25
|
var _keydownBehavior_event_key1;
|
|
26
|
-
return (_keydownBehavior_event_key1 = (_keydownBehavior_event_key =
|
|
26
|
+
return (_keydownBehavior_event_key1 = (_keydownBehavior_event_key = keydownBehavior[event.key]) === null || _keydownBehavior_event_key === void 0 ? void 0 : _keydownBehavior_event_key.call(keydownBehavior, event, target, instance)) !== null && _keydownBehavior_event_key1 !== void 0 ? _keydownBehavior_event_key1 : combinationBehavior(event, target, instance);
|
|
27
27
|
};
|
|
28
28
|
const keydownBehavior = {
|
|
29
29
|
ArrowDown: (event, target, instance)=>{
|
|
@@ -18,9 +18,8 @@ behavior.keypress = (event, target, instance)=>{
|
|
|
18
18
|
instance.dispatchUIEvent(target, 'click');
|
|
19
19
|
};
|
|
20
20
|
} else if (isElementType(target, 'input')) {
|
|
21
|
-
var _form;
|
|
22
21
|
const form = target.form;
|
|
23
|
-
const submit =
|
|
22
|
+
const submit = form === null || form === void 0 ? void 0 : form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]');
|
|
24
23
|
if (submit) {
|
|
25
24
|
return ()=>instance.dispatchUIEvent(submit, 'click');
|
|
26
25
|
} else if (form && SubmitSingleInputOnEnter.includes(target.type) && form.querySelectorAll('input').length === 1) {
|
|
@@ -9,8 +9,8 @@ import '../../options.js';
|
|
|
9
9
|
import { behavior } from './registry.js';
|
|
10
10
|
|
|
11
11
|
behavior.keyup = (event, target, instance)=>{
|
|
12
|
-
var _keyupBehavior_event_key
|
|
13
|
-
return (_keyupBehavior_event_key =
|
|
12
|
+
var _keyupBehavior_event_key;
|
|
13
|
+
return (_keyupBehavior_event_key = keyupBehavior[event.key]) === null || _keyupBehavior_event_key === void 0 ? void 0 : _keyupBehavior_event_key.call(keyupBehavior, event, target, instance);
|
|
14
14
|
};
|
|
15
15
|
const keyupBehavior = {
|
|
16
16
|
' ': (event, target, instance)=>{
|
|
@@ -20,9 +20,9 @@ function dispatchUIEvent(target, type, init, preventDefault = false) {
|
|
|
20
20
|
return dispatchEvent.call(this, target, event, preventDefault);
|
|
21
21
|
}
|
|
22
22
|
function dispatchEvent(target, event, preventDefault = false) {
|
|
23
|
-
var _behavior_type
|
|
23
|
+
var _behavior_type;
|
|
24
24
|
const type = event.type;
|
|
25
|
-
const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type =
|
|
25
|
+
const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type = behavior[type]) === null || _behavior_type === void 0 ? void 0 : _behavior_type.call(behavior, event, target, this);
|
|
26
26
|
if (behaviorImplementation) {
|
|
27
27
|
event.preventDefault();
|
|
28
28
|
let defaultPrevented = false;
|
package/dist/esm/event/focus.js
CHANGED
|
@@ -22,10 +22,7 @@ import { wrapEvent } from './wrapEvent.js';
|
|
|
22
22
|
} else if (target) {
|
|
23
23
|
wrapEvent(()=>target.focus());
|
|
24
24
|
} else {
|
|
25
|
-
wrapEvent(()=>
|
|
26
|
-
var _activeElement;
|
|
27
|
-
return (_activeElement = activeElement) === null || _activeElement === void 0 ? void 0 : _activeElement.blur();
|
|
28
|
-
});
|
|
25
|
+
wrapEvent(()=>activeElement === null || activeElement === void 0 ? void 0 : activeElement.blur());
|
|
29
26
|
}
|
|
30
27
|
updateSelectionOnFocus(target !== null && target !== void 0 ? target : element.ownerDocument.body);
|
|
31
28
|
}
|
|
@@ -13,7 +13,6 @@ import '../../options.js';
|
|
|
13
13
|
/**
|
|
14
14
|
* Determine which selection logic and selection ranges to consider.
|
|
15
15
|
*/ function getTargetTypeAndSelection(node) {
|
|
16
|
-
var _element, _selection;
|
|
17
16
|
const element = getElement(node);
|
|
18
17
|
if (element && hasOwnSelection(element)) {
|
|
19
18
|
return {
|
|
@@ -21,10 +20,10 @@ import '../../options.js';
|
|
|
21
20
|
selection: getUISelection(element)
|
|
22
21
|
};
|
|
23
22
|
}
|
|
24
|
-
const selection =
|
|
23
|
+
const selection = element === null || element === void 0 ? void 0 : element.ownerDocument.getSelection();
|
|
25
24
|
// It is possible to extend a single-range selection into a contenteditable.
|
|
26
25
|
// This results in the range acting like a range outside of contenteditable.
|
|
27
|
-
const isCE = getContentEditable(node) && (
|
|
26
|
+
const isCE = getContentEditable(node) && (selection === null || selection === void 0 ? void 0 : selection.anchorNode) && getContentEditable(selection.anchorNode);
|
|
28
27
|
return {
|
|
29
28
|
type: isCE ? 'contenteditable' : 'default',
|
|
30
29
|
selection
|
|
@@ -29,7 +29,6 @@ function modifySelectionPerMouseMove(selectionRange, { document, target, node, o
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
} else {
|
|
32
|
-
var _selection, _selection1;
|
|
33
32
|
const range = selectionRange.cloneRange();
|
|
34
33
|
const cmp = range.comparePoint(selectionFocus.node, selectionFocus.offset);
|
|
35
34
|
if (cmp < 0) {
|
|
@@ -38,8 +37,8 @@ function modifySelectionPerMouseMove(selectionRange, { document, target, node, o
|
|
|
38
37
|
range.setEnd(selectionFocus.node, selectionFocus.offset);
|
|
39
38
|
}
|
|
40
39
|
const selection = document.getSelection();
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
|
|
41
|
+
selection === null || selection === void 0 ? void 0 : selection.addRange(range.cloneRange());
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
|
|
@@ -22,9 +22,8 @@ import { setSelection } from './setSelection.js';
|
|
|
22
22
|
focusOffset: selection.startOffset === selection.endOffset ? selection.focusOffset + direction : direction < 0 ? selection.startOffset : selection.endOffset
|
|
23
23
|
});
|
|
24
24
|
} else {
|
|
25
|
-
var _selection;
|
|
26
25
|
const selection = node.ownerDocument.getSelection();
|
|
27
|
-
if (!(
|
|
26
|
+
if (!(selection === null || selection === void 0 ? void 0 : selection.focusNode)) {
|
|
28
27
|
return;
|
|
29
28
|
}
|
|
30
29
|
if (selection.isCollapsed) {
|
|
@@ -30,14 +30,13 @@ import { setSelection } from './setSelection.js';
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
function isAllSelected(target) {
|
|
33
|
-
var _selection;
|
|
34
33
|
if (hasOwnSelection(target)) {
|
|
35
34
|
return getUISelection(target).startOffset === 0 && getUISelection(target).endOffset === getUIValue(target).length;
|
|
36
35
|
}
|
|
37
36
|
var _getContentEditable;
|
|
38
37
|
const focusNode = (_getContentEditable = getContentEditable(target)) !== null && _getContentEditable !== void 0 ? _getContentEditable : target.ownerDocument.body;
|
|
39
38
|
const selection = target.ownerDocument.getSelection();
|
|
40
|
-
return (
|
|
39
|
+
return (selection === null || selection === void 0 ? void 0 : selection.anchorNode) === focusNode && selection.focusNode === focusNode && selection.anchorOffset === 0 && selection.focusOffset === focusNode.childNodes.length;
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
export { isAllSelected, selectAll };
|
|
@@ -39,7 +39,6 @@ function setSelectionPerMouseDown({ document, target, clickCount, node, offset }
|
|
|
39
39
|
end: end !== null && end !== void 0 ? end : text.length
|
|
40
40
|
};
|
|
41
41
|
} else {
|
|
42
|
-
var _selection, _selection1;
|
|
43
42
|
const { node: startNode, offset: startOffset } = resolveCaretPosition({
|
|
44
43
|
target,
|
|
45
44
|
node,
|
|
@@ -58,8 +57,8 @@ function setSelectionPerMouseDown({ document, target, clickCount, node, offset }
|
|
|
58
57
|
throw new Error('The given offset is out of bounds.');
|
|
59
58
|
}
|
|
60
59
|
const selection = document.getSelection();
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
|
|
61
|
+
selection === null || selection === void 0 ? void 0 : selection.addRange(range.cloneRange());
|
|
63
62
|
return range;
|
|
64
63
|
}
|
|
65
64
|
}
|
|
@@ -13,9 +13,8 @@ import '../../options.js';
|
|
|
13
13
|
* Reset the Document Selection when moving focus into an element
|
|
14
14
|
* with own selection implementation.
|
|
15
15
|
*/ function updateSelectionOnFocus(element) {
|
|
16
|
-
var _selection;
|
|
17
16
|
const selection = element.ownerDocument.getSelection();
|
|
18
|
-
/* istanbul ignore if */ if (!(
|
|
17
|
+
/* istanbul ignore if */ if (!(selection === null || selection === void 0 ? void 0 : selection.focusNode)) {
|
|
19
18
|
return;
|
|
20
19
|
}
|
|
21
20
|
// If the focus moves inside an element with own selection implementation,
|
|
@@ -33,16 +33,16 @@ async function pointer(input) {
|
|
|
33
33
|
this.system.pointer.resetClickCount();
|
|
34
34
|
}
|
|
35
35
|
async function pointerAction(instance, action) {
|
|
36
|
-
var
|
|
36
|
+
var _previousPosition_caret, _previousPosition_caret1;
|
|
37
37
|
const pointerName = 'pointerName' in action && action.pointerName ? action.pointerName : 'keyDef' in action ? instance.system.pointer.getPointerName(action.keyDef) : 'mouse';
|
|
38
38
|
const previousPosition = instance.system.pointer.getPreviousPosition(pointerName);
|
|
39
39
|
var _action_target, _action_coords, _action_node, _action_offset;
|
|
40
40
|
const position = {
|
|
41
41
|
target: (_action_target = action.target) !== null && _action_target !== void 0 ? _action_target : getPrevTarget(instance, previousPosition),
|
|
42
|
-
coords: (_action_coords = action.coords) !== null && _action_coords !== void 0 ? _action_coords :
|
|
42
|
+
coords: (_action_coords = action.coords) !== null && _action_coords !== void 0 ? _action_coords : previousPosition === null || previousPosition === void 0 ? void 0 : previousPosition.coords,
|
|
43
43
|
caret: {
|
|
44
|
-
node: (_action_node = action.node) !== null && _action_node !== void 0 ? _action_node : hasCaretPosition(action) ? undefined :
|
|
45
|
-
offset: (_action_offset = action.offset) !== null && _action_offset !== void 0 ? _action_offset : hasCaretPosition(action) ? undefined :
|
|
44
|
+
node: (_action_node = action.node) !== null && _action_node !== void 0 ? _action_node : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === void 0 ? void 0 : (_previousPosition_caret = previousPosition.caret) === null || _previousPosition_caret === void 0 ? void 0 : _previousPosition_caret.node,
|
|
45
|
+
offset: (_action_offset = action.offset) !== null && _action_offset !== void 0 ? _action_offset : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === void 0 ? void 0 : (_previousPosition_caret1 = previousPosition.caret) === null || _previousPosition_caret1 === void 0 ? void 0 : _previousPosition_caret1.offset
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
if ('keyDef' in action) {
|
|
@@ -36,7 +36,6 @@ class PointerHost {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
async move(instance, pointerName, position) {
|
|
39
|
-
var _pointermove, _mousemove, _pointermove1, _mousemove1, _pointermove2, _mousemove2;
|
|
40
39
|
const pointer = this.pointers.get(pointerName);
|
|
41
40
|
// In (some?) browsers this order of events can be observed.
|
|
42
41
|
// This interweaving of events is probably unnecessary.
|
|
@@ -44,12 +43,12 @@ class PointerHost {
|
|
|
44
43
|
// the order in which they interweave/follow on a user interaction depends on the implementation.
|
|
45
44
|
const pointermove = pointer.move(instance, position);
|
|
46
45
|
const mousemove = pointer.pointerType === 'touch' || pointer.isPrevented && pointer.isDown ? undefined : this.mouse.move(instance, position);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
pointermove === null || pointermove === void 0 ? void 0 : pointermove.leave();
|
|
47
|
+
mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
|
|
48
|
+
pointermove === null || pointermove === void 0 ? void 0 : pointermove.enter();
|
|
49
|
+
mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
|
|
50
|
+
pointermove === null || pointermove === void 0 ? void 0 : pointermove.move();
|
|
51
|
+
mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
|
|
53
52
|
}
|
|
54
53
|
async release(instance, keyDef, position) {
|
|
55
54
|
const device = this.devices.get(keyDef.pointerType);
|
|
@@ -69,19 +68,17 @@ class PointerHost {
|
|
|
69
68
|
}
|
|
70
69
|
if (!pointer.isPrevented) {
|
|
71
70
|
if (pointer.pointerType === 'touch' && !pointer.isMultitouch) {
|
|
72
|
-
var _mousemove, _mousemove1, _mousemove2;
|
|
73
71
|
const mousemove = this.mouse.move(instance, pointer.position);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
|
|
73
|
+
mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
|
|
74
|
+
mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
|
|
77
75
|
this.mouse.down(instance, keyDef, pointer);
|
|
78
76
|
}
|
|
79
77
|
if (!pointer.isMultitouch) {
|
|
80
|
-
var _mousemove3, _mousemove4, _mousemove5;
|
|
81
78
|
const mousemove = this.mouse.move(instance, pointer.position);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
|
|
80
|
+
mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
|
|
81
|
+
mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
|
|
85
82
|
this.mouse.up(instance, keyDef, pointer);
|
|
86
83
|
}
|
|
87
84
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as named from '@testing-library/dom';
|
|
2
2
|
import '../utils/click/isClickableInput.js';
|
|
3
3
|
import '../utils/dataTransfer/Clipboard.js';
|
|
4
4
|
import '../utils/edit/isEditable.js';
|
|
@@ -19,7 +19,7 @@ import '../event/behavior/paste.js';
|
|
|
19
19
|
import '../event/eventMap.js';
|
|
20
20
|
import { focusElement } from '../event/focus.js';
|
|
21
21
|
|
|
22
|
-
const { getConfig } =
|
|
22
|
+
const { getConfig } = named;
|
|
23
23
|
async function selectOptions(select, values) {
|
|
24
24
|
return selectOptionsBase.call(this, true, select, values);
|
|
25
25
|
}
|
|
@@ -16,8 +16,7 @@ async function upload(element, fileOrFiles) {
|
|
|
16
16
|
if (!input || !isElementType(input, 'input', {
|
|
17
17
|
type: 'file'
|
|
18
18
|
})) {
|
|
19
|
-
|
|
20
|
-
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${(_input = input) === null || _input === void 0 ? void 0 : _input.tagName} element does not accept file uploads`);
|
|
19
|
+
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === void 0 ? void 0 : input.tagName} element does not accept file uploads`);
|
|
21
20
|
}
|
|
22
21
|
if (isDisabled(element)) return;
|
|
23
22
|
const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [
|
|
@@ -82,8 +82,7 @@ function createClipboardStub(window, control) {
|
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
function isClipboardStub(clipboard) {
|
|
85
|
-
|
|
86
|
-
return !!((_clipboard = clipboard) === null || _clipboard === void 0 ? void 0 : _clipboard[ClipboardStubControl]);
|
|
85
|
+
return !!(clipboard === null || clipboard === void 0 ? void 0 : clipboard[ClipboardStubControl]);
|
|
87
86
|
}
|
|
88
87
|
function attachClipboardStubToView(window) {
|
|
89
88
|
if (isClipboardStub(window.navigator.clipboard)) {
|
|
@@ -124,9 +123,8 @@ function detachClipboardStubFromView(window) {
|
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
125
|
async function readDataTransferFromClipboard(document) {
|
|
127
|
-
var _window;
|
|
128
126
|
const window = document.defaultView;
|
|
129
|
-
const clipboard =
|
|
127
|
+
const clipboard = window === null || window === void 0 ? void 0 : window.navigator.clipboard;
|
|
130
128
|
const items = clipboard && await clipboard.read();
|
|
131
129
|
if (!items) {
|
|
132
130
|
throw new Error('The Clipboard API is unavailable.');
|
|
@@ -66,11 +66,10 @@ function getTypeMatcher(type, exact) {
|
|
|
66
66
|
function createDataTransferStub(window) {
|
|
67
67
|
return new class DataTransferStub {
|
|
68
68
|
getData(format) {
|
|
69
|
-
var _match;
|
|
70
69
|
var _this_items_find;
|
|
71
70
|
const match = (_this_items_find = this.items.find(getTypeMatcher(format, true))) !== null && _this_items_find !== void 0 ? _this_items_find : this.items.find(getTypeMatcher(format, false));
|
|
72
71
|
let text = '';
|
|
73
|
-
|
|
72
|
+
match === null || match === void 0 ? void 0 : match.getAsString((t)=>{
|
|
74
73
|
text = t;
|
|
75
74
|
});
|
|
76
75
|
return text;
|
|
@@ -36,8 +36,8 @@ function setFiles(el, files) {
|
|
|
36
36
|
if (v === '') {
|
|
37
37
|
restore();
|
|
38
38
|
} else {
|
|
39
|
-
var _valueDescr_set
|
|
40
|
-
|
|
39
|
+
var _valueDescr_set;
|
|
40
|
+
valueDescr === null || valueDescr === void 0 ? void 0 : (_valueDescr_set = valueDescr.set) === null || _valueDescr_set === void 0 ? void 0 : _valueDescr_set.call(el, v);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
},
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { isDisabled } from '../misc/isDisabled.js';
|
|
2
2
|
|
|
3
3
|
function getActiveElement(document) {
|
|
4
|
-
var _activeElement;
|
|
5
4
|
const activeElement = document.activeElement;
|
|
6
|
-
if (
|
|
5
|
+
if (activeElement === null || activeElement === void 0 ? void 0 : activeElement.shadowRoot) {
|
|
7
6
|
return getActiveElement(activeElement.shadowRoot);
|
|
8
7
|
} else {
|
|
9
8
|
// Browser does not yield disabled elements as document.activeElement - jsdom does
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as named from '@testing-library/dom/dist/helpers.js';
|
|
2
2
|
|
|
3
|
-
const { getWindowFromNode } =
|
|
3
|
+
const { getWindowFromNode } = named;
|
|
4
4
|
function getWindow(node) {
|
|
5
5
|
return getWindowFromNode(node);
|
|
6
6
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { getWindow } from './getWindow.js';
|
|
2
2
|
|
|
3
3
|
function isVisible(element) {
|
|
4
|
-
var _el;
|
|
5
4
|
const window = getWindow(element);
|
|
6
|
-
for(let el = element;
|
|
5
|
+
for(let el = element; el === null || el === void 0 ? void 0 : el.ownerDocument; el = el.parentElement){
|
|
7
6
|
const { display, visibility } = window.getComputedStyle(el);
|
|
8
7
|
if (display === 'none') {
|
|
9
8
|
return false;
|
|
@@ -8,9 +8,8 @@ function hasPointerEvents(instance, element) {
|
|
|
8
8
|
return ((_checkPointerEvents = checkPointerEvents(instance, element)) === null || _checkPointerEvents === void 0 ? void 0 : _checkPointerEvents.pointerEvents) !== 'none';
|
|
9
9
|
}
|
|
10
10
|
function closestPointerEventsDeclaration(element) {
|
|
11
|
-
var _el;
|
|
12
11
|
const window = getWindow(element);
|
|
13
|
-
for(let el = element, tree = [];
|
|
12
|
+
for(let el = element, tree = []; el === null || el === void 0 ? void 0 : el.ownerDocument; el = el.parentElement){
|
|
14
13
|
tree.push(el);
|
|
15
14
|
const pointerEvents = window.getComputedStyle(el).pointerEvents;
|
|
16
15
|
if (pointerEvents && ![
|
|
@@ -30,8 +29,7 @@ function checkPointerEvents(instance, element) {
|
|
|
30
29
|
const lastCheck = element[PointerEventsCheck];
|
|
31
30
|
const needsCheck = instance.config.pointerEventsCheck !== PointerEventsCheckLevel.Never && (!lastCheck || hasBitFlag(instance.config.pointerEventsCheck, PointerEventsCheckLevel.EachApiCall) && lastCheck[ApiLevel.Call] !== getLevelRef(instance, ApiLevel.Call) || hasBitFlag(instance.config.pointerEventsCheck, PointerEventsCheckLevel.EachTrigger) && lastCheck[ApiLevel.Trigger] !== getLevelRef(instance, ApiLevel.Trigger));
|
|
32
31
|
if (!needsCheck) {
|
|
33
|
-
|
|
34
|
-
return (_lastCheck = lastCheck) === null || _lastCheck === void 0 ? void 0 : _lastCheck.result;
|
|
32
|
+
return lastCheck === null || lastCheck === void 0 ? void 0 : lastCheck.result;
|
|
35
33
|
}
|
|
36
34
|
const declaration = closestPointerEventsDeclaration(element);
|
|
37
35
|
element[PointerEventsCheck] = {
|
|
@@ -42,9 +40,8 @@ function checkPointerEvents(instance, element) {
|
|
|
42
40
|
return declaration;
|
|
43
41
|
}
|
|
44
42
|
function assertPointerEvents(instance, element) {
|
|
45
|
-
var _declaration;
|
|
46
43
|
const declaration = checkPointerEvents(instance, element);
|
|
47
|
-
if ((
|
|
44
|
+
if ((declaration === null || declaration === void 0 ? void 0 : declaration.pointerEvents) === 'none') {
|
|
48
45
|
throw new Error([
|
|
49
46
|
`Unable to perform pointer interaction as the element ${declaration.tree.length > 1 ? 'inherits' : 'has'} \`pointer-events: none\`:`,
|
|
50
47
|
'',
|
|
@@ -64,7 +61,7 @@ function printTree(tree) {
|
|
|
64
61
|
].filter(Boolean).join('')).join('\n');
|
|
65
62
|
}
|
|
66
63
|
function getLabelDescr(element) {
|
|
67
|
-
var _element_labels
|
|
64
|
+
var _element_labels;
|
|
68
65
|
let label;
|
|
69
66
|
if (element.hasAttribute('aria-label')) {
|
|
70
67
|
label = element.getAttribute('aria-label');
|
|
@@ -88,10 +85,9 @@ function getLabelDescr(element) {
|
|
|
88
85
|
var _element_textContent;
|
|
89
86
|
label = (_element_textContent = element.textContent) === null || _element_textContent === void 0 ? void 0 : _element_textContent.trim();
|
|
90
87
|
}
|
|
91
|
-
label =
|
|
92
|
-
if (Number(
|
|
93
|
-
|
|
94
|
-
label = `${(_label2 = label) === null || _label2 === void 0 ? void 0 : _label2.substring(0, 29)}…`;
|
|
88
|
+
label = label === null || label === void 0 ? void 0 : label.replace(/\n/g, ' ');
|
|
89
|
+
if (Number(label === null || label === void 0 ? void 0 : label.length) > 30) {
|
|
90
|
+
label = `${label === null || label === void 0 ? void 0 : label.substring(0, 29)}…`;
|
|
95
91
|
}
|
|
96
92
|
return label ? `(label=${label})` : '';
|
|
97
93
|
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export default _default;
|
|
1
|
+
import * as named from '@testing-library/dom';
|
|
2
|
+
export default named;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export default _default;
|
|
1
|
+
import * as named from '@testing-library/dom/dist/event-map.js';
|
|
2
|
+
export default named;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export default _default;
|
|
1
|
+
import * as named from '@testing-library/dom/dist/helpers.js';
|
|
2
|
+
export default named;
|