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});
|
Object.defineProperty(FEATURES, 'SUPPORT_RANGE_BOUNDS', {value});
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
|
// $FlowFixMe - get/set properties not yet supported
|
||||||
get SUPPORT_SVG_DRAWING() {
|
get SUPPORT_SVG_DRAWING() {
|
||||||
'use strict';
|
'use strict';
|
||||||
const value = testSVG(document);
|
const value = testSVG(document);
|
||||||
|
@ -37,11 +37,7 @@ export default class ImageLoader {
|
|||||||
return this.addImage(src, src);
|
return this.addImage(src, src);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (
|
if (this.options.allowTaint === true || isInlineImage(src) || this.isSameOrigin(src)) {
|
||||||
this.options.allowTaint === true ||
|
|
||||||
isInlineImage(src) ||
|
|
||||||
this.isSameOrigin(src)
|
|
||||||
) {
|
|
||||||
return this.addImage(src, src);
|
return this.addImage(src, src);
|
||||||
} else if (typeof this.options.proxy === 'string' && !this.isSameOrigin(src)) {
|
} else if (typeof this.options.proxy === 'string' && !this.isSameOrigin(src)) {
|
||||||
// TODO proxy
|
// TODO proxy
|
||||||
@ -66,10 +62,14 @@ export default class ImageLoader {
|
|||||||
this.cache[key] = new Promise((resolve, reject) => {
|
this.cache[key] = new Promise((resolve, reject) => {
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
img.onload = () => resolve(img);
|
img.onload = () => resolve(img);
|
||||||
|
|
||||||
img.onerror = reject;
|
img.onerror = reject;
|
||||||
img.src = src;
|
img.src = src;
|
||||||
if (img.complete === true) {
|
if (img.complete === true) {
|
||||||
resolve(img);
|
// Inline XML images may fail to parse, throwing an Error later on
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve(img);
|
||||||
|
}, 500);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return key;
|
return key;
|
||||||
|
Loading…
Reference in New Issue
Block a user