From 001b9ad7ccf52746f8bf76609a28f720ee8ede16 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 23 Jan 2016 18:59:37 +0000 Subject: [PATCH] try to trap SecurityError exceptions for linux FFs who don't like you calling .contentDocument on an SVG (assuming that's where the error comes from) --- src/Tinter.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Tinter.js b/src/Tinter.js index 1e1d534bd5..7773be4502 100644 --- a/src/Tinter.js +++ b/src/Tinter.js @@ -182,7 +182,20 @@ module.exports = { var fixups = []; for (var i = 0; i < svgs.length; i++) { - var svgDoc = svgs[i].contentDocument; + var svgDoc; + try { + svgDoc = svgs[i].contentDocument; + } + catch(e) { + var msg = 'Failed to get svg.contentDocument of ' + svgs[i].toString(); + if (e.message) { + msg += e.message; + } + if (e.stack) { + msg += ' | stack: ' + e.stack; + } + console.error(e); + } if (!svgDoc) continue; var tags = svgDoc.getElementsByTagName("*"); for (var j = 0; j < tags.length; j++) {