@testing-library/user-event 12.7.2 → 12.7.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 +1 -0
- package/dist/upload.js +2 -25
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -684,6 +684,7 @@ Thanks goes to these people ([emoji key][emojis]):
|
|
|
684
684
|
<td align="center"><a href="https://www.daleseo.com"><img src="https://avatars1.githubusercontent.com/u/5466341?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dale Seo</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=daleseo" title="Documentation">📖</a></td>
|
|
685
685
|
<td align="center"><a href="http://www.alex-boyce.me/"><img src="https://avatars.githubusercontent.com/u/4050934?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alex Boyce</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=curiosity26" title="Code">💻</a></td>
|
|
686
686
|
<td align="center"><a href="https://benadamstyles.com"><img src="https://avatars.githubusercontent.com/u/4380655?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ben Styles</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=benadamstyles" title="Code">💻</a> <a href="https://github.com/testing-library/user-event/commits?author=benadamstyles" title="Tests">⚠️</a></td>
|
|
687
|
+
<td align="center"><a href="http://laurabeatris.com"><img src="https://avatars.githubusercontent.com/u/48022589?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Laura Beatris</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=LauraBeatris" title="Code">💻</a> <a href="https://github.com/testing-library/user-event/commits?author=LauraBeatris" title="Tests">⚠️</a></td>
|
|
687
688
|
</tr>
|
|
688
689
|
</table>
|
|
689
690
|
|
package/dist/upload.js
CHANGED
|
@@ -17,19 +17,14 @@ function upload(element, fileOrFiles, init) {
|
|
|
17
17
|
if (element.disabled) return;
|
|
18
18
|
(0, _click.click)(element, init);
|
|
19
19
|
const input = element.tagName === 'LABEL' ? element.control : element;
|
|
20
|
-
const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [fileOrFiles]).
|
|
20
|
+
const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [fileOrFiles]).slice(0, input.multiple ? undefined : 1); // blur fires when the file selector pops up
|
|
21
21
|
|
|
22
22
|
(0, _blur.blur)(element, init); // focus fires when they make their selection
|
|
23
23
|
|
|
24
|
-
(0, _focus.focus)(element, init); //
|
|
25
|
-
|
|
26
|
-
if (files.length === 0) {
|
|
27
|
-
return;
|
|
28
|
-
} // the event fired in the browser isn't actually an "input" or "change" event
|
|
24
|
+
(0, _focus.focus)(element, init); // the event fired in the browser isn't actually an "input" or "change" event
|
|
29
25
|
// but a new Event with a type set to "input" and "change"
|
|
30
26
|
// Kinda odd...
|
|
31
27
|
|
|
32
|
-
|
|
33
28
|
const inputFiles = {
|
|
34
29
|
length: files.length,
|
|
35
30
|
item: index => files[index],
|
|
@@ -51,22 +46,4 @@ function upload(element, fileOrFiles, init) {
|
|
|
51
46
|
},
|
|
52
47
|
...init
|
|
53
48
|
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function isAcceptableFile(file, accept) {
|
|
57
|
-
if (!accept) {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const wildcards = ['audio/*', 'image/*', 'video/*'];
|
|
62
|
-
return accept.split(',').some(acceptToken => {
|
|
63
|
-
if (acceptToken[0] === '.') {
|
|
64
|
-
// tokens starting with a dot represent a file extension
|
|
65
|
-
return file.name.endsWith(acceptToken);
|
|
66
|
-
} else if (wildcards.includes(acceptToken)) {
|
|
67
|
-
return file.type.startsWith(acceptToken.substr(0, acceptToken.length - 1));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return file.type === acceptToken;
|
|
71
|
-
});
|
|
72
49
|
}
|