@testing-library/user-event 13.1.5 → 13.1.9
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/README.md +3 -0
- package/dist/keyboard/getNextKeyDef.js +3 -1
- package/dist/keyboard/keyboardImplementation.js +4 -2
- package/dist/keyboard/plugins/index.js +4 -2
- package/dist/keyboard/shared/fireInputEvent.js +13 -14
- package/dist/upload.d.ts +1 -1
- package/dist/upload.js +2 -3
- package/dist/utils/edit/selectionRange.js +5 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -772,6 +772,9 @@ Thanks goes to these people ([emoji key][emojis]):
|
|
|
772
772
|
<td align="center"><a href="https://github.com/InExtremaRes"><img src="https://avatars.githubusercontent.com/u/1635491?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Daniel Contreras</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3AInExtremaRes" title="Bug reports">🐛</a></td>
|
|
773
773
|
<td align="center"><a href="https://eugene.coding.blog"><img src="https://avatars.githubusercontent.com/u/13572283?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Eugene Ghanizadeh</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=loreanvictor" title="Code">💻</a></td>
|
|
774
774
|
<td align="center"><a href="https://github.com/vicrep"><img src="https://avatars.githubusercontent.com/u/11432241?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Victor Repkow</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=vicrep" title="Code">💻</a></td>
|
|
775
|
+
<td align="center"><a href="https://github.com/GreenGremlin"><img src="https://avatars.githubusercontent.com/u/647452?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jonathan Felchlin</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=GreenGremlin" title="Code">💻</a></td>
|
|
776
|
+
<td align="center"><a href="https://github.com/sydneyjodon-wk"><img src="https://avatars.githubusercontent.com/u/51122966?v=4?s=100" width="100px;" alt=""/><br /><sub><b>sydneyjodon-wk</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Asydneyjodon-wk" title="Bug reports">🐛</a></td>
|
|
777
|
+
<td align="center"><a href="https://github.com/codepath2019"><img src="https://avatars.githubusercontent.com/u/49729798?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Charles Magic Woo</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Acodepath2019" title="Bug reports">🐛</a></td>
|
|
775
778
|
</tr>
|
|
776
779
|
</table>
|
|
777
780
|
|
|
@@ -107,5 +107,7 @@ function isPrintableCharacter(startBracket, descriptor) {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
function getErrorMessage(expected, found, text) {
|
|
110
|
-
return `Expected ${expected} but found "${found != null ? found : ''}" in "${text}"
|
|
110
|
+
return `Expected ${expected} but found "${found != null ? found : ''}" in "${text}"
|
|
111
|
+
See https://github.com/testing-library/user-event/blob/master/README.md#keyboardtext-options
|
|
112
|
+
for more information about how userEvent parses your input.`;
|
|
111
113
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -18,6 +16,10 @@ var plugins = _interopRequireWildcard(require("./plugins"));
|
|
|
18
16
|
|
|
19
17
|
var _getEventProps = require("./getEventProps");
|
|
20
18
|
|
|
19
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
20
|
+
|
|
21
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
+
|
|
21
23
|
async function keyboardImplementation(text, options, state) {
|
|
22
24
|
const {
|
|
23
25
|
document
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
@@ -17,6 +15,10 @@ var characterKeys = _interopRequireWildcard(require("./character"));
|
|
|
17
15
|
|
|
18
16
|
var functionalKeys = _interopRequireWildcard(require("./functional"));
|
|
19
17
|
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
20
22
|
const replaceBehavior = [{
|
|
21
23
|
matches: (keyDef, element) => keyDef.key === 'selectall' && (0, _utils.isElementType)(element, ['input', 'textarea']),
|
|
22
24
|
handle: (keyDef, element, options, state) => {
|
|
@@ -31,30 +31,29 @@ function fireInputEvent(element, {
|
|
|
31
31
|
_dom.fireEvent.input(element, { ...eventOverrides
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
setSelectionRangeAfterInputHandler(element, newValue);
|
|
34
|
+
setSelectionRangeAfterInputHandler(element, newValue, newSelectionStart);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function setSelectionRangeAfterInput(element, newSelectionStart) {
|
|
38
38
|
(0, _utils.setSelectionRange)(element, newSelectionStart, newSelectionStart);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
function setSelectionRangeAfterInputHandler(element, newValue) {
|
|
42
|
-
// if we *can* change the selection start, then we will if the new value
|
|
43
|
-
// is the same as the current value (so it wasn't programatically changed
|
|
44
|
-
// when the fireEvent.input was triggered).
|
|
45
|
-
// The reason we have to do this at all is because it actually *is*
|
|
46
|
-
// programmatically changed by fireEvent.input, so we have to simulate the
|
|
47
|
-
// browser's default behavior
|
|
41
|
+
function setSelectionRangeAfterInputHandler(element, newValue, newSelectionStart) {
|
|
48
42
|
const value = (0, _utils.getValue)(element); // don't apply this workaround on elements that don't necessarily report the visible value - e.g. number
|
|
49
43
|
// TODO: this could probably be only applied when there is keyboardState.carryValue
|
|
50
44
|
|
|
51
|
-
const
|
|
45
|
+
const isUnreliableValue = value === '' && (0, _utils.hasUnreliableEmptyValue)(element);
|
|
52
46
|
|
|
53
|
-
if (!
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
47
|
+
if (!isUnreliableValue && value === newValue) {
|
|
48
|
+
const {
|
|
49
|
+
selectionStart
|
|
50
|
+
} = (0, _utils.getSelectionRange)(element);
|
|
51
|
+
|
|
52
|
+
if (selectionStart === value.length) {
|
|
53
|
+
// The value was changed as expected, but the cursor was moved to the end
|
|
54
|
+
// TODO: this could probably be only applied when we work around a framework setter on the element in applyNative
|
|
55
|
+
(0, _utils.setSelectionRange)(element, newSelectionStart, newSelectionStart);
|
|
56
|
+
}
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
/**
|
package/dist/upload.d.ts
CHANGED
package/dist/upload.js
CHANGED
|
@@ -68,15 +68,14 @@ function upload(element, fileOrFiles, init, {
|
|
|
68
68
|
},
|
|
69
69
|
bubbles: true,
|
|
70
70
|
cancelable: false,
|
|
71
|
-
composed: true
|
|
72
|
-
...init
|
|
71
|
+
composed: true
|
|
73
72
|
}));
|
|
74
73
|
|
|
75
74
|
_dom.fireEvent.change(input, {
|
|
76
75
|
target: {
|
|
77
76
|
files: inputFiles
|
|
78
77
|
},
|
|
79
|
-
...init
|
|
78
|
+
...(init == null ? void 0 : init.changeInit)
|
|
80
79
|
});
|
|
81
80
|
}
|
|
82
81
|
|
|
@@ -80,6 +80,11 @@ function setSelectionRange(element, newSelectionStart, newSelectionEnd) {
|
|
|
80
80
|
selectionStart: newSelectionStart,
|
|
81
81
|
selectionEnd: newSelectionEnd
|
|
82
82
|
};
|
|
83
|
+
} // Moving the selection inside <input> or <textarea> does not alter the document Selection.
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
if ((0, _isElementType.isElementType)(element, 'input') || (0, _isElementType.isElementType)(element, 'textarea')) {
|
|
87
|
+
return;
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
const range = element.ownerDocument.createRange();
|