Correctly clone dynami CSSStyleSheets (Fix #1370)

This commit is contained in:
Niklas von Hertzen
2018-01-07 20:13:26 +08:00
parent 8788a9f458
commit 4c14894a0a
2 changed files with 46 additions and 0 deletions

View File

@ -229,6 +229,15 @@ export class DocumentCloner {
return tempIframe;
}
if (node instanceof HTMLStyleElement && node.sheet && node.sheet.cssRules) {
const css = [].slice
.call(node.sheet.cssRules, 0)
.reduce((css, rule) => css + rule.cssText, '');
const style = node.cloneNode(false);
style.textContent = css;
return style;
}
return node.cloneNode(false);
}