|
|
@@ -117,11 +117,19 @@ this.docHelper = this.docHelper || (() => {
|
|
|
if (doc) {
|
|
|
const contents = [];
|
|
|
doc.querySelectorAll("style").forEach((styleElement, styleIndex) => {
|
|
|
+ let stylesheet;
|
|
|
try {
|
|
|
- contents[styleIndex] = Array.from(styleElement.sheet.cssRules).map(rule => rule.cssText).join("\n");
|
|
|
+ const tempStyleElement = doc.createElement("style");
|
|
|
+ tempStyleElement.textContent = styleElement.textContent;
|
|
|
+ doc.body.appendChild(tempStyleElement);
|
|
|
+ stylesheet = tempStyleElement.sheet;
|
|
|
+ tempStyleElement.remove();
|
|
|
} catch (error) {
|
|
|
/* ignored */
|
|
|
}
|
|
|
+ if (!stylesheet || stylesheet.cssRules.length != styleElement.sheet.cssRules.length) {
|
|
|
+ contents[styleIndex] = Array.from(styleElement.sheet.cssRules).map(rule => rule.cssText).join("\n");
|
|
|
+ }
|
|
|
});
|
|
|
return contents;
|
|
|
}
|