mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Improve logging
This commit is contained in:
parent
906a66eec7
commit
1a53643457
33
src/Clone.js
33
src/Clone.js
@ -37,7 +37,12 @@ export class DocumentCloner {
|
||||
if (backgroundImage.method === 'url') {
|
||||
return this.imageLoader
|
||||
.inlineImage(backgroundImage.args[0])
|
||||
.then(img => (img ? `url("${img.src}")` : 'none'));
|
||||
.then(img => (img ? `url("${img.src}")` : 'none'))
|
||||
.catch(e => {
|
||||
if (__DEV__) {
|
||||
this.logger.log(`Unable to load image`, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
return Promise.resolve(
|
||||
`${backgroundImage.prefix}${backgroundImage.method}(${backgroundImage.args.join(
|
||||
@ -54,14 +59,20 @@ export class DocumentCloner {
|
||||
});
|
||||
|
||||
if (node instanceof HTMLImageElement) {
|
||||
this.imageLoader.inlineImage(node.src).then(img => {
|
||||
if (img && node instanceof HTMLImageElement && node.parentNode) {
|
||||
node.parentNode.replaceChild(
|
||||
copyCSSStyles(node.style, img.cloneNode(false)),
|
||||
node
|
||||
);
|
||||
}
|
||||
});
|
||||
this.imageLoader
|
||||
.inlineImage(node.src)
|
||||
.then(img => {
|
||||
if (img && node instanceof HTMLImageElement && node.parentNode) {
|
||||
const parentNode = node.parentNode;
|
||||
const clonedChild = copyCSSStyles(node.style, img.cloneNode(false));
|
||||
parentNode.replaceChild(clonedChild, node);
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
if (__DEV__) {
|
||||
this.logger.log(`Unable to load image`, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -73,7 +84,9 @@ export class DocumentCloner {
|
||||
img.src = node.toDataURL();
|
||||
return img;
|
||||
} catch (e) {
|
||||
this.logger.log(`Unable to clone canvas contents, canvas is tainted`);
|
||||
if (__DEV__) {
|
||||
this.logger.log(`Unable to clone canvas contents, canvas is tainted`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user