diff --git a/src/Clone.js b/src/Clone.js index 4def893..1de4eb7 100644 --- a/src/Clone.js +++ b/src/Clone.js @@ -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); } diff --git a/tests/reftests/dynamicstyle.html b/tests/reftests/dynamicstyle.html new file mode 100644 index 0000000..218a2ca --- /dev/null +++ b/tests/reftests/dynamicstyle.html @@ -0,0 +1,37 @@ + + + + Dynamic style + + + + + + +
Static styles
+
Dynamic styles
+ + +