Skip to content

Commit

Permalink
Merge pull request #37 from dwelle/fix_ff_abort
Browse files Browse the repository at this point in the history
fix legacy open throwing abortError
  • Loading branch information
tomayac authored Mar 5, 2021
2 parents 5d8a551 + 7517a4e commit 40b4acb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions src/legacy/directory-open.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@ export default async (options = {}) => {

const cancelDetector = () => {
window.removeEventListener('focus', cancelDetector);
if (input.files.length === 0) {
reject(new DOMException('The user aborted a request.', 'AbortError'));
}
requestAnimationFrame(() => {
requestAnimationFrame(() => {
if (input.files.length === 0) {
reject(
new DOMException('The user aborted a request.', 'AbortError')
);
}
});
});
};

input.addEventListener('click', () => {
Expand Down
12 changes: 9 additions & 3 deletions src/legacy/file-open.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ export default async (options = {}) => {

const cancelDetector = () => {
window.removeEventListener('focus', cancelDetector);
if (input.files.length === 0) {
reject(new DOMException('The user aborted a request.', 'AbortError'));
}
requestAnimationFrame(() => {
requestAnimationFrame(() => {
if (input.files.length === 0) {
reject(
new DOMException('The user aborted a request.', 'AbortError')
);
}
});
});
};

input.addEventListener('click', () => {
Expand Down

0 comments on commit 40b4acb

Please sign in to comment.