@testing-library/user-event 14.6.10 → 14.6.11
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.
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var dispatchEvent = require('../event/dispatchEvent.js');
|
|
4
4
|
var isElementType = require('../utils/misc/isElementType.js');
|
|
5
5
|
require('../utils/dataTransfer/Clipboard.js');
|
|
6
|
+
var getActiveElement = require('../utils/focus/getActiveElement.js');
|
|
6
7
|
var UI = require('./UI.js');
|
|
7
8
|
require('@testing-library/dom');
|
|
8
9
|
var interceptor = require('./interceptor.js');
|
|
@@ -13,7 +14,9 @@ function prepareDocument(document) {
|
|
|
13
14
|
return;
|
|
14
15
|
}
|
|
15
16
|
document.addEventListener('focus', (e)=>{
|
|
16
|
-
|
|
17
|
+
var _e_composedPath_;
|
|
18
|
+
// Focus on elements in a shadow tree is retargeted to the shadow host.
|
|
19
|
+
const el = (_e_composedPath_ = e.composedPath()[0]) !== null && _e_composedPath_ !== void 0 ? _e_composedPath_ : e.target;
|
|
17
20
|
prepareElement(el);
|
|
18
21
|
}, {
|
|
19
22
|
capture: true,
|
|
@@ -21,12 +24,14 @@ function prepareDocument(document) {
|
|
|
21
24
|
});
|
|
22
25
|
// Our test environment defaults to `document.body` as `activeElement`.
|
|
23
26
|
// In other environments this might be `null` when preparing.
|
|
27
|
+
const activeElement = getActiveElement.getActiveElement(document);
|
|
24
28
|
// istanbul ignore else
|
|
25
|
-
if (
|
|
26
|
-
prepareElement(
|
|
29
|
+
if (activeElement) {
|
|
30
|
+
prepareElement(activeElement);
|
|
27
31
|
}
|
|
28
32
|
document.addEventListener('blur', (e)=>{
|
|
29
|
-
|
|
33
|
+
var _e_composedPath_;
|
|
34
|
+
const el = (_e_composedPath_ = e.composedPath()[0]) !== null && _e_composedPath_ !== void 0 ? _e_composedPath_ : e.target;
|
|
30
35
|
const initialValue = UI.getInitialValue(el);
|
|
31
36
|
if (initialValue !== undefined) {
|
|
32
37
|
if (el.value !== initialValue) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { dispatchDOMEvent } from '../event/dispatchEvent.js';
|
|
2
2
|
import { isElementType } from '../utils/misc/isElementType.js';
|
|
3
3
|
import '../utils/dataTransfer/Clipboard.js';
|
|
4
|
+
import { getActiveElement } from '../utils/focus/getActiveElement.js';
|
|
4
5
|
import { getInitialValue, clearInitialValue } from './UI.js';
|
|
5
6
|
import '@testing-library/dom';
|
|
6
7
|
import { prepareValueInterceptor, prepareSelectionInterceptor, prepareRangeTextInterceptor } from './interceptor.js';
|
|
@@ -11,7 +12,9 @@ function prepareDocument(document) {
|
|
|
11
12
|
return;
|
|
12
13
|
}
|
|
13
14
|
document.addEventListener('focus', (e)=>{
|
|
14
|
-
|
|
15
|
+
var _e_composedPath_;
|
|
16
|
+
// Focus on elements in a shadow tree is retargeted to the shadow host.
|
|
17
|
+
const el = (_e_composedPath_ = e.composedPath()[0]) !== null && _e_composedPath_ !== void 0 ? _e_composedPath_ : e.target;
|
|
15
18
|
prepareElement(el);
|
|
16
19
|
}, {
|
|
17
20
|
capture: true,
|
|
@@ -19,12 +22,14 @@ function prepareDocument(document) {
|
|
|
19
22
|
});
|
|
20
23
|
// Our test environment defaults to `document.body` as `activeElement`.
|
|
21
24
|
// In other environments this might be `null` when preparing.
|
|
25
|
+
const activeElement = getActiveElement(document);
|
|
22
26
|
// istanbul ignore else
|
|
23
|
-
if (
|
|
24
|
-
prepareElement(
|
|
27
|
+
if (activeElement) {
|
|
28
|
+
prepareElement(activeElement);
|
|
25
29
|
}
|
|
26
30
|
document.addEventListener('blur', (e)=>{
|
|
27
|
-
|
|
31
|
+
var _e_composedPath_;
|
|
32
|
+
const el = (_e_composedPath_ = e.composedPath()[0]) !== null && _e_composedPath_ !== void 0 ? _e_composedPath_ : e.target;
|
|
28
33
|
const initialValue = getInitialValue(el);
|
|
29
34
|
if (initialValue !== undefined) {
|
|
30
35
|
if (el.value !== initialValue) {
|