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,7 +93,9 @@ export class DocumentCloner {
for (let child = node.firstChild; child; child = child.nextSibling) {
if (child.nodeType !== Node.ELEMENT_NODE || child.nodeName !== 'SCRIPT') {
clone.appendChild(this.cloneNode(child));
if (!this.copyStyles || child.nodeName !== 'STYLE') {
clone.appendChild(this.cloneNode(child));
}
}
}
if (node instanceof HTMLElement && clone instanceof HTMLElement) {

View File

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