mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Correctly apply image timeout for loading images
This commit is contained in:
parent
c093c95881
commit
bd463d9343
@ -78,10 +78,12 @@ export default class ImageLoader<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
xhr.ontimeout = () => reject(`Timed out fetching ${src}`);
|
|
||||||
xhr.responseType = 'blob';
|
xhr.responseType = 'blob';
|
||||||
if (this.options.imageTimeout) {
|
if (this.options.imageTimeout) {
|
||||||
xhr.timeout = this.options.imageTimeout;
|
const timeout = this.options.imageTimeout;
|
||||||
|
xhr.timeout = timeout;
|
||||||
|
xhr.ontimeout = () =>
|
||||||
|
reject(__DEV__ ? `Timed out (${timeout}ms) fetching ${src}` : '');
|
||||||
}
|
}
|
||||||
xhr.open('GET', src, true);
|
xhr.open('GET', src, true);
|
||||||
xhr.send();
|
xhr.send();
|
||||||
@ -122,6 +124,13 @@ export default class ImageLoader<T> {
|
|||||||
resolve(img);
|
resolve(img);
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
|
if (this.options.imageTimeout) {
|
||||||
|
const timeout = this.options.imageTimeout;
|
||||||
|
setTimeout(
|
||||||
|
() => reject(__DEV__ ? `Timed out (${timeout}ms) fetching ${src}` : ''),
|
||||||
|
timeout
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.cache[key] =
|
this.cache[key] =
|
||||||
|
@ -19,7 +19,7 @@ export type Options = {
|
|||||||
async: ?boolean,
|
async: ?boolean,
|
||||||
allowTaint: ?boolean,
|
allowTaint: ?boolean,
|
||||||
canvas: ?HTMLCanvasElement,
|
canvas: ?HTMLCanvasElement,
|
||||||
imageTimeout: ?number,
|
imageTimeout: number,
|
||||||
proxy: ?string,
|
proxy: ?string,
|
||||||
removeContainer: ?boolean,
|
removeContainer: ?boolean,
|
||||||
scale: number,
|
scale: number,
|
||||||
|
Loading…
Reference in New Issue
Block a user