mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Don't resolve images immediately if they appear complete
This commit is contained in:
parent
37a9249a4a
commit
f3d6d2fdf4
@ -48,6 +48,7 @@ const FEATURES = {
|
||||
Object.defineProperty(FEATURES, 'SUPPORT_RANGE_BOUNDS', {value});
|
||||
return value;
|
||||
},
|
||||
// $FlowFixMe - get/set properties not yet supported
|
||||
get SUPPORT_SVG_DRAWING() {
|
||||
'use strict';
|
||||
const value = testSVG(document);
|
||||
|
@ -37,11 +37,7 @@ export default class ImageLoader {
|
||||
return this.addImage(src, src);
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
this.options.allowTaint === true ||
|
||||
isInlineImage(src) ||
|
||||
this.isSameOrigin(src)
|
||||
) {
|
||||
if (this.options.allowTaint === true || isInlineImage(src) || this.isSameOrigin(src)) {
|
||||
return this.addImage(src, src);
|
||||
} else if (typeof this.options.proxy === 'string' && !this.isSameOrigin(src)) {
|
||||
// TODO proxy
|
||||
@ -66,10 +62,14 @@ export default class ImageLoader {
|
||||
this.cache[key] = new Promise((resolve, reject) => {
|
||||
const img = new Image();
|
||||
img.onload = () => resolve(img);
|
||||
|
||||
img.onerror = reject;
|
||||
img.src = src;
|
||||
if (img.complete === true) {
|
||||
resolve(img);
|
||||
// Inline XML images may fail to parse, throwing an Error later on
|
||||
setTimeout(() => {
|
||||
resolve(img);
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
return key;
|
||||
|
Loading…
Reference in New Issue
Block a user