From 18bcb318567e1854d59daa663115a387692f1070 Mon Sep 17 00:00:00 2001 From: MoyuScript Date: Sun, 1 Apr 2018 18:49:23 +1000 Subject: [PATCH] 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 --- src/Clone.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Clone.js b/src/Clone.js index 018e6dc..553e21b 100644 --- a/src/Clone.js +++ b/src/Clone.js @@ -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;