@testing-library/user-event 14.4.3 → 14.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/_interop/dtl.js +30 -0
- package/dist/cjs/_interop/dtlEventMap.js +30 -0
- package/dist/cjs/_interop/dtlHelpers.js +30 -0
- package/dist/cjs/clipboard/copy.js +2 -2
- package/dist/cjs/clipboard/cut.js +2 -2
- package/dist/cjs/clipboard/paste.js +4 -4
- package/dist/cjs/convenience/tab.js +1 -1
- package/dist/cjs/document/UI.js +5 -5
- package/dist/cjs/document/interceptor.js +6 -4
- package/dist/cjs/document/trackValue.js +4 -4
- package/dist/cjs/event/behavior/keydown.js +6 -6
- package/dist/cjs/event/behavior/keypress.js +4 -3
- package/dist/cjs/event/behavior/keyup.js +2 -2
- package/dist/cjs/event/behavior/paste.js +2 -2
- package/dist/cjs/event/createEvent.js +41 -41
- package/dist/cjs/event/dispatchEvent.js +2 -2
- package/dist/cjs/event/eventMap.js +2 -2
- package/dist/cjs/event/focus.js +2 -2
- package/dist/cjs/event/input.js +4 -4
- package/dist/cjs/event/selection/getInputRange.js +2 -2
- package/dist/cjs/event/selection/getTargetTypeAndSelection.js +3 -2
- package/dist/cjs/event/selection/modifySelection.js +3 -3
- package/dist/cjs/event/selection/modifySelectionPerMouse.js +4 -3
- package/dist/cjs/event/selection/moveSelection.js +6 -5
- package/dist/cjs/event/selection/resolveCaretPosition.js +1 -1
- package/dist/cjs/event/selection/selectAll.js +6 -5
- package/dist/cjs/event/selection/setSelection.js +3 -3
- package/dist/cjs/event/selection/setSelectionPerMouse.js +8 -7
- package/dist/cjs/event/selection/setSelectionRange.js +2 -2
- package/dist/cjs/event/selection/updateSelectionOnFocus.js +4 -3
- package/dist/cjs/event/wrapEvent.js +3 -2
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/keyboard/index.js +2 -2
- package/dist/cjs/keyboard/parseKeyDef.js +8 -8
- package/dist/cjs/pointer/index.js +11 -11
- package/dist/cjs/pointer/keyMap.js +1 -1
- package/dist/cjs/pointer/parseKeyDef.js +1 -1
- package/dist/cjs/setup/api.js +19 -17
- package/dist/cjs/setup/directApi.js +3 -3
- package/dist/cjs/setup/setup.js +10 -10
- package/dist/cjs/setup/wrapAsync.js +3 -2
- package/dist/cjs/system/index.js +15 -2
- package/dist/cjs/system/keyboard.js +27 -12
- package/dist/cjs/system/pointer/buttons.js +14 -1
- package/dist/cjs/system/pointer/device.js +14 -1
- package/dist/cjs/system/pointer/index.js +46 -26
- package/dist/cjs/system/pointer/mouse.js +33 -19
- package/dist/cjs/system/pointer/pointer.js +24 -8
- package/dist/cjs/system/pointer/shared.js +2 -2
- package/dist/cjs/utility/selectOptions.js +12 -11
- package/dist/cjs/utility/type.js +1 -1
- package/dist/cjs/utility/upload.js +6 -5
- package/dist/cjs/utils/dataTransfer/Clipboard.js +25 -9
- package/dist/cjs/utils/dataTransfer/DataTransfer.js +25 -9
- package/dist/cjs/utils/edit/maxLength.js +2 -2
- package/dist/cjs/utils/edit/setFiles.js +4 -4
- package/dist/cjs/utils/focus/cursor.js +2 -2
- package/dist/cjs/utils/focus/getActiveElement.js +4 -3
- package/dist/cjs/utils/focus/selector.js +1 -1
- package/dist/cjs/utils/keyDef/readNextDescriptor.js +5 -5
- package/dist/cjs/utils/misc/getTreeDiff.js +3 -3
- package/dist/cjs/utils/misc/getWindow.js +3 -2
- package/dist/cjs/utils/misc/isDisabled.js +3 -3
- package/dist/cjs/utils/misc/isVisible.js +3 -2
- package/dist/cjs/utils/misc/wait.js +1 -1
- package/dist/cjs/utils/pointer/cssPointerEvents.js +23 -19
- package/dist/esm/_interop/dtl.js +6 -0
- package/dist/esm/_interop/dtlEventMap.js +6 -0
- package/dist/esm/_interop/dtlHelpers.js +6 -0
- package/dist/esm/clipboard/copy.js +2 -2
- package/dist/esm/clipboard/cut.js +2 -2
- package/dist/esm/clipboard/paste.js +4 -4
- package/dist/esm/convenience/tab.js +1 -1
- package/dist/esm/document/UI.js +5 -5
- package/dist/esm/document/interceptor.js +6 -4
- package/dist/esm/document/trackValue.js +4 -4
- package/dist/esm/event/behavior/keydown.js +6 -6
- package/dist/esm/event/behavior/keypress.js +4 -3
- package/dist/esm/event/behavior/keyup.js +2 -2
- package/dist/esm/event/behavior/paste.js +2 -2
- package/dist/esm/event/createEvent.js +41 -41
- package/dist/esm/event/dispatchEvent.js +2 -2
- package/dist/esm/event/eventMap.js +2 -2
- package/dist/esm/event/focus.js +2 -2
- package/dist/esm/event/input.js +4 -4
- package/dist/esm/event/selection/getInputRange.js +2 -2
- package/dist/esm/event/selection/getTargetTypeAndSelection.js +3 -2
- package/dist/esm/event/selection/modifySelection.js +3 -3
- package/dist/esm/event/selection/modifySelectionPerMouse.js +4 -3
- package/dist/esm/event/selection/moveSelection.js +6 -5
- package/dist/esm/event/selection/resolveCaretPosition.js +1 -1
- package/dist/esm/event/selection/selectAll.js +6 -5
- package/dist/esm/event/selection/setSelection.js +3 -3
- package/dist/esm/event/selection/setSelectionPerMouse.js +8 -7
- package/dist/esm/event/selection/setSelectionRange.js +2 -2
- package/dist/esm/event/selection/updateSelectionOnFocus.js +4 -3
- package/dist/esm/event/wrapEvent.js +2 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/keyboard/index.js +2 -2
- package/dist/esm/keyboard/parseKeyDef.js +8 -8
- package/dist/esm/pointer/index.js +11 -11
- package/dist/esm/pointer/keyMap.js +1 -1
- package/dist/esm/pointer/parseKeyDef.js +1 -1
- package/dist/esm/setup/api.js +33 -12
- package/dist/esm/setup/directApi.js +3 -3
- package/dist/esm/setup/setup.js +11 -11
- package/dist/esm/setup/wrapAsync.js +2 -1
- package/dist/esm/system/index.js +15 -2
- package/dist/esm/system/keyboard.js +27 -12
- package/dist/esm/system/pointer/buttons.js +14 -1
- package/dist/esm/system/pointer/device.js +14 -1
- package/dist/esm/system/pointer/index.js +46 -26
- package/dist/esm/system/pointer/mouse.js +33 -19
- package/dist/esm/system/pointer/pointer.js +24 -8
- package/dist/esm/system/pointer/shared.js +2 -2
- package/dist/esm/utility/selectOptions.js +8 -7
- package/dist/esm/utility/type.js +1 -1
- package/dist/esm/utility/upload.js +6 -5
- package/dist/esm/utils/dataTransfer/Clipboard.js +25 -9
- package/dist/esm/utils/dataTransfer/DataTransfer.js +25 -9
- package/dist/esm/utils/edit/maxLength.js +2 -2
- package/dist/esm/utils/edit/setFiles.js +4 -4
- package/dist/esm/utils/focus/cursor.js +2 -2
- package/dist/esm/utils/focus/getActiveElement.js +4 -3
- package/dist/esm/utils/focus/selector.js +1 -1
- package/dist/esm/utils/keyDef/readNextDescriptor.js +5 -5
- package/dist/esm/utils/misc/getTreeDiff.js +3 -3
- package/dist/esm/utils/misc/getWindow.js +2 -1
- package/dist/esm/utils/misc/isDisabled.js +3 -3
- package/dist/esm/utils/misc/isVisible.js +3 -2
- package/dist/esm/utils/misc/wait.js +1 -1
- package/dist/esm/utils/pointer/cssPointerEvents.js +23 -19
- package/dist/types/_interop/dtl.d.ts +3 -0
- package/dist/types/_interop/dtlEventMap.d.ts +3 -0
- package/dist/types/_interop/dtlHelpers.d.ts +3 -0
- package/dist/types/clipboard/copy.d.ts +1 -1
- package/dist/types/clipboard/cut.d.ts +1 -1
- package/dist/types/clipboard/paste.d.ts +1 -1
- package/dist/types/convenience/click.d.ts +1 -1
- package/dist/types/convenience/hover.d.ts +1 -1
- package/dist/types/convenience/tab.d.ts +1 -1
- package/dist/types/document/UI.d.ts +3 -3
- package/dist/types/document/interceptor.d.ts +3 -3
- package/dist/types/event/behavior/registry.d.ts +1 -1
- package/dist/types/event/createEvent.d.ts +1 -1
- package/dist/types/event/dispatchEvent.d.ts +1 -1
- package/dist/types/event/eventMap.d.ts +8 -0
- package/dist/types/event/input.d.ts +1 -1
- package/dist/types/event/radio.d.ts +1 -1
- package/dist/types/event/selection/index.d.ts +2 -2
- package/dist/types/event/selection/modifySelectionPerMouse.d.ts +1 -1
- package/dist/types/event/selection/setSelectionPerMouse.d.ts +1 -1
- package/dist/types/event/types.d.ts +3 -3
- package/dist/types/index.d.ts +3 -1
- package/dist/types/keyboard/index.d.ts +1 -1
- package/dist/types/options.d.ts +2 -2
- package/dist/types/pointer/index.d.ts +7 -7
- package/dist/types/setup/api.d.ts +23 -5
- package/dist/types/setup/directApi.d.ts +5 -5
- package/dist/types/setup/setup.d.ts +5 -5
- package/dist/types/system/keyboard.d.ts +2 -2
- package/dist/types/system/pointer/buttons.d.ts +2 -2
- package/dist/types/system/pointer/device.d.ts +1 -1
- package/dist/types/system/pointer/mouse.d.ts +2 -2
- package/dist/types/system/pointer/pointer.d.ts +2 -2
- 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 +2 -2
- package/dist/types/utility/upload.d.ts +1 -1
- package/dist/types/utils/click/isClickableInput.d.ts +1 -1
- package/dist/types/utils/dataTransfer/Clipboard.d.ts +1 -1
- package/dist/types/utils/edit/isEditable.d.ts +2 -2
- package/dist/types/utils/edit/maxLength.d.ts +1 -1
- package/dist/types/utils/keyDef/readNextDescriptor.d.ts +1 -1
- package/dist/types/utils/misc/isElementType.d.ts +1 -1
- package/dist/types/utils/misc/level.d.ts +2 -2
- package/dist/types/utils/misc/wait.d.ts +1 -1
- package/dist/types/utils/pointer/cssPointerEvents.d.ts +1 -1
- package/package.json +22 -11
- /package/dist/cjs/{event → _interop}/dom-events.d.js +0 -0
- /package/dist/cjs/{utils/misc → _interop}/dom-helpers.d.js +0 -0
- /package/dist/esm/{event → _interop}/dom-events.d.js +0 -0
- /package/dist/esm/{utils/misc → _interop}/dom-helpers.d.js +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var def = require('@testing-library/dom');
|
|
4
|
+
|
|
5
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
6
|
+
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n["default"] = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var def__default = /*#__PURE__*/_interopDefaultLegacy(def);
|
|
26
|
+
var def__namespace = /*#__PURE__*/_interopNamespace(def);
|
|
27
|
+
|
|
28
|
+
var dtl = def__default["default"] !== null && def__default["default"] !== void 0 ? def__default["default"] : def__namespace;
|
|
29
|
+
|
|
30
|
+
module.exports = dtl;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var def = require('@testing-library/dom/dist/event-map.js');
|
|
4
|
+
|
|
5
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
6
|
+
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n["default"] = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var def__default = /*#__PURE__*/_interopDefaultLegacy(def);
|
|
26
|
+
var def__namespace = /*#__PURE__*/_interopNamespace(def);
|
|
27
|
+
|
|
28
|
+
var dtlEvents = def__default["default"] !== null && def__default["default"] !== void 0 ? def__default["default"] : def__namespace;
|
|
29
|
+
|
|
30
|
+
module.exports = dtlEvents;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var def = require('@testing-library/dom/dist/helpers.js');
|
|
4
|
+
|
|
5
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
6
|
+
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n["default"] = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var def__default = /*#__PURE__*/_interopDefaultLegacy(def);
|
|
26
|
+
var def__namespace = /*#__PURE__*/_interopNamespace(def);
|
|
27
|
+
|
|
28
|
+
var dtlHelpers = def__default["default"] !== null && def__default["default"] !== void 0 ? def__default["default"] : def__namespace;
|
|
29
|
+
|
|
30
|
+
module.exports = dtlHelpers;
|
|
@@ -14,8 +14,8 @@ var copySelection = require('../document/copySelection.js');
|
|
|
14
14
|
|
|
15
15
|
async function copy() {
|
|
16
16
|
const doc = this.config.document;
|
|
17
|
-
var
|
|
18
|
-
const target = (
|
|
17
|
+
var _doc_activeElement;
|
|
18
|
+
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== void 0 ? _doc_activeElement : /* istanbul ignore next */ doc.body;
|
|
19
19
|
const clipboardData = copySelection.copySelection(target);
|
|
20
20
|
if (clipboardData.items.length === 0) {
|
|
21
21
|
return;
|
|
@@ -14,8 +14,8 @@ var copySelection = require('../document/copySelection.js');
|
|
|
14
14
|
|
|
15
15
|
async function cut() {
|
|
16
16
|
const doc = this.config.document;
|
|
17
|
-
var
|
|
18
|
-
const target = (
|
|
17
|
+
var _doc_activeElement;
|
|
18
|
+
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== void 0 ? _doc_activeElement : /* istanbul ignore next */ doc.body;
|
|
19
19
|
const clipboardData = copySelection.copySelection(target);
|
|
20
20
|
if (clipboardData.items.length === 0) {
|
|
21
21
|
return;
|
|
@@ -14,10 +14,10 @@ require('../options.js');
|
|
|
14
14
|
|
|
15
15
|
async function paste(clipboardData) {
|
|
16
16
|
const doc = this.config.document;
|
|
17
|
-
var
|
|
18
|
-
const target = (
|
|
19
|
-
var
|
|
20
|
-
const dataTransfer = (
|
|
17
|
+
var _doc_activeElement;
|
|
18
|
+
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== void 0 ? _doc_activeElement : /* istanbul ignore next */ doc.body;
|
|
19
|
+
var _ref;
|
|
20
|
+
const dataTransfer = (_ref = typeof clipboardData === 'string' ? getClipboardDataFromString(doc, clipboardData) : clipboardData) !== null && _ref !== void 0 ? _ref : await Clipboard.readDataTransferFromClipboard(doc).catch(()=>{
|
|
21
21
|
throw new Error('`userEvent.paste()` without `clipboardData` requires the `ClipboardAPI` to be available.');
|
|
22
22
|
});
|
|
23
23
|
this.dispatchUIEvent(target, 'paste', {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
async function tab({ shift
|
|
5
|
+
async function tab({ shift } = {}) {
|
|
6
6
|
return this.keyboard(shift === true ? '{Shift>}{Tab}{/Shift}' : shift === false ? '[/ShiftLeft][/ShiftRight]{Tab}' : '{Tab}');
|
|
7
7
|
}
|
|
8
8
|
|
package/dist/cjs/document/UI.js
CHANGED
|
@@ -36,7 +36,7 @@ function getInitialValue(element) {
|
|
|
36
36
|
function setUISelectionRaw(element, selection) {
|
|
37
37
|
element[UISelection] = selection;
|
|
38
38
|
}
|
|
39
|
-
function setUISelection(element, { focusOffset: focusOffsetParam
|
|
39
|
+
function setUISelection(element, { focusOffset: focusOffsetParam, anchorOffset: anchorOffsetParam = focusOffsetParam }, mode = 'replace') {
|
|
40
40
|
const valueLength = getUIValue(element).length;
|
|
41
41
|
const sanitizeOffset = (o)=>Math.max(0, Math.min(valueLength, o));
|
|
42
42
|
const anchorOffset = mode === 'replace' || element[UISelection] === undefined ? sanitizeOffset(anchorOffsetParam) : element[UISelection].anchorOffset;
|
|
@@ -62,10 +62,10 @@ function setUISelection(element, { focusOffset: focusOffsetParam , anchorOffset:
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
function getUISelection(element) {
|
|
65
|
-
var
|
|
66
|
-
const sel = (
|
|
67
|
-
anchorOffset: (
|
|
68
|
-
focusOffset: (
|
|
65
|
+
var _element_selectionStart, _element_selectionEnd, _element_UISelection;
|
|
66
|
+
const sel = (_element_UISelection = element[UISelection]) !== null && _element_UISelection !== void 0 ? _element_UISelection : {
|
|
67
|
+
anchorOffset: (_element_selectionStart = element.selectionStart) !== null && _element_selectionStart !== void 0 ? _element_selectionStart : 0,
|
|
68
|
+
focusOffset: (_element_selectionEnd = element.selectionEnd) !== null && _element_selectionEnd !== void 0 ? _element_selectionEnd : 0
|
|
69
69
|
};
|
|
70
70
|
return {
|
|
71
71
|
...sel,
|
|
@@ -16,21 +16,23 @@ var UI = require('./UI.js');
|
|
|
16
16
|
|
|
17
17
|
const Interceptor = Symbol('Interceptor for programmatical calls');
|
|
18
18
|
function prepareInterceptor(element, propName, interceptorImpl) {
|
|
19
|
+
var _prototypeDescriptor, _prototypeDescriptor1;
|
|
19
20
|
const prototypeDescriptor = Object.getOwnPropertyDescriptor(element.constructor.prototype, propName);
|
|
20
21
|
const objectDescriptor = Object.getOwnPropertyDescriptor(element, propName);
|
|
21
|
-
const target = (prototypeDescriptor === null ||
|
|
22
|
-
/* istanbul ignore if */ if (typeof (prototypeDescriptor === null ||
|
|
22
|
+
const target = ((_prototypeDescriptor = prototypeDescriptor) === null || _prototypeDescriptor === void 0 ? void 0 : _prototypeDescriptor.set) ? 'set' : 'value';
|
|
23
|
+
/* istanbul ignore if */ if (typeof ((_prototypeDescriptor1 = prototypeDescriptor) === null || _prototypeDescriptor1 === void 0 ? void 0 : _prototypeDescriptor1[target]) !== 'function' || prototypeDescriptor[target][Interceptor]) {
|
|
23
24
|
throw new Error(`Element ${element.tagName} does not implement "${String(propName)}".`);
|
|
24
25
|
}
|
|
25
26
|
function intercept(...args) {
|
|
26
|
-
|
|
27
|
+
var _then;
|
|
28
|
+
const { applyNative = false, realArgs, then } = interceptorImpl.call(this, ...args);
|
|
27
29
|
const realFunc = (!applyNative && objectDescriptor || prototypeDescriptor)[target];
|
|
28
30
|
if (target === 'set') {
|
|
29
31
|
realFunc.call(this, realArgs);
|
|
30
32
|
} else {
|
|
31
33
|
realFunc.call(this, ...realArgs);
|
|
32
34
|
}
|
|
33
|
-
then === null ||
|
|
35
|
+
(_then = then) === null || _then === void 0 ? void 0 : _then();
|
|
34
36
|
}
|
|
35
37
|
intercept[Interceptor] = Interceptor;
|
|
36
38
|
Object.defineProperty(element, propName, {
|
|
@@ -33,8 +33,8 @@ function startTrackValue(element) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
function trackOrSetValue(element, v) {
|
|
36
|
-
var
|
|
37
|
-
(
|
|
36
|
+
var _element_TrackChanges_tracked, _element_TrackChanges;
|
|
37
|
+
(_element_TrackChanges = element[TrackChanges]) === null || _element_TrackChanges === void 0 ? void 0 : (_element_TrackChanges_tracked = _element_TrackChanges.tracked) === null || _element_TrackChanges_tracked === void 0 ? void 0 : _element_TrackChanges_tracked.push(v);
|
|
38
38
|
if (!element[TrackChanges]) {
|
|
39
39
|
UI.setUIValueClean(element);
|
|
40
40
|
UI.setUISelection(element, {
|
|
@@ -43,10 +43,10 @@ function trackOrSetValue(element, v) {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
function commitValueAfterInput(element, cursorOffset) {
|
|
46
|
-
var
|
|
46
|
+
var _changes_tracked, _changes;
|
|
47
47
|
const changes = element[TrackChanges];
|
|
48
48
|
element[TrackChanges] = undefined;
|
|
49
|
-
if (!(changes === null ||
|
|
49
|
+
if (!((_changes = changes) === null || _changes === void 0 ? void 0 : (_changes_tracked = _changes.tracked) === null || _changes_tracked === void 0 ? void 0 : _changes_tracked.length)) {
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
const isJustReactStateUpdate = changes.tracked.length === 2 && changes.tracked[0] === changes.previousValue && changes.tracked[1] === element.value;
|
|
@@ -23,9 +23,9 @@ var radio = require('../radio.js');
|
|
|
23
23
|
var registry = require('./registry.js');
|
|
24
24
|
|
|
25
25
|
registry.behavior.keydown = (event, target, instance)=>{
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
return (
|
|
26
|
+
var _keydownBehavior_event_key, _keydownBehavior;
|
|
27
|
+
var _keydownBehavior_event_key1;
|
|
28
|
+
return (_keydownBehavior_event_key1 = (_keydownBehavior_event_key = (_keydownBehavior = 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);
|
|
29
29
|
};
|
|
30
30
|
const keydownBehavior = {
|
|
31
31
|
ArrowDown: (event, target, instance)=>{
|
|
@@ -78,9 +78,9 @@ const keydownBehavior = {
|
|
|
78
78
|
'textarea'
|
|
79
79
|
]) || isContentEditable.isContentEditable(target)) {
|
|
80
80
|
return ()=>{
|
|
81
|
-
var
|
|
82
|
-
var
|
|
83
|
-
const newPos = (
|
|
81
|
+
var _getValueOrTextContent;
|
|
82
|
+
var _getValueOrTextContent_length;
|
|
83
|
+
const newPos = (_getValueOrTextContent_length = (_getValueOrTextContent = getValueOrTextContent.getValueOrTextContent(target)) === null || _getValueOrTextContent === void 0 ? void 0 : _getValueOrTextContent.length) !== null && _getValueOrTextContent_length !== void 0 ? _getValueOrTextContent_length : /* istanbul ignore next */ 0;
|
|
84
84
|
setSelectionRange.setSelectionRange(target, newPos, newPos);
|
|
85
85
|
};
|
|
86
86
|
}
|
|
@@ -20,8 +20,9 @@ registry.behavior.keypress = (event, target, instance)=>{
|
|
|
20
20
|
instance.dispatchUIEvent(target, 'click');
|
|
21
21
|
};
|
|
22
22
|
} else if (isElementType.isElementType(target, 'input')) {
|
|
23
|
+
var _form;
|
|
23
24
|
const form = target.form;
|
|
24
|
-
const submit = form === null ||
|
|
25
|
+
const submit = (_form = form) === null || _form === void 0 ? void 0 : _form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]');
|
|
25
26
|
if (submit) {
|
|
26
27
|
return ()=>instance.dispatchUIEvent(submit, 'click');
|
|
27
28
|
} else if (form && SubmitSingleInputOnEnter.includes(target.type) && form.querySelectorAll('input').length === 1) {
|
|
@@ -43,7 +44,7 @@ const ClickInputOnEnter = [
|
|
|
43
44
|
'file',
|
|
44
45
|
'image',
|
|
45
46
|
'reset',
|
|
46
|
-
'submit'
|
|
47
|
+
'submit'
|
|
47
48
|
];
|
|
48
49
|
const SubmitSingleInputOnEnter = [
|
|
49
50
|
'email',
|
|
@@ -53,5 +54,5 @@ const SubmitSingleInputOnEnter = [
|
|
|
53
54
|
'tel',
|
|
54
55
|
'text',
|
|
55
56
|
'url',
|
|
56
|
-
'week'
|
|
57
|
+
'week'
|
|
57
58
|
];
|
|
@@ -11,8 +11,8 @@ require('../../options.js');
|
|
|
11
11
|
var registry = require('./registry.js');
|
|
12
12
|
|
|
13
13
|
registry.behavior.keyup = (event, target, instance)=>{
|
|
14
|
-
var
|
|
15
|
-
return (
|
|
14
|
+
var _keyupBehavior_event_key, _keyupBehavior;
|
|
15
|
+
return (_keyupBehavior_event_key = (_keyupBehavior = keyupBehavior)[event.key]) === null || _keyupBehavior_event_key === void 0 ? void 0 : _keyupBehavior_event_key.call(_keyupBehavior, event, target, instance);
|
|
16
16
|
};
|
|
17
17
|
const keyupBehavior = {
|
|
18
18
|
' ': (event, target, instance)=>{
|
|
@@ -14,8 +14,8 @@ var registry = require('./registry.js');
|
|
|
14
14
|
registry.behavior.paste = (event, target, instance)=>{
|
|
15
15
|
if (isEditable.isEditable(target)) {
|
|
16
16
|
return ()=>{
|
|
17
|
-
var
|
|
18
|
-
const insertData = (
|
|
17
|
+
var _event_clipboardData;
|
|
18
|
+
const insertData = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text');
|
|
19
19
|
if (insertData) {
|
|
20
20
|
input.input(instance, target, insertData, 'insertFromPaste');
|
|
21
21
|
}
|
|
@@ -29,7 +29,7 @@ const eventInitializer = {
|
|
|
29
29
|
initUIEvent,
|
|
30
30
|
initUIEventModififiers,
|
|
31
31
|
initMouseEvent,
|
|
32
|
-
initPointerEvent
|
|
32
|
+
initPointerEvent
|
|
33
33
|
],
|
|
34
34
|
KeyboardEvent: [
|
|
35
35
|
initUIEvent,
|
|
@@ -38,58 +38,58 @@ const eventInitializer = {
|
|
|
38
38
|
]
|
|
39
39
|
};
|
|
40
40
|
function createEvent(type, target, init) {
|
|
41
|
-
var
|
|
41
|
+
var _eventInitializer_EventType;
|
|
42
42
|
const window = getWindow.getWindow(target);
|
|
43
|
-
const { EventType
|
|
43
|
+
const { EventType, defaultInit } = eventMap.eventMap[eventMap.eventMapKeys[type]];
|
|
44
44
|
const event = new (getEventConstructors(window))[EventType](type, defaultInit);
|
|
45
|
-
(
|
|
45
|
+
(_eventInitializer_EventType = eventInitializer[EventType]) === null || _eventInitializer_EventType === void 0 ? void 0 : _eventInitializer_EventType.forEach((f)=>f(event, init !== null && init !== void 0 ? init : {}));
|
|
46
46
|
return event;
|
|
47
47
|
}
|
|
48
48
|
/* istanbul ignore next */ function getEventConstructors(window) {
|
|
49
|
-
var
|
|
50
|
-
/* eslint-disable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ const Event = (
|
|
49
|
+
var _window_Event;
|
|
50
|
+
/* eslint-disable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ const Event = (_window_Event = window.Event) !== null && _window_Event !== void 0 ? _window_Event : class Event {
|
|
51
51
|
};
|
|
52
|
-
var
|
|
53
|
-
const AnimationEvent = (
|
|
52
|
+
var _window_AnimationEvent;
|
|
53
|
+
const AnimationEvent = (_window_AnimationEvent = window.AnimationEvent) !== null && _window_AnimationEvent !== void 0 ? _window_AnimationEvent : class AnimationEvent extends Event {
|
|
54
54
|
};
|
|
55
|
-
var
|
|
56
|
-
const ClipboardEvent = (
|
|
55
|
+
var _window_ClipboardEvent;
|
|
56
|
+
const ClipboardEvent = (_window_ClipboardEvent = window.ClipboardEvent) !== null && _window_ClipboardEvent !== void 0 ? _window_ClipboardEvent : class ClipboardEvent extends Event {
|
|
57
57
|
};
|
|
58
|
-
var
|
|
59
|
-
const PopStateEvent = (
|
|
58
|
+
var _window_PopStateEvent;
|
|
59
|
+
const PopStateEvent = (_window_PopStateEvent = window.PopStateEvent) !== null && _window_PopStateEvent !== void 0 ? _window_PopStateEvent : class PopStateEvent extends Event {
|
|
60
60
|
};
|
|
61
|
-
var
|
|
62
|
-
const ProgressEvent = (
|
|
61
|
+
var _window_ProgressEvent;
|
|
62
|
+
const ProgressEvent = (_window_ProgressEvent = window.ProgressEvent) !== null && _window_ProgressEvent !== void 0 ? _window_ProgressEvent : class ProgressEvent extends Event {
|
|
63
63
|
};
|
|
64
|
-
var
|
|
65
|
-
const TransitionEvent = (
|
|
64
|
+
var _window_TransitionEvent;
|
|
65
|
+
const TransitionEvent = (_window_TransitionEvent = window.TransitionEvent) !== null && _window_TransitionEvent !== void 0 ? _window_TransitionEvent : class TransitionEvent extends Event {
|
|
66
66
|
};
|
|
67
|
-
var
|
|
68
|
-
const UIEvent = (
|
|
67
|
+
var _window_UIEvent;
|
|
68
|
+
const UIEvent = (_window_UIEvent = window.UIEvent) !== null && _window_UIEvent !== void 0 ? _window_UIEvent : class UIEvent extends Event {
|
|
69
69
|
};
|
|
70
|
-
var
|
|
71
|
-
const CompositionEvent = (
|
|
70
|
+
var _window_CompositionEvent;
|
|
71
|
+
const CompositionEvent = (_window_CompositionEvent = window.CompositionEvent) !== null && _window_CompositionEvent !== void 0 ? _window_CompositionEvent : class CompositionEvent extends UIEvent {
|
|
72
72
|
};
|
|
73
|
-
var
|
|
74
|
-
const FocusEvent = (
|
|
73
|
+
var _window_FocusEvent;
|
|
74
|
+
const FocusEvent = (_window_FocusEvent = window.FocusEvent) !== null && _window_FocusEvent !== void 0 ? _window_FocusEvent : class FocusEvent extends UIEvent {
|
|
75
75
|
};
|
|
76
|
-
var
|
|
77
|
-
const InputEvent = (
|
|
76
|
+
var _window_InputEvent;
|
|
77
|
+
const InputEvent = (_window_InputEvent = window.InputEvent) !== null && _window_InputEvent !== void 0 ? _window_InputEvent : class InputEvent extends UIEvent {
|
|
78
78
|
};
|
|
79
|
-
var
|
|
80
|
-
const KeyboardEvent = (
|
|
79
|
+
var _window_KeyboardEvent;
|
|
80
|
+
const KeyboardEvent = (_window_KeyboardEvent = window.KeyboardEvent) !== null && _window_KeyboardEvent !== void 0 ? _window_KeyboardEvent : class KeyboardEvent extends UIEvent {
|
|
81
81
|
};
|
|
82
|
-
var
|
|
83
|
-
const MouseEvent = (
|
|
82
|
+
var _window_MouseEvent;
|
|
83
|
+
const MouseEvent = (_window_MouseEvent = window.MouseEvent) !== null && _window_MouseEvent !== void 0 ? _window_MouseEvent : class MouseEvent extends UIEvent {
|
|
84
84
|
};
|
|
85
|
-
var
|
|
86
|
-
const DragEvent = (
|
|
85
|
+
var _window_DragEvent;
|
|
86
|
+
const DragEvent = (_window_DragEvent = window.DragEvent) !== null && _window_DragEvent !== void 0 ? _window_DragEvent : class DragEvent extends MouseEvent {
|
|
87
87
|
};
|
|
88
|
-
var
|
|
89
|
-
const PointerEvent = (
|
|
88
|
+
var _window_PointerEvent;
|
|
89
|
+
const PointerEvent = (_window_PointerEvent = window.PointerEvent) !== null && _window_PointerEvent !== void 0 ? _window_PointerEvent : class PointerEvent extends MouseEvent {
|
|
90
90
|
};
|
|
91
|
-
var
|
|
92
|
-
const TouchEvent = (
|
|
91
|
+
var _window_TouchEvent;
|
|
92
|
+
const TouchEvent = (_window_TouchEvent = window.TouchEvent) !== null && _window_TouchEvent !== void 0 ? _window_TouchEvent : class TouchEvent extends UIEvent {
|
|
93
93
|
};
|
|
94
94
|
/* eslint-enable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ return {
|
|
95
95
|
Event,
|
|
@@ -119,25 +119,25 @@ function assignProps(obj, props) {
|
|
|
119
119
|
function sanitizeNumber(n) {
|
|
120
120
|
return Number(n !== null && n !== void 0 ? n : 0);
|
|
121
121
|
}
|
|
122
|
-
function initClipboardEvent(event, { clipboardData
|
|
122
|
+
function initClipboardEvent(event, { clipboardData }) {
|
|
123
123
|
assignProps(event, {
|
|
124
124
|
clipboardData
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
|
-
function initInputEvent(event, { data
|
|
127
|
+
function initInputEvent(event, { data, inputType, isComposing }) {
|
|
128
128
|
assignProps(event, {
|
|
129
129
|
data,
|
|
130
130
|
isComposing: Boolean(isComposing),
|
|
131
131
|
inputType: String(inputType)
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
function initUIEvent(event, { view
|
|
134
|
+
function initUIEvent(event, { view, detail }) {
|
|
135
135
|
assignProps(event, {
|
|
136
136
|
view,
|
|
137
137
|
detail: sanitizeNumber(detail !== null && detail !== void 0 ? detail : 0)
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
|
-
function initUIEventModififiers(event, { altKey
|
|
140
|
+
function initUIEventModififiers(event, { altKey, ctrlKey, metaKey, shiftKey, modifierAltGraph, modifierCapsLock, modifierFn, modifierFnLock, modifierNumLock, modifierScrollLock, modifierSymbol, modifierSymbolLock }) {
|
|
141
141
|
assignProps(event, {
|
|
142
142
|
altKey: Boolean(altKey),
|
|
143
143
|
ctrlKey: Boolean(ctrlKey),
|
|
@@ -161,7 +161,7 @@ function initUIEventModififiers(event, { altKey , ctrlKey , metaKey , shiftKey ,
|
|
|
161
161
|
}
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
|
-
function initKeyboardEvent(event, { key
|
|
164
|
+
function initKeyboardEvent(event, { key, code, location, repeat, isComposing, charCode }) {
|
|
165
165
|
assignProps(event, {
|
|
166
166
|
key: String(key),
|
|
167
167
|
code: String(code),
|
|
@@ -171,7 +171,7 @@ function initKeyboardEvent(event, { key , code , location , repeat , isComposing
|
|
|
171
171
|
charCode
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
|
-
function initMouseEvent(event, { x
|
|
174
|
+
function initMouseEvent(event, { x, y, screenX, screenY, clientX = x, clientY = y, button, buttons, relatedTarget }) {
|
|
175
175
|
assignProps(event, {
|
|
176
176
|
screenX: sanitizeNumber(screenX),
|
|
177
177
|
screenY: sanitizeNumber(screenY),
|
|
@@ -184,7 +184,7 @@ function initMouseEvent(event, { x , y , screenX , screenY , clientX =x , client
|
|
|
184
184
|
relatedTarget
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
|
-
function initPointerEvent(event, { pointerId
|
|
187
|
+
function initPointerEvent(event, { pointerId, width, height, pressure, tangentialPressure, tiltX, tiltY, twist, pointerType, isPrimary }) {
|
|
188
188
|
assignProps(event, {
|
|
189
189
|
pointerId: sanitizeNumber(pointerId),
|
|
190
190
|
width: sanitizeNumber(width),
|
|
@@ -24,9 +24,9 @@ function dispatchUIEvent(target, type, init, preventDefault = false) {
|
|
|
24
24
|
return dispatchEvent.call(this, target, event, preventDefault);
|
|
25
25
|
}
|
|
26
26
|
function dispatchEvent(target, event, preventDefault = false) {
|
|
27
|
-
var
|
|
27
|
+
var _behavior_type, _behavior;
|
|
28
28
|
const type = event.type;
|
|
29
|
-
const behaviorImplementation = preventDefault ? ()=>{} : (
|
|
29
|
+
const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type = (_behavior = registry.behavior)[type]) === null || _behavior_type === void 0 ? void 0 : _behavior_type.call(_behavior, event, target, this);
|
|
30
30
|
if (behaviorImplementation) {
|
|
31
31
|
event.preventDefault();
|
|
32
32
|
let defaultPrevented = false;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var dtlEventMap = require('../_interop/dtlEventMap.js');
|
|
6
6
|
|
|
7
7
|
const eventMap = {
|
|
8
|
-
...
|
|
8
|
+
...dtlEventMap.eventMap,
|
|
9
9
|
click: {
|
|
10
10
|
EventType: 'PointerEvent',
|
|
11
11
|
defaultInit: {
|
package/dist/cjs/event/focus.js
CHANGED
|
@@ -27,8 +27,8 @@ var wrapEvent = require('./wrapEvent.js');
|
|
|
27
27
|
wrapEvent.wrapEvent(()=>target.focus());
|
|
28
28
|
} else {
|
|
29
29
|
wrapEvent.wrapEvent(()=>{
|
|
30
|
-
var
|
|
31
|
-
return (
|
|
30
|
+
var _activeElement;
|
|
31
|
+
return (_activeElement = activeElement) === null || _activeElement === void 0 ? void 0 : _activeElement.blur();
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
updateSelectionOnFocus.updateSelectionOnFocus(target !== null && target !== void 0 ? target : element.ownerDocument.body);
|
package/dist/cjs/event/input.js
CHANGED
|
@@ -98,7 +98,7 @@ function editInputElement(instance, element, inputRange, data, inputType) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
const { newValue
|
|
101
|
+
const { newValue, newOffset, oldValue } = calculateNewValue(dataToInsert, element, inputRange, inputType);
|
|
102
102
|
if (newValue === oldValue && newOffset === inputRange.startOffset && newOffset === inputRange.endOffset) {
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
@@ -126,7 +126,7 @@ function editInputElement(instance, element, inputRange, data, inputType) {
|
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
function calculateNewValue(inputData, node, { startOffset
|
|
129
|
+
function calculateNewValue(inputData, node, { startOffset, endOffset }, inputType) {
|
|
130
130
|
const value = UI.getUIValue(node);
|
|
131
131
|
const prologEnd = Math.max(0, startOffset === endOffset && inputType === 'deleteContentBackward' ? startOffset - 1 : startOffset);
|
|
132
132
|
const prolog = value.substring(0, prologEnd);
|
|
@@ -154,12 +154,12 @@ function commitInput(instance, element, newOffset, inputInit) {
|
|
|
154
154
|
trackValue.commitValueAfterInput(element, newOffset);
|
|
155
155
|
}
|
|
156
156
|
function isValidNumberInput(value) {
|
|
157
|
-
var
|
|
157
|
+
var _value_match, _value_match1;
|
|
158
158
|
// the browser allows some invalid input but not others
|
|
159
159
|
// it allows up to two '-' at any place before any 'e' or one directly following 'e'
|
|
160
160
|
// it allows one '.' at any place before e
|
|
161
161
|
const valueParts = value.split('e', 2);
|
|
162
|
-
return !(/[^\d.\-e]/.test(value) || Number((
|
|
162
|
+
return !(/[^\d.\-e]/.test(value) || Number((_value_match = value.match(/-/g)) === null || _value_match === void 0 ? void 0 : _value_match.length) > 2 || Number((_value_match1 = value.match(/\./g)) === null || _value_match1 === void 0 ? void 0 : _value_match1.length) > 1 || valueParts[1] && !/^-?\d*$/.test(valueParts[1]));
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
exports.input = input;
|
|
@@ -11,9 +11,9 @@ var getTargetTypeAndSelection = require('./getTargetTypeAndSelection.js');
|
|
|
11
11
|
if (typeAndSelection.type === 'input') {
|
|
12
12
|
return typeAndSelection.selection;
|
|
13
13
|
} else if (typeAndSelection.type === 'contenteditable') {
|
|
14
|
-
var
|
|
14
|
+
var _typeAndSelection_selection;
|
|
15
15
|
// Multi-range on contenteditable edits the first selection instead of the last
|
|
16
|
-
return (
|
|
16
|
+
return (_typeAndSelection_selection = typeAndSelection.selection) === null || _typeAndSelection_selection === void 0 ? void 0 : _typeAndSelection_selection.getRangeAt(0);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -17,6 +17,7 @@ require('../../options.js');
|
|
|
17
17
|
/**
|
|
18
18
|
* Determine which selection logic and selection ranges to consider.
|
|
19
19
|
*/ function getTargetTypeAndSelection(node) {
|
|
20
|
+
var _element, _selection;
|
|
20
21
|
const element = getElement(node);
|
|
21
22
|
if (element && selection.hasOwnSelection(element)) {
|
|
22
23
|
return {
|
|
@@ -24,10 +25,10 @@ require('../../options.js');
|
|
|
24
25
|
selection: UI.getUISelection(element)
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
|
-
const selection$1 = element === null ||
|
|
28
|
+
const selection$1 = (_element = element) === null || _element === void 0 ? void 0 : _element.ownerDocument.getSelection();
|
|
28
29
|
// It is possible to extend a single-range selection into a contenteditable.
|
|
29
30
|
// This results in the range acting like a range outside of contenteditable.
|
|
30
|
-
const isCE = isContentEditable.getContentEditable(node) && (selection$1 === null ||
|
|
31
|
+
const isCE = isContentEditable.getContentEditable(node) && ((_selection = selection$1) === null || _selection === void 0 ? void 0 : _selection.anchorNode) && isContentEditable.getContentEditable(selection$1.anchorNode);
|
|
31
32
|
return {
|
|
32
33
|
type: isCE ? 'contenteditable' : 'default',
|
|
33
34
|
selection: selection$1
|
|
@@ -15,8 +15,8 @@ var getTargetTypeAndSelection = require('./getTargetTypeAndSelection.js');
|
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Extend/shrink the selection like with Shift+Arrows or Shift+Mouse
|
|
18
|
-
*/ function modifySelection({ focusNode
|
|
19
|
-
var
|
|
18
|
+
*/ function modifySelection({ focusNode, focusOffset }) {
|
|
19
|
+
var _focusNode_ownerDocument_getSelection, _focusNode_ownerDocument;
|
|
20
20
|
const typeAndSelection = getTargetTypeAndSelection.getTargetTypeAndSelection(focusNode);
|
|
21
21
|
if (typeAndSelection.type === 'input') {
|
|
22
22
|
return UI.setUISelection(focusNode, {
|
|
@@ -24,7 +24,7 @@ var getTargetTypeAndSelection = require('./getTargetTypeAndSelection.js');
|
|
|
24
24
|
focusOffset
|
|
25
25
|
}, 'modify');
|
|
26
26
|
}
|
|
27
|
-
(
|
|
27
|
+
(_focusNode_ownerDocument = focusNode.ownerDocument) === null || _focusNode_ownerDocument === void 0 ? void 0 : (_focusNode_ownerDocument_getSelection = _focusNode_ownerDocument.getSelection()) === null || _focusNode_ownerDocument_getSelection === void 0 ? void 0 : _focusNode_ownerDocument_getSelection.extend(focusNode, focusOffset);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
exports.modifySelection = modifySelection;
|
|
@@ -13,7 +13,7 @@ require('../../utils/misc/level.js');
|
|
|
13
13
|
require('../../options.js');
|
|
14
14
|
var resolveCaretPosition = require('./resolveCaretPosition.js');
|
|
15
15
|
|
|
16
|
-
function modifySelectionPerMouseMove(selectionRange, { document
|
|
16
|
+
function modifySelectionPerMouseMove(selectionRange, { document, target, node, offset }) {
|
|
17
17
|
const selectionFocus = resolveCaretPosition.resolveCaretPosition({
|
|
18
18
|
target,
|
|
19
19
|
node,
|
|
@@ -33,6 +33,7 @@ function modifySelectionPerMouseMove(selectionRange, { document , target , node
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
} else {
|
|
36
|
+
var _selection, _selection1;
|
|
36
37
|
const range = selectionRange.cloneRange();
|
|
37
38
|
const cmp = range.comparePoint(selectionFocus.node, selectionFocus.offset);
|
|
38
39
|
if (cmp < 0) {
|
|
@@ -41,8 +42,8 @@ function modifySelectionPerMouseMove(selectionRange, { document , target , node
|
|
|
41
42
|
range.setEnd(selectionFocus.node, selectionFocus.offset);
|
|
42
43
|
}
|
|
43
44
|
const selection = document.getSelection();
|
|
44
|
-
selection === null ||
|
|
45
|
-
selection === null ||
|
|
45
|
+
(_selection = selection) === null || _selection === void 0 ? void 0 : _selection.removeAllRanges();
|
|
46
|
+
(_selection1 = selection) === null || _selection1 === void 0 ? void 0 : _selection1.addRange(range.cloneRange());
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
|