@testing-library/user-event 14.5.1 → 14.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/clipboard/copy.js +1 -10
- package/dist/cjs/clipboard/cut.js +1 -10
- package/dist/cjs/clipboard/index.js +0 -2
- package/dist/cjs/clipboard/paste.js +2 -10
- package/dist/cjs/convenience/click.js +0 -2
- package/dist/cjs/convenience/hover.js +0 -8
- package/dist/cjs/convenience/index.js +0 -2
- package/dist/cjs/convenience/tab.js +0 -2
- package/dist/cjs/document/UI.js +3 -5
- package/dist/cjs/document/copySelection.js +0 -8
- package/dist/cjs/document/getValueOrTextContent.js +0 -9
- package/dist/cjs/document/index.js +0 -2
- package/dist/cjs/document/interceptor.js +5 -14
- package/dist/cjs/document/patchFocus.js +104 -0
- package/dist/cjs/document/prepareDocument.js +1 -10
- package/dist/cjs/document/trackValue.js +2 -10
- package/dist/cjs/event/behavior/click.js +1 -7
- package/dist/cjs/event/behavior/cut.js +0 -6
- package/dist/cjs/event/behavior/index.js +0 -2
- package/dist/cjs/event/behavior/keydown.js +3 -9
- package/dist/cjs/event/behavior/keypress.js +2 -8
- package/dist/cjs/event/behavior/keyup.js +1 -7
- package/dist/cjs/event/behavior/paste.js +1 -7
- package/dist/cjs/event/behavior/registry.js +0 -2
- package/dist/cjs/event/createEvent.js +36 -31
- package/dist/cjs/event/dispatchEvent.js +1 -3
- package/dist/cjs/event/eventMap.js +232 -35
- package/dist/cjs/event/focus.js +5 -12
- package/dist/cjs/event/index.js +0 -9
- package/dist/cjs/event/input.js +2 -10
- package/dist/cjs/event/radio.js +0 -8
- package/dist/cjs/event/selection/getInputRange.js +1 -3
- package/dist/cjs/event/selection/getTargetTypeAndSelection.js +2 -11
- package/dist/cjs/event/selection/index.js +0 -2
- package/dist/cjs/event/selection/modifySelection.js +1 -10
- package/dist/cjs/event/selection/modifySelectionPerMouse.js +2 -11
- package/dist/cjs/event/selection/moveSelection.js +1 -10
- package/dist/cjs/event/selection/resolveCaretPosition.js +4 -13
- package/dist/cjs/event/selection/selectAll.js +3 -12
- package/dist/cjs/event/selection/setSelection.js +1 -10
- package/dist/cjs/event/selection/setSelectionPerMouse.js +7 -16
- package/dist/cjs/event/selection/setSelectionRange.js +1 -10
- package/dist/cjs/event/selection/updateSelectionOnFocus.js +6 -11
- package/dist/cjs/event/wrapEvent.js +2 -25
- package/dist/cjs/index.js +2 -5
- package/dist/cjs/keyboard/index.js +0 -9
- package/dist/cjs/keyboard/keyMap.js +0 -2
- package/dist/cjs/keyboard/parseKeyDef.js +3 -11
- package/dist/cjs/options.js +10 -10
- package/dist/cjs/pointer/index.js +6 -14
- package/dist/cjs/pointer/keyMap.js +0 -2
- package/dist/cjs/pointer/parseKeyDef.js +0 -8
- package/dist/cjs/setup/api.js +0 -2
- package/dist/cjs/setup/directApi.js +0 -2
- package/dist/cjs/setup/index.js +0 -2
- package/dist/cjs/setup/setup.js +7 -10
- package/dist/cjs/setup/wrapAsync.js +2 -25
- package/dist/cjs/system/index.js +0 -2
- package/dist/cjs/system/keyboard.js +47 -28
- package/dist/cjs/system/pointer/buttons.js +0 -2
- package/dist/cjs/system/pointer/device.js +0 -2
- package/dist/cjs/system/pointer/index.js +18 -22
- package/dist/cjs/system/pointer/mouse.js +8 -18
- package/dist/cjs/system/pointer/pointer.js +4 -12
- package/dist/cjs/system/pointer/shared.js +2 -4
- package/dist/cjs/utility/clear.js +0 -9
- package/dist/cjs/utility/index.js +0 -2
- package/dist/cjs/utility/selectOptions.js +6 -36
- package/dist/cjs/utility/type.js +1 -10
- package/dist/cjs/utility/upload.js +4 -12
- package/dist/cjs/utils/click/isClickableInput.js +11 -13
- package/dist/cjs/utils/dataTransfer/Blob.js +0 -2
- package/dist/cjs/utils/dataTransfer/Clipboard.js +5 -8
- package/dist/cjs/utils/dataTransfer/DataTransfer.js +6 -12
- package/dist/cjs/utils/dataTransfer/FileList.js +0 -2
- package/dist/cjs/utils/edit/isContentEditable.js +0 -2
- package/dist/cjs/utils/edit/isEditable.js +15 -17
- package/dist/cjs/utils/edit/maxLength.js +10 -12
- package/dist/cjs/utils/edit/setFiles.js +2 -4
- package/dist/cjs/utils/edit/timeValue.js +0 -2
- package/dist/cjs/utils/focus/cursor.js +1 -3
- package/dist/cjs/utils/focus/getActiveElement.js +2 -4
- package/dist/cjs/utils/focus/getTabDestination.js +0 -2
- package/dist/cjs/utils/focus/isFocusable.js +0 -2
- package/dist/cjs/utils/focus/selection.js +0 -2
- package/dist/cjs/utils/focus/selector.js +0 -2
- package/dist/cjs/utils/index.js +1 -6
- package/dist/cjs/utils/keyDef/readNextDescriptor.js +8 -10
- package/dist/cjs/utils/misc/cloneEvent.js +0 -2
- package/dist/cjs/utils/misc/findClosest.js +0 -2
- package/dist/cjs/utils/misc/getDocumentFromNode.js +0 -2
- package/dist/cjs/utils/misc/getTreeDiff.js +0 -2
- package/dist/cjs/utils/misc/getWindow.js +13 -26
- package/dist/cjs/utils/misc/isDescendantOrSelf.js +0 -2
- package/dist/cjs/utils/misc/isDisabled.js +1 -3
- package/dist/cjs/utils/misc/isElementType.js +0 -2
- package/dist/cjs/utils/misc/isVisible.js +1 -3
- package/dist/cjs/utils/misc/level.js +4 -5
- package/dist/cjs/utils/misc/wait.js +0 -2
- package/dist/cjs/utils/pointer/cssPointerEvents.js +11 -13
- package/dist/esm/clipboard/copy.js +1 -8
- package/dist/esm/clipboard/cut.js +1 -8
- package/dist/esm/clipboard/paste.js +2 -8
- package/dist/esm/convenience/hover.js +0 -6
- package/dist/esm/document/UI.js +3 -3
- package/dist/esm/document/copySelection.js +0 -6
- package/dist/esm/document/getValueOrTextContent.js +0 -7
- package/dist/esm/document/interceptor.js +5 -12
- package/dist/esm/document/patchFocus.js +101 -0
- package/dist/esm/document/prepareDocument.js +1 -8
- package/dist/esm/document/trackValue.js +2 -8
- package/dist/esm/event/behavior/click.js +1 -7
- package/dist/esm/event/behavior/cut.js +0 -6
- package/dist/esm/event/behavior/keydown.js +3 -9
- package/dist/esm/event/behavior/keypress.js +2 -8
- package/dist/esm/event/behavior/keyup.js +1 -7
- package/dist/esm/event/behavior/paste.js +1 -7
- package/dist/esm/event/createEvent.js +37 -30
- package/dist/esm/event/dispatchEvent.js +1 -1
- package/dist/esm/event/eventMap.js +233 -13
- package/dist/esm/event/focus.js +5 -10
- package/dist/esm/event/index.js +0 -7
- package/dist/esm/event/input.js +2 -8
- package/dist/esm/event/radio.js +0 -6
- package/dist/esm/event/selection/getInputRange.js +1 -1
- package/dist/esm/event/selection/getTargetTypeAndSelection.js +2 -9
- package/dist/esm/event/selection/modifySelection.js +1 -8
- package/dist/esm/event/selection/modifySelectionPerMouse.js +2 -9
- package/dist/esm/event/selection/moveSelection.js +1 -8
- package/dist/esm/event/selection/resolveCaretPosition.js +4 -11
- package/dist/esm/event/selection/selectAll.js +3 -10
- package/dist/esm/event/selection/setSelection.js +1 -8
- package/dist/esm/event/selection/setSelectionPerMouse.js +7 -14
- package/dist/esm/event/selection/setSelectionRange.js +1 -8
- package/dist/esm/event/selection/updateSelectionOnFocus.js +6 -9
- package/dist/esm/event/wrapEvent.js +1 -2
- package/dist/esm/keyboard/index.js +0 -7
- package/dist/esm/keyboard/parseKeyDef.js +3 -9
- package/dist/esm/options.js +8 -8
- package/dist/esm/pointer/index.js +6 -12
- package/dist/esm/pointer/parseKeyDef.js +0 -6
- package/dist/esm/setup/setup.js +7 -8
- package/dist/esm/setup/wrapAsync.js +1 -2
- package/dist/esm/system/keyboard.js +46 -26
- package/dist/esm/system/pointer/index.js +18 -20
- package/dist/esm/system/pointer/mouse.js +8 -16
- package/dist/esm/system/pointer/pointer.js +4 -10
- package/dist/esm/system/pointer/shared.js +2 -2
- package/dist/esm/utility/clear.js +0 -7
- package/dist/esm/utility/selectOptions.js +2 -10
- package/dist/esm/utility/type.js +1 -8
- package/dist/esm/utility/upload.js +4 -10
- package/dist/esm/utils/click/isClickableInput.js +11 -11
- package/dist/esm/utils/dataTransfer/Clipboard.js +5 -6
- package/dist/esm/utils/dataTransfer/DataTransfer.js +6 -10
- package/dist/esm/utils/edit/isEditable.js +15 -15
- package/dist/esm/utils/edit/maxLength.js +10 -10
- package/dist/esm/utils/edit/setFiles.js +2 -2
- package/dist/esm/utils/focus/cursor.js +1 -1
- package/dist/esm/utils/focus/getActiveElement.js +2 -2
- package/dist/esm/utils/keyDef/readNextDescriptor.js +8 -8
- package/dist/esm/utils/misc/getWindow.js +13 -4
- package/dist/esm/utils/misc/isDisabled.js +1 -1
- package/dist/esm/utils/misc/isVisible.js +1 -1
- package/dist/esm/utils/misc/level.js +3 -3
- package/dist/esm/utils/pointer/cssPointerEvents.js +11 -11
- package/dist/types/document/patchFocus.d.ts +9 -0
- package/dist/types/event/eventMap.d.ts +204 -331
- package/dist/types/event/types.d.ts +3 -2
- package/dist/types/system/keyboard.d.ts +1 -4
- package/dist/types/utils/dataTransfer/DataTransfer.d.ts +1 -1
- package/package.json +17 -6
- package/dist/cjs/_interop/dom-events.d.js +0 -2
- package/dist/cjs/_interop/dom-helpers.d.js +0 -2
- package/dist/cjs/_interop/dtl.js +0 -27
- package/dist/cjs/_interop/dtlEventMap.js +0 -27
- package/dist/cjs/_interop/dtlHelpers.js +0 -27
- package/dist/esm/_interop/dom-events.d.js +0 -1
- package/dist/esm/_interop/dom-helpers.d.js +0 -1
- package/dist/esm/_interop/dtl.js +0 -2
- package/dist/esm/_interop/dtlEventMap.js +0 -2
- package/dist/esm/_interop/dtlHelpers.js +0 -2
- package/dist/types/_interop/dtl.d.ts +0 -2
- package/dist/types/_interop/dtlEventMap.d.ts +0 -2
- package/dist/types/_interop/dtlHelpers.d.ts +0 -2
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
import '../utils/click/isClickableInput.js';
|
|
2
1
|
import { writeDataTransferToClipboard } from '../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import '../utils/edit/isEditable.js';
|
|
4
|
-
import '../utils/edit/maxLength.js';
|
|
5
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
6
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
7
|
-
import '../utils/misc/level.js';
|
|
8
|
-
import '../options.js';
|
|
9
2
|
import { copySelection } from '../document/copySelection.js';
|
|
10
3
|
|
|
11
4
|
async function cut() {
|
|
12
5
|
const doc = this.config.document;
|
|
13
6
|
var _doc_activeElement;
|
|
14
|
-
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !==
|
|
7
|
+
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== undefined ? _doc_activeElement : /* istanbul ignore next */ doc.body;
|
|
15
8
|
const clipboardData = copySelection(target);
|
|
16
9
|
if (clipboardData.items.length === 0) {
|
|
17
10
|
return;
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import '../utils/click/isClickableInput.js';
|
|
2
1
|
import { createDataTransfer } from '../utils/dataTransfer/DataTransfer.js';
|
|
3
2
|
import { readDataTransferFromClipboard } from '../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../utils/edit/isEditable.js';
|
|
5
|
-
import '../utils/edit/maxLength.js';
|
|
6
3
|
import { getWindow } from '../utils/misc/getWindow.js';
|
|
7
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
8
|
-
import '../utils/misc/level.js';
|
|
9
|
-
import '../options.js';
|
|
10
4
|
|
|
11
5
|
async function paste(clipboardData) {
|
|
12
6
|
const doc = this.config.document;
|
|
13
7
|
var _doc_activeElement;
|
|
14
|
-
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !==
|
|
8
|
+
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== undefined ? _doc_activeElement : /* istanbul ignore next */ doc.body;
|
|
15
9
|
var _ref;
|
|
16
|
-
const dataTransfer = (_ref = typeof clipboardData === 'string' ? getClipboardDataFromString(doc, clipboardData) : clipboardData) !== null && _ref !==
|
|
10
|
+
const dataTransfer = (_ref = typeof clipboardData === 'string' ? getClipboardDataFromString(doc, clipboardData) : clipboardData) !== null && _ref !== undefined ? _ref : await readDataTransferFromClipboard(doc).catch(()=>{
|
|
17
11
|
throw new Error('`userEvent.paste()` without `clipboardData` requires the `ClipboardAPI` to be available.');
|
|
18
12
|
});
|
|
19
13
|
this.dispatchUIEvent(target, 'paste', {
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import '../utils/click/isClickableInput.js';
|
|
2
1
|
import '../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import '../utils/edit/isEditable.js';
|
|
4
|
-
import '../utils/edit/maxLength.js';
|
|
5
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
6
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
7
|
-
import '../utils/misc/level.js';
|
|
8
2
|
import { assertPointerEvents } from '../utils/pointer/cssPointerEvents.js';
|
|
9
3
|
|
|
10
4
|
async function hover(element) {
|
package/dist/esm/document/UI.js
CHANGED
|
@@ -59,9 +59,9 @@ function setUISelection(element, { focusOffset: focusOffsetParam, anchorOffset:
|
|
|
59
59
|
}
|
|
60
60
|
function getUISelection(element) {
|
|
61
61
|
var _element_selectionStart, _element_selectionEnd, _element_UISelection;
|
|
62
|
-
const sel = (_element_UISelection = element[UISelection]) !== null && _element_UISelection !==
|
|
63
|
-
anchorOffset: (_element_selectionStart = element.selectionStart) !== null && _element_selectionStart !==
|
|
64
|
-
focusOffset: (_element_selectionEnd = element.selectionEnd) !== null && _element_selectionEnd !==
|
|
62
|
+
const sel = (_element_UISelection = element[UISelection]) !== null && _element_UISelection !== undefined ? _element_UISelection : {
|
|
63
|
+
anchorOffset: (_element_selectionStart = element.selectionStart) !== null && _element_selectionStart !== undefined ? _element_selectionStart : 0,
|
|
64
|
+
focusOffset: (_element_selectionEnd = element.selectionEnd) !== null && _element_selectionEnd !== undefined ? _element_selectionEnd : 0
|
|
65
65
|
};
|
|
66
66
|
return {
|
|
67
67
|
...sel,
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import '../utils/click/isClickableInput.js';
|
|
2
1
|
import { createDataTransfer } from '../utils/dataTransfer/DataTransfer.js';
|
|
3
2
|
import '../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../utils/edit/isEditable.js';
|
|
5
|
-
import '../utils/edit/maxLength.js';
|
|
6
3
|
import { getWindow } from '../utils/misc/getWindow.js';
|
|
7
4
|
import { hasOwnSelection } from '../utils/focus/selection.js';
|
|
8
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
9
|
-
import '../utils/misc/level.js';
|
|
10
|
-
import '../options.js';
|
|
11
5
|
import { getUISelection, getUIValue } from './UI.js';
|
|
12
6
|
|
|
13
7
|
function copySelection(target) {
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import '../utils/click/isClickableInput.js';
|
|
2
1
|
import '../utils/dataTransfer/Clipboard.js';
|
|
3
2
|
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
3
|
import { getUIValue } from './UI.js';
|
|
11
4
|
|
|
12
5
|
function getValueOrTextContent(element) {
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import '../utils/click/isClickableInput.js';
|
|
2
|
-
import '../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import '../utils/edit/isEditable.js';
|
|
4
|
-
import '../utils/edit/maxLength.js';
|
|
5
1
|
import { isElementType } from '../utils/misc/isElementType.js';
|
|
6
|
-
import '
|
|
7
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
8
|
-
import '../utils/misc/level.js';
|
|
9
|
-
import '../options.js';
|
|
2
|
+
import '../utils/dataTransfer/Clipboard.js';
|
|
10
3
|
import { startTrackValue, trackOrSetValue } from './trackValue.js';
|
|
11
4
|
import { setUISelectionClean, setUISelectionRaw, getUIValue, setUIValueClean, isUIValue, isUISelectionStart } from './UI.js';
|
|
12
5
|
|
|
@@ -14,8 +7,8 @@ const Interceptor = Symbol('Interceptor for programmatical calls');
|
|
|
14
7
|
function prepareInterceptor(element, propName, interceptorImpl) {
|
|
15
8
|
const prototypeDescriptor = Object.getOwnPropertyDescriptor(element.constructor.prototype, propName);
|
|
16
9
|
const objectDescriptor = Object.getOwnPropertyDescriptor(element, propName);
|
|
17
|
-
const target = (prototypeDescriptor === null || prototypeDescriptor ===
|
|
18
|
-
/* istanbul ignore if */ if (typeof (prototypeDescriptor === null || prototypeDescriptor ===
|
|
10
|
+
const target = (prototypeDescriptor === null || prototypeDescriptor === undefined ? undefined : prototypeDescriptor.set) ? 'set' : 'value';
|
|
11
|
+
/* istanbul ignore if */ if (typeof (prototypeDescriptor === null || prototypeDescriptor === undefined ? undefined : prototypeDescriptor[target]) !== 'function' || prototypeDescriptor[target][Interceptor]) {
|
|
19
12
|
throw new Error(`Element ${element.tagName} does not implement "${String(propName)}".`);
|
|
20
13
|
}
|
|
21
14
|
function intercept(...args) {
|
|
@@ -26,11 +19,11 @@ function prepareInterceptor(element, propName, interceptorImpl) {
|
|
|
26
19
|
} else {
|
|
27
20
|
realFunc.call(this, ...realArgs);
|
|
28
21
|
}
|
|
29
|
-
then === null || then ===
|
|
22
|
+
then === null || then === undefined ? undefined : then();
|
|
30
23
|
}
|
|
31
24
|
intercept[Interceptor] = Interceptor;
|
|
32
25
|
Object.defineProperty(element, propName, {
|
|
33
|
-
...objectDescriptor !== null && objectDescriptor !==
|
|
26
|
+
...objectDescriptor !== null && objectDescriptor !== undefined ? objectDescriptor : prototypeDescriptor,
|
|
34
27
|
[target]: intercept
|
|
35
28
|
});
|
|
36
29
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { dispatchDOMEvent } from '../event/dispatchEvent.js';
|
|
2
|
+
import '../utils/dataTransfer/Clipboard.js';
|
|
3
|
+
import { getActiveElement } from '../utils/focus/getActiveElement.js';
|
|
4
|
+
import '@testing-library/dom';
|
|
5
|
+
|
|
6
|
+
const patched = Symbol('patched focus/blur methods');
|
|
7
|
+
function patchFocus(HTMLElement) {
|
|
8
|
+
if (HTMLElement.prototype[patched]) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
12
|
+
const { focus, blur } = HTMLElement.prototype;
|
|
13
|
+
Object.defineProperties(HTMLElement.prototype, {
|
|
14
|
+
focus: {
|
|
15
|
+
configurable: true,
|
|
16
|
+
get: ()=>patchedFocus
|
|
17
|
+
},
|
|
18
|
+
blur: {
|
|
19
|
+
configurable: true,
|
|
20
|
+
get: ()=>patchedBlur
|
|
21
|
+
},
|
|
22
|
+
[patched]: {
|
|
23
|
+
configurable: true,
|
|
24
|
+
get: ()=>({
|
|
25
|
+
focus,
|
|
26
|
+
blur
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
let activeCall;
|
|
31
|
+
function patchedFocus(options) {
|
|
32
|
+
if (this.ownerDocument.visibilityState !== 'hidden') {
|
|
33
|
+
return focus.call(this, options);
|
|
34
|
+
}
|
|
35
|
+
const blured = getActiveTarget(this.ownerDocument);
|
|
36
|
+
if (blured === this) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const thisCall = Symbol('focus call');
|
|
40
|
+
activeCall = thisCall;
|
|
41
|
+
if (blured) {
|
|
42
|
+
blur.call(blured);
|
|
43
|
+
dispatchDOMEvent(blured, 'blur', {
|
|
44
|
+
relatedTarget: this
|
|
45
|
+
});
|
|
46
|
+
dispatchDOMEvent(blured, 'focusout', {
|
|
47
|
+
relatedTarget: activeCall === thisCall ? this : null
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (activeCall === thisCall) {
|
|
51
|
+
focus.call(this, options);
|
|
52
|
+
dispatchDOMEvent(this, 'focus', {
|
|
53
|
+
relatedTarget: blured
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (activeCall === thisCall) {
|
|
57
|
+
dispatchDOMEvent(this, 'focusin', {
|
|
58
|
+
relatedTarget: blured
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function patchedBlur() {
|
|
63
|
+
if (this.ownerDocument.visibilityState !== 'hidden') {
|
|
64
|
+
return blur.call(this);
|
|
65
|
+
}
|
|
66
|
+
const blured = getActiveTarget(this.ownerDocument);
|
|
67
|
+
if (blured !== this) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const thisCall = Symbol('blur call');
|
|
71
|
+
activeCall = thisCall;
|
|
72
|
+
blur.call(this);
|
|
73
|
+
dispatchDOMEvent(blured, 'blur', {
|
|
74
|
+
relatedTarget: null
|
|
75
|
+
});
|
|
76
|
+
dispatchDOMEvent(blured, 'focusout', {
|
|
77
|
+
relatedTarget: null
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function getActiveTarget(document) {
|
|
82
|
+
const active = getActiveElement(document);
|
|
83
|
+
return (active === null || active === undefined ? undefined : active.tagName) === 'BODY' ? null : active;
|
|
84
|
+
}
|
|
85
|
+
function restoreFocus(HTMLElement) {
|
|
86
|
+
if (HTMLElement.prototype[patched]) {
|
|
87
|
+
const { focus, blur } = HTMLElement.prototype[patched];
|
|
88
|
+
Object.defineProperties(HTMLElement.prototype, {
|
|
89
|
+
focus: {
|
|
90
|
+
configurable: true,
|
|
91
|
+
get: ()=>focus
|
|
92
|
+
},
|
|
93
|
+
blur: {
|
|
94
|
+
configurable: true,
|
|
95
|
+
get: ()=>blur
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { patchFocus, restoreFocus };
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { dispatchDOMEvent } from '../event/dispatchEvent.js';
|
|
2
|
-
import '../utils/click/isClickableInput.js';
|
|
3
|
-
import '../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../utils/edit/isEditable.js';
|
|
5
|
-
import '../utils/edit/maxLength.js';
|
|
6
2
|
import { isElementType } from '../utils/misc/isElementType.js';
|
|
7
|
-
import '
|
|
8
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
9
|
-
import '../utils/misc/level.js';
|
|
10
|
-
import '../options.js';
|
|
3
|
+
import '../utils/dataTransfer/Clipboard.js';
|
|
11
4
|
import { getInitialValue, clearInitialValue } from './UI.js';
|
|
12
5
|
import '@testing-library/dom';
|
|
13
6
|
import { prepareValueInterceptor, prepareSelectionInterceptor, prepareRangeTextInterceptor } from './interceptor.js';
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import '../utils/click/isClickableInput.js';
|
|
2
1
|
import '../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import '../utils/edit/isEditable.js';
|
|
4
|
-
import '../utils/edit/maxLength.js';
|
|
5
2
|
import { getWindow } from '../utils/misc/getWindow.js';
|
|
6
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
7
|
-
import '../utils/misc/level.js';
|
|
8
|
-
import '../options.js';
|
|
9
3
|
import { setUIValueClean, setUISelection, hasUISelection } from './UI.js';
|
|
10
4
|
|
|
11
5
|
const TrackChanges = Symbol('Track programmatic changes for React workaround');
|
|
@@ -30,7 +24,7 @@ function startTrackValue(element) {
|
|
|
30
24
|
}
|
|
31
25
|
function trackOrSetValue(element, v) {
|
|
32
26
|
var _element_TrackChanges_tracked, _element_TrackChanges;
|
|
33
|
-
(_element_TrackChanges = element[TrackChanges]) === null || _element_TrackChanges ===
|
|
27
|
+
(_element_TrackChanges = element[TrackChanges]) === null || _element_TrackChanges === undefined ? undefined : (_element_TrackChanges_tracked = _element_TrackChanges.tracked) === null || _element_TrackChanges_tracked === undefined ? undefined : _element_TrackChanges_tracked.push(v);
|
|
34
28
|
if (!element[TrackChanges]) {
|
|
35
29
|
setUIValueClean(element);
|
|
36
30
|
setUISelection(element, {
|
|
@@ -42,7 +36,7 @@ function commitValueAfterInput(element, cursorOffset) {
|
|
|
42
36
|
var _changes_tracked;
|
|
43
37
|
const changes = element[TrackChanges];
|
|
44
38
|
element[TrackChanges] = undefined;
|
|
45
|
-
if (!(changes === null || changes ===
|
|
39
|
+
if (!(changes === null || changes === undefined ? undefined : (_changes_tracked = changes.tracked) === null || _changes_tracked === undefined ? undefined : _changes_tracked.length)) {
|
|
46
40
|
return;
|
|
47
41
|
}
|
|
48
42
|
const isJustReactStateUpdate = changes.tracked.length === 2 && changes.tracked[0] === changes.previousValue && changes.tracked[1] === element.value;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import '../../utils/click/isClickableInput.js';
|
|
2
|
-
import '../../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import '../../utils/edit/isEditable.js';
|
|
4
|
-
import '../../utils/edit/maxLength.js';
|
|
5
1
|
import { isElementType } from '../../utils/misc/isElementType.js';
|
|
2
|
+
import '../../utils/dataTransfer/Clipboard.js';
|
|
6
3
|
import { getWindow } from '../../utils/misc/getWindow.js';
|
|
7
4
|
import { isFocusable } from '../../utils/focus/isFocusable.js';
|
|
8
|
-
import '../../utils/keyDef/readNextDescriptor.js';
|
|
9
5
|
import { cloneEvent } from '../../utils/misc/cloneEvent.js';
|
|
10
|
-
import '../../utils/misc/level.js';
|
|
11
|
-
import '../../options.js';
|
|
12
6
|
import { focusElement, blurElement } from '../focus.js';
|
|
13
7
|
import { behavior } from './registry.js';
|
|
14
8
|
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import '../../utils/click/isClickableInput.js';
|
|
2
1
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
3
2
|
import { isEditable } from '../../utils/edit/isEditable.js';
|
|
4
|
-
import '../../utils/edit/maxLength.js';
|
|
5
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
6
|
-
import '../../utils/keyDef/readNextDescriptor.js';
|
|
7
|
-
import '../../utils/misc/level.js';
|
|
8
|
-
import '../../options.js';
|
|
9
3
|
import { input } from '../input.js';
|
|
10
4
|
import { behavior } from './registry.js';
|
|
11
5
|
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import { getUIValue, setUISelection } from '../../document/UI.js';
|
|
2
2
|
import { getValueOrTextContent } from '../../document/getValueOrTextContent.js';
|
|
3
|
-
import '../../utils/
|
|
3
|
+
import { isElementType } from '../../utils/misc/isElementType.js';
|
|
4
4
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
5
5
|
import { isContentEditable } from '../../utils/edit/isContentEditable.js';
|
|
6
6
|
import { isEditable } from '../../utils/edit/isEditable.js';
|
|
7
|
-
import '../../utils/edit/maxLength.js';
|
|
8
|
-
import { isElementType } from '../../utils/misc/isElementType.js';
|
|
9
7
|
import { getTabDestination } from '../../utils/focus/getTabDestination.js';
|
|
10
8
|
import { hasOwnSelection } from '../../utils/focus/selection.js';
|
|
11
|
-
import '../../utils/keyDef/readNextDescriptor.js';
|
|
12
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
13
|
-
import '../../utils/misc/level.js';
|
|
14
|
-
import '../../options.js';
|
|
15
9
|
import { focusElement } from '../focus.js';
|
|
16
10
|
import { input } from '../input.js';
|
|
17
11
|
import { moveSelection } from '../selection/moveSelection.js';
|
|
@@ -23,7 +17,7 @@ import { behavior } from './registry.js';
|
|
|
23
17
|
behavior.keydown = (event, target, instance)=>{
|
|
24
18
|
var _keydownBehavior_event_key;
|
|
25
19
|
var _keydownBehavior_event_key1;
|
|
26
|
-
return (_keydownBehavior_event_key1 = (_keydownBehavior_event_key = keydownBehavior[event.key]) === null || _keydownBehavior_event_key ===
|
|
20
|
+
return (_keydownBehavior_event_key1 = (_keydownBehavior_event_key = keydownBehavior[event.key]) === null || _keydownBehavior_event_key === undefined ? undefined : _keydownBehavior_event_key.call(keydownBehavior, event, target, instance)) !== null && _keydownBehavior_event_key1 !== undefined ? _keydownBehavior_event_key1 : combinationBehavior(event, target, instance);
|
|
27
21
|
};
|
|
28
22
|
const keydownBehavior = {
|
|
29
23
|
ArrowDown: (event, target, instance)=>{
|
|
@@ -78,7 +72,7 @@ const keydownBehavior = {
|
|
|
78
72
|
return ()=>{
|
|
79
73
|
var _getValueOrTextContent;
|
|
80
74
|
var _getValueOrTextContent_length;
|
|
81
|
-
const newPos = (_getValueOrTextContent_length = (_getValueOrTextContent = getValueOrTextContent(target)) === null || _getValueOrTextContent ===
|
|
75
|
+
const newPos = (_getValueOrTextContent_length = (_getValueOrTextContent = getValueOrTextContent(target)) === null || _getValueOrTextContent === undefined ? undefined : _getValueOrTextContent.length) !== null && _getValueOrTextContent_length !== undefined ? _getValueOrTextContent_length : /* istanbul ignore next */ 0;
|
|
82
76
|
setSelectionRange(target, newPos, newPos);
|
|
83
77
|
};
|
|
84
78
|
}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
import '../../utils/
|
|
1
|
+
import { isElementType } from '../../utils/misc/isElementType.js';
|
|
2
2
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
3
3
|
import { isContentEditable } from '../../utils/edit/isContentEditable.js';
|
|
4
4
|
import { isEditable } from '../../utils/edit/isEditable.js';
|
|
5
|
-
import '../../utils/edit/maxLength.js';
|
|
6
|
-
import { isElementType } from '../../utils/misc/isElementType.js';
|
|
7
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
8
|
-
import '../../utils/keyDef/readNextDescriptor.js';
|
|
9
|
-
import '../../utils/misc/level.js';
|
|
10
|
-
import '../../options.js';
|
|
11
5
|
import { input } from '../input.js';
|
|
12
6
|
import { behavior } from './registry.js';
|
|
13
7
|
|
|
@@ -19,7 +13,7 @@ behavior.keypress = (event, target, instance)=>{
|
|
|
19
13
|
};
|
|
20
14
|
} else if (isElementType(target, 'input')) {
|
|
21
15
|
const form = target.form;
|
|
22
|
-
const submit = form === null || form ===
|
|
16
|
+
const submit = form === null || form === undefined ? undefined : form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]');
|
|
23
17
|
if (submit) {
|
|
24
18
|
return ()=>instance.dispatchUIEvent(submit, 'click');
|
|
25
19
|
} else if (form && SubmitSingleInputOnEnter.includes(target.type) && form.querySelectorAll('input').length === 1) {
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { isClickableInput } from '../../utils/click/isClickableInput.js';
|
|
2
2
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import '../../utils/edit/isEditable.js';
|
|
4
|
-
import '../../utils/edit/maxLength.js';
|
|
5
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
6
|
-
import '../../utils/keyDef/readNextDescriptor.js';
|
|
7
|
-
import '../../utils/misc/level.js';
|
|
8
|
-
import '../../options.js';
|
|
9
3
|
import { behavior } from './registry.js';
|
|
10
4
|
|
|
11
5
|
behavior.keyup = (event, target, instance)=>{
|
|
12
6
|
var _keyupBehavior_event_key;
|
|
13
|
-
return (_keyupBehavior_event_key = keyupBehavior[event.key]) === null || _keyupBehavior_event_key ===
|
|
7
|
+
return (_keyupBehavior_event_key = keyupBehavior[event.key]) === null || _keyupBehavior_event_key === undefined ? undefined : _keyupBehavior_event_key.call(keyupBehavior, event, target, instance);
|
|
14
8
|
};
|
|
15
9
|
const keyupBehavior = {
|
|
16
10
|
' ': (event, target, instance)=>{
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import '../../utils/click/isClickableInput.js';
|
|
2
1
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
3
2
|
import { isEditable } from '../../utils/edit/isEditable.js';
|
|
4
|
-
import '../../utils/edit/maxLength.js';
|
|
5
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
6
|
-
import '../../utils/keyDef/readNextDescriptor.js';
|
|
7
|
-
import '../../utils/misc/level.js';
|
|
8
|
-
import '../../options.js';
|
|
9
3
|
import { input } from '../input.js';
|
|
10
4
|
import { behavior } from './registry.js';
|
|
11
5
|
|
|
@@ -13,7 +7,7 @@ behavior.paste = (event, target, instance)=>{
|
|
|
13
7
|
if (isEditable(target)) {
|
|
14
8
|
return ()=>{
|
|
15
9
|
var _event_clipboardData;
|
|
16
|
-
const insertData = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData ===
|
|
10
|
+
const insertData = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === undefined ? undefined : _event_clipboardData.getData('text');
|
|
17
11
|
if (insertData) {
|
|
18
12
|
input(instance, target, insertData, 'insertFromPaste');
|
|
19
13
|
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import '../utils/click/isClickableInput.js';
|
|
2
1
|
import '../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import '../utils/edit/isEditable.js';
|
|
4
|
-
import '../utils/edit/maxLength.js';
|
|
5
2
|
import { getWindow } from '../utils/misc/getWindow.js';
|
|
6
|
-
import '
|
|
7
|
-
import '../utils/misc/level.js';
|
|
8
|
-
import '../options.js';
|
|
9
|
-
import { eventMap, eventMapKeys } from './eventMap.js';
|
|
3
|
+
import { eventMap } from './eventMap.js';
|
|
10
4
|
|
|
11
5
|
const eventInitializer = {
|
|
12
6
|
ClipboardEvent: [
|
|
13
7
|
initClipboardEvent
|
|
14
8
|
],
|
|
9
|
+
Event: [],
|
|
10
|
+
FocusEvent: [
|
|
11
|
+
initUIEvent,
|
|
12
|
+
initFocusEvent
|
|
13
|
+
],
|
|
15
14
|
InputEvent: [
|
|
16
15
|
initUIEvent,
|
|
17
16
|
initInputEvent
|
|
@@ -34,58 +33,57 @@ const eventInitializer = {
|
|
|
34
33
|
]
|
|
35
34
|
};
|
|
36
35
|
function createEvent(type, target, init) {
|
|
37
|
-
var _eventInitializer_EventType;
|
|
38
36
|
const window = getWindow(target);
|
|
39
|
-
const { EventType, defaultInit } = eventMap[
|
|
37
|
+
const { EventType, defaultInit } = eventMap[type];
|
|
40
38
|
const event = new (getEventConstructors(window))[EventType](type, defaultInit);
|
|
41
|
-
|
|
39
|
+
eventInitializer[EventType].forEach((f)=>f(event, init !== null && init !== undefined ? init : {}));
|
|
42
40
|
return event;
|
|
43
41
|
}
|
|
44
42
|
/* istanbul ignore next */ function getEventConstructors(window) {
|
|
45
43
|
var _window_Event;
|
|
46
|
-
/* eslint-disable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ const Event = (_window_Event = window.Event) !== null && _window_Event !==
|
|
44
|
+
/* eslint-disable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ const Event = (_window_Event = window.Event) !== null && _window_Event !== undefined ? _window_Event : class Event {
|
|
47
45
|
};
|
|
48
46
|
var _window_AnimationEvent;
|
|
49
|
-
const AnimationEvent = (_window_AnimationEvent = window.AnimationEvent) !== null && _window_AnimationEvent !==
|
|
47
|
+
const AnimationEvent = (_window_AnimationEvent = window.AnimationEvent) !== null && _window_AnimationEvent !== undefined ? _window_AnimationEvent : class AnimationEvent extends Event {
|
|
50
48
|
};
|
|
51
49
|
var _window_ClipboardEvent;
|
|
52
|
-
const ClipboardEvent = (_window_ClipboardEvent = window.ClipboardEvent) !== null && _window_ClipboardEvent !==
|
|
50
|
+
const ClipboardEvent = (_window_ClipboardEvent = window.ClipboardEvent) !== null && _window_ClipboardEvent !== undefined ? _window_ClipboardEvent : class ClipboardEvent extends Event {
|
|
53
51
|
};
|
|
54
52
|
var _window_PopStateEvent;
|
|
55
|
-
const PopStateEvent = (_window_PopStateEvent = window.PopStateEvent) !== null && _window_PopStateEvent !==
|
|
53
|
+
const PopStateEvent = (_window_PopStateEvent = window.PopStateEvent) !== null && _window_PopStateEvent !== undefined ? _window_PopStateEvent : class PopStateEvent extends Event {
|
|
56
54
|
};
|
|
57
55
|
var _window_ProgressEvent;
|
|
58
|
-
const ProgressEvent = (_window_ProgressEvent = window.ProgressEvent) !== null && _window_ProgressEvent !==
|
|
56
|
+
const ProgressEvent = (_window_ProgressEvent = window.ProgressEvent) !== null && _window_ProgressEvent !== undefined ? _window_ProgressEvent : class ProgressEvent extends Event {
|
|
59
57
|
};
|
|
60
58
|
var _window_TransitionEvent;
|
|
61
|
-
const TransitionEvent = (_window_TransitionEvent = window.TransitionEvent) !== null && _window_TransitionEvent !==
|
|
59
|
+
const TransitionEvent = (_window_TransitionEvent = window.TransitionEvent) !== null && _window_TransitionEvent !== undefined ? _window_TransitionEvent : class TransitionEvent extends Event {
|
|
62
60
|
};
|
|
63
61
|
var _window_UIEvent;
|
|
64
|
-
const UIEvent = (_window_UIEvent = window.UIEvent) !== null && _window_UIEvent !==
|
|
62
|
+
const UIEvent = (_window_UIEvent = window.UIEvent) !== null && _window_UIEvent !== undefined ? _window_UIEvent : class UIEvent extends Event {
|
|
65
63
|
};
|
|
66
64
|
var _window_CompositionEvent;
|
|
67
|
-
const CompositionEvent = (_window_CompositionEvent = window.CompositionEvent) !== null && _window_CompositionEvent !==
|
|
65
|
+
const CompositionEvent = (_window_CompositionEvent = window.CompositionEvent) !== null && _window_CompositionEvent !== undefined ? _window_CompositionEvent : class CompositionEvent extends UIEvent {
|
|
68
66
|
};
|
|
69
67
|
var _window_FocusEvent;
|
|
70
|
-
const FocusEvent = (_window_FocusEvent = window.FocusEvent) !== null && _window_FocusEvent !==
|
|
68
|
+
const FocusEvent = (_window_FocusEvent = window.FocusEvent) !== null && _window_FocusEvent !== undefined ? _window_FocusEvent : class FocusEvent extends UIEvent {
|
|
71
69
|
};
|
|
72
70
|
var _window_InputEvent;
|
|
73
|
-
const InputEvent = (_window_InputEvent = window.InputEvent) !== null && _window_InputEvent !==
|
|
71
|
+
const InputEvent = (_window_InputEvent = window.InputEvent) !== null && _window_InputEvent !== undefined ? _window_InputEvent : class InputEvent extends UIEvent {
|
|
74
72
|
};
|
|
75
73
|
var _window_KeyboardEvent;
|
|
76
|
-
const KeyboardEvent = (_window_KeyboardEvent = window.KeyboardEvent) !== null && _window_KeyboardEvent !==
|
|
74
|
+
const KeyboardEvent = (_window_KeyboardEvent = window.KeyboardEvent) !== null && _window_KeyboardEvent !== undefined ? _window_KeyboardEvent : class KeyboardEvent extends UIEvent {
|
|
77
75
|
};
|
|
78
76
|
var _window_MouseEvent;
|
|
79
|
-
const MouseEvent = (_window_MouseEvent = window.MouseEvent) !== null && _window_MouseEvent !==
|
|
77
|
+
const MouseEvent = (_window_MouseEvent = window.MouseEvent) !== null && _window_MouseEvent !== undefined ? _window_MouseEvent : class MouseEvent extends UIEvent {
|
|
80
78
|
};
|
|
81
79
|
var _window_DragEvent;
|
|
82
|
-
const DragEvent = (_window_DragEvent = window.DragEvent) !== null && _window_DragEvent !==
|
|
80
|
+
const DragEvent = (_window_DragEvent = window.DragEvent) !== null && _window_DragEvent !== undefined ? _window_DragEvent : class DragEvent extends MouseEvent {
|
|
83
81
|
};
|
|
84
82
|
var _window_PointerEvent;
|
|
85
|
-
const PointerEvent = (_window_PointerEvent = window.PointerEvent) !== null && _window_PointerEvent !==
|
|
83
|
+
const PointerEvent = (_window_PointerEvent = window.PointerEvent) !== null && _window_PointerEvent !== undefined ? _window_PointerEvent : class PointerEvent extends MouseEvent {
|
|
86
84
|
};
|
|
87
85
|
var _window_TouchEvent;
|
|
88
|
-
const TouchEvent = (_window_TouchEvent = window.TouchEvent) !== null && _window_TouchEvent !==
|
|
86
|
+
const TouchEvent = (_window_TouchEvent = window.TouchEvent) !== null && _window_TouchEvent !== undefined ? _window_TouchEvent : class TouchEvent extends UIEvent {
|
|
89
87
|
};
|
|
90
88
|
/* eslint-enable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ return {
|
|
91
89
|
Event,
|
|
@@ -108,18 +106,23 @@ function createEvent(type, target, init) {
|
|
|
108
106
|
function assignProps(obj, props) {
|
|
109
107
|
for (const [key, value] of Object.entries(props)){
|
|
110
108
|
Object.defineProperty(obj, key, {
|
|
111
|
-
get: ()=>value !== null && value !==
|
|
109
|
+
get: ()=>value !== null && value !== undefined ? value : null
|
|
112
110
|
});
|
|
113
111
|
}
|
|
114
112
|
}
|
|
115
113
|
function sanitizeNumber(n) {
|
|
116
|
-
return Number(n !== null && n !==
|
|
114
|
+
return Number(n !== null && n !== undefined ? n : 0);
|
|
117
115
|
}
|
|
118
116
|
function initClipboardEvent(event, { clipboardData }) {
|
|
119
117
|
assignProps(event, {
|
|
120
118
|
clipboardData
|
|
121
119
|
});
|
|
122
120
|
}
|
|
121
|
+
function initFocusEvent(event, { relatedTarget }) {
|
|
122
|
+
assignProps(event, {
|
|
123
|
+
relatedTarget
|
|
124
|
+
});
|
|
125
|
+
}
|
|
123
126
|
function initInputEvent(event, { data, inputType, isComposing }) {
|
|
124
127
|
assignProps(event, {
|
|
125
128
|
data,
|
|
@@ -130,7 +133,7 @@ function initInputEvent(event, { data, inputType, isComposing }) {
|
|
|
130
133
|
function initUIEvent(event, { view, detail }) {
|
|
131
134
|
assignProps(event, {
|
|
132
135
|
view,
|
|
133
|
-
detail: sanitizeNumber(detail !== null && detail !==
|
|
136
|
+
detail: sanitizeNumber(detail !== null && detail !== undefined ? detail : 0)
|
|
134
137
|
});
|
|
135
138
|
}
|
|
136
139
|
function initUIEventModififiers(event, { altKey, ctrlKey, metaKey, shiftKey, modifierAltGraph, modifierCapsLock, modifierFn, modifierFnLock, modifierNumLock, modifierScrollLock, modifierSymbol, modifierSymbolLock }) {
|
|
@@ -167,7 +170,7 @@ function initKeyboardEvent(event, { key, code, location, repeat, isComposing, ch
|
|
|
167
170
|
charCode
|
|
168
171
|
});
|
|
169
172
|
}
|
|
170
|
-
function initMouseEvent(event, { x, y, screenX, screenY, clientX = x, clientY = y, button, buttons, relatedTarget }) {
|
|
173
|
+
function initMouseEvent(event, { x, y, screenX, screenY, clientX = x, clientY = y, button, buttons, relatedTarget, offsetX, offsetY, pageX, pageY }) {
|
|
171
174
|
assignProps(event, {
|
|
172
175
|
screenX: sanitizeNumber(screenX),
|
|
173
176
|
screenY: sanitizeNumber(screenY),
|
|
@@ -177,7 +180,11 @@ function initMouseEvent(event, { x, y, screenX, screenY, clientX = x, clientY =
|
|
|
177
180
|
y: sanitizeNumber(clientY),
|
|
178
181
|
button: sanitizeNumber(button),
|
|
179
182
|
buttons: sanitizeNumber(buttons),
|
|
180
|
-
relatedTarget
|
|
183
|
+
relatedTarget,
|
|
184
|
+
offsetX: sanitizeNumber(offsetX),
|
|
185
|
+
offsetY: sanitizeNumber(offsetY),
|
|
186
|
+
pageX: sanitizeNumber(pageX),
|
|
187
|
+
pageY: sanitizeNumber(pageY)
|
|
181
188
|
});
|
|
182
189
|
}
|
|
183
190
|
function initPointerEvent(event, { pointerId, width, height, pressure, tangentialPressure, tiltX, tiltY, twist, pointerType, isPrimary }) {
|
|
@@ -22,7 +22,7 @@ function dispatchUIEvent(target, type, init, preventDefault = false) {
|
|
|
22
22
|
function dispatchEvent(target, event, preventDefault = false) {
|
|
23
23
|
var _behavior_type;
|
|
24
24
|
const type = event.type;
|
|
25
|
-
const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type = behavior[type]) === null || _behavior_type ===
|
|
25
|
+
const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type = behavior[type]) === null || _behavior_type === undefined ? undefined : _behavior_type.call(behavior, event, target, this);
|
|
26
26
|
if (behaviorImplementation) {
|
|
27
27
|
event.preventDefault();
|
|
28
28
|
let defaultPrevented = false;
|