IE11 Member not found fix Wrap accesing the cssText property in a try...catch (#1415)

* https://github.com/niklasvh/html2canvas/issues/1374 - Wrap accesing the cssText property in a try...catch
This commit is contained in:
Simon 2018-04-01 18:49:23 +10:00 committed by Niklas von Hertzen
parent e6bbc1abb5
commit 0e273418c7

View File

@ -230,9 +230,17 @@ export class DocumentCloner {
}
if (node instanceof HTMLStyleElement && node.sheet && node.sheet.cssRules) {
const css = [].slice
.call(node.sheet.cssRules, 0)
.reduce((css, rule) => css + rule.cssText, '');
const css = [].slice.call(node.sheet.cssRules, 0).reduce((css, rule) => {
try {
if (rule && rule.cssText) {
return css + rule.cssText;
}
return css;
} catch (err) {
this.logger.log('Unable to access cssText property', rule.name);
return css;
}
}, '');
const style = node.cloneNode(false);
style.textContent = css;
return style;