Remove redundant style nodes from clone

This commit is contained in:
Niklas von Hertzen 2017-08-18 22:22:24 +08:00
parent bd463d9343
commit 5dbb197a82
2 changed files with 5 additions and 1 deletions

View File

@ -93,9 +93,11 @@ export class DocumentCloner {
for (let child = node.firstChild; child; child = child.nextSibling) { for (let child = node.firstChild; child; child = child.nextSibling) {
if (child.nodeType !== Node.ELEMENT_NODE || child.nodeName !== 'SCRIPT') { if (child.nodeType !== Node.ELEMENT_NODE || child.nodeName !== 'SCRIPT') {
if (!this.copyStyles || child.nodeName !== 'STYLE') {
clone.appendChild(this.cloneNode(child)); clone.appendChild(this.cloneNode(child));
} }
} }
}
if (node instanceof HTMLElement && clone instanceof HTMLElement) { if (node instanceof HTMLElement && clone instanceof HTMLElement) {
this.inlineAllImages(inlinePseudoElement(node, clone, PSEUDO_BEFORE)); this.inlineAllImages(inlinePseudoElement(node, clone, PSEUDO_BEFORE));
this.inlineAllImages(inlinePseudoElement(node, clone, PSEUDO_AFTER)); this.inlineAllImages(inlinePseudoElement(node, clone, PSEUDO_AFTER));

View File

@ -44,6 +44,8 @@ export default class ForeignObjectRenderer {
resolve(this.canvas); resolve(this.canvas);
}; };
img.onerror = reject;
img.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent( img.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(
new XMLSerializer().serializeToString(svg) new XMLSerializer().serializeToString(svg)
)}`; )}`;