@testing-library/user-event 12.1.9 → 12.1.10

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 CHANGED
@@ -594,7 +594,7 @@ Thanks goes to these people ([emoji key][emojis]):
594
594
  <td align="center"><a href="https://github.com/lazytype"><img src="https://avatars1.githubusercontent.com/u/840985?v=4" width="100px;" alt=""/><br /><sub><b>lazytype</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=lazytype" title="Code">💻</a> <a href="https://github.com/testing-library/user-event/commits?author=lazytype" title="Tests">⚠️</a></td>
595
595
  </tr>
596
596
  <tr>
597
- <td align="center"><a href="https://www.linkedin.com/in/luis-takahashi/"><img src="https://avatars0.githubusercontent.com/u/19766035?v=4" width="100px;" alt=""/><br /><sub><b>Luís Takahashi</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=luistak" title="Code">💻</a></td>
597
+ <td align="center"><a href="https://www.linkedin.com/in/luis-takahashi/"><img src="https://avatars0.githubusercontent.com/u/19766035?v=4" width="100px;" alt=""/><br /><sub><b>Luís Takahashi</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=luistak" title="Code">💻</a> <a href="https://github.com/testing-library/user-event/commits?author=luistak" title="Tests">⚠️</a></td>
598
598
  </tr>
599
599
  </table>
600
600
 
@@ -11,6 +11,8 @@ var _click = require("./click");
11
11
 
12
12
  var _focus = require("./focus");
13
13
 
14
+ var _hover = require("./hover");
15
+
14
16
  function selectOptionsBase(newValue, select, values, init) {
15
17
  if (!newValue && !select.multiple) {
16
18
  throw (0, _dom.getConfig)().getElementError(`Unable to deselect an option in a non-multiple select. Use selectOptions to change the selection instead.`, select);
@@ -22,7 +24,7 @@ function selectOptionsBase(newValue, select, values, init) {
22
24
  if (allOptions.includes(val)) {
23
25
  return val;
24
26
  } else {
25
- const matchingOption = allOptions.find(o => o.value === val);
27
+ const matchingOption = allOptions.find(o => o.value === val || o.innerHTML === val);
26
28
 
27
29
  if (matchingOption) {
28
30
  return matchingOption;
@@ -70,15 +72,22 @@ function selectOptionsBase(newValue, select, values, init) {
70
72
  }
71
73
 
72
74
  function selectOption(option) {
73
- option.selected = newValue;
74
- (0, _dom.fireEvent)(select, (0, _dom.createEvent)('input', select, {
75
- bubbles: true,
76
- cancelable: false,
77
- composed: true,
78
- ...init
79
- }));
80
-
81
- _dom.fireEvent.change(select, init);
75
+ if (option.getAttribute('role') === 'option') {
76
+ option == null ? void 0 : option.setAttribute == null ? void 0 : option.setAttribute('aria-selected', newValue);
77
+ (0, _hover.hover)(option, init);
78
+ (0, _click.click)(option, init);
79
+ (0, _hover.unhover)(option, init);
80
+ } else {
81
+ option.selected = newValue;
82
+ (0, _dom.fireEvent)(select, (0, _dom.createEvent)('input', select, {
83
+ bubbles: true,
84
+ cancelable: false,
85
+ composed: true,
86
+ ...init
87
+ }));
88
+
89
+ _dom.fireEvent.change(select, init);
90
+ }
82
91
  }
83
92
  }
84
93
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/user-event",
3
- "version": "12.1.9",
3
+ "version": "12.1.10",
4
4
  "description": "Fire events the same way the user does",
5
5
  "main": "dist/index.js",
6
6
  "typings": "typings/index.d.ts",