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
25
src/Clone.js
25
src/Clone.js
@ -37,7 +37,12 @@ export class DocumentCloner {
|
|||||||
if (backgroundImage.method === 'url') {
|
if (backgroundImage.method === 'url') {
|
||||||
return this.imageLoader
|
return this.imageLoader
|
||||||
.inlineImage(backgroundImage.args[0])
|
.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(
|
return Promise.resolve(
|
||||||
`${backgroundImage.prefix}${backgroundImage.method}(${backgroundImage.args.join(
|
`${backgroundImage.prefix}${backgroundImage.method}(${backgroundImage.args.join(
|
||||||
@ -54,12 +59,18 @@ export class DocumentCloner {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (node instanceof HTMLImageElement) {
|
if (node instanceof HTMLImageElement) {
|
||||||
this.imageLoader.inlineImage(node.src).then(img => {
|
this.imageLoader
|
||||||
|
.inlineImage(node.src)
|
||||||
|
.then(img => {
|
||||||
if (img && node instanceof HTMLImageElement && node.parentNode) {
|
if (img && node instanceof HTMLImageElement && node.parentNode) {
|
||||||
node.parentNode.replaceChild(
|
const parentNode = node.parentNode;
|
||||||
copyCSSStyles(node.style, img.cloneNode(false)),
|
const clonedChild = copyCSSStyles(node.style, img.cloneNode(false));
|
||||||
node
|
parentNode.replaceChild(clonedChild, node);
|
||||||
);
|
}
|
||||||
|
})
|
||||||
|
.catch(e => {
|
||||||
|
if (__DEV__) {
|
||||||
|
this.logger.log(`Unable to load image`, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -73,9 +84,11 @@ export class DocumentCloner {
|
|||||||
img.src = node.toDataURL();
|
img.src = node.toDataURL();
|
||||||
return img;
|
return img;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
if (__DEV__) {
|
||||||
this.logger.log(`Unable to clone canvas contents, canvas is tainted`);
|
this.logger.log(`Unable to clone canvas contents, canvas is tainted`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return node.cloneNode(false);
|
return node.cloneNode(false);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user