@testing-library/user-event 12.1.2 → 12.1.3

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
@@ -23,7 +23,7 @@
23
23
  [![MIT License][license-badge]][license]
24
24
 
25
25
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
26
- [![All Contributors](https://img.shields.io/badge/all_contributors-57-orange.svg?style=flat-square)](#contributors-)
26
+ [![All Contributors](https://img.shields.io/badge/all_contributors-58-orange.svg?style=flat-square)](#contributors-)
27
27
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
28
28
  [![PRs Welcome][prs-badge]][prs]
29
29
  [![Code of Conduct][coc-badge]][coc]
@@ -586,6 +586,7 @@ Thanks goes to these people ([emoji key][emojis]):
586
586
  </tr>
587
587
  <tr>
588
588
  <td align="center"><a href="https://github.com/ph-fritsche"><img src="https://avatars3.githubusercontent.com/u/39068198?v=4" width="100px;" alt=""/><br /><sub><b>ph-fritsche</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=ph-fritsche" title="Code">💻</a> <a href="https://github.com/testing-library/user-event/commits?author=ph-fritsche" title="Tests">⚠️</a></td>
589
+ <td align="center"><a href="https://github.com/reywright"><img src="https://avatars3.githubusercontent.com/u/708820?v=4" width="100px;" alt=""/><br /><sub><b>Rey Wright</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Areywright" title="Bug reports">🐛</a> <a href="https://github.com/testing-library/user-event/commits?author=reywright" title="Code">💻</a></td>
589
590
  </tr>
590
591
  </table>
591
592
 
package/dist/utils.js CHANGED
@@ -118,7 +118,7 @@ function supportsMaxLength(element) {
118
118
 
119
119
  function getSelectionRange(element) {
120
120
  if (isContentEditable(element)) {
121
- const range = document.getSelection().getRangeAt(0);
121
+ const range = element.ownerDocument.getSelection().getRangeAt(0);
122
122
  return {
123
123
  selectionStart: range.startOffset,
124
124
  selectionEnd: range.endOffset
@@ -211,12 +211,12 @@ function setSelectionRangeIfNecessary(element, newSelectionStart, newSelectionEn
211
211
 
212
212
  if (selectionStart !== newSelectionStart || selectionEnd !== newSelectionStart) {
213
213
  if (isContentEditable(element)) {
214
- const range = document.createRange();
214
+ const range = element.ownerDocument.createRange();
215
215
  range.selectNodeContents(element);
216
216
  range.setStart(element.firstChild, newSelectionStart);
217
217
  range.setEnd(element.firstChild, newSelectionEnd);
218
- document.getSelection().removeAllRanges();
219
- document.getSelection().addRange(range);
218
+ element.ownerDocument.getSelection().removeAllRanges();
219
+ element.ownerDocument.getSelection().addRange(range);
220
220
  } else {
221
221
  element.setSelectionRange(newSelectionStart, newSelectionEnd);
222
222
  }
@@ -233,7 +233,7 @@ function isFocusable(element) {
233
233
  const CLICKABLE_INPUT_TYPES = ['button', 'color', 'file', 'image', 'reset', 'submit'];
234
234
 
235
235
  function isClickable(element) {
236
- return element.tagName === 'BUTTON' || element instanceof HTMLInputElement && CLICKABLE_INPUT_TYPES.includes(element.type);
236
+ return element.tagName === 'BUTTON' || element instanceof element.ownerDocument.defaultView.HTMLInputElement && CLICKABLE_INPUT_TYPES.includes(element.type);
237
237
  }
238
238
 
239
239
  function eventWrapper(cb) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/user-event",
3
- "version": "12.1.2",
3
+ "version": "12.1.3",
4
4
  "description": "Fire events the same way the user does",
5
5
  "main": "dist/index.js",
6
6
  "typings": "typings/index.d.ts",