From b0072eab57d44fad5b6ccb2bca230a0b2d97564c Mon Sep 17 00:00:00 2001 From: Sean Rand Date: Mon, 3 Aug 2015 01:15:50 +0200 Subject: [PATCH] try/catch createShadowRoot in contentscripts --- src/js/contentscript-end.js | 7 ++++++- src/js/contentscript-start.js | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/js/contentscript-end.js b/src/js/contentscript-end.js index 5a3f99dcd..88726b406 100644 --- a/src/js/contentscript-end.js +++ b/src/js/contentscript-end.js @@ -470,7 +470,12 @@ var uBlockCollapser = (function() { if ( shadow !== null && shadow.className === sessionId ) { continue; } - shadow = elem.createShadowRoot(); + // not all nodes can be shadowed + try { + shadow = elem.createShadowRoot(); + } catch (ex) { + continue; + } shadow.className = sessionId; } }; diff --git a/src/js/contentscript-start.js b/src/js/contentscript-start.js index 892eea8cc..279d234c2 100644 --- a/src/js/contentscript-start.js +++ b/src/js/contentscript-start.js @@ -181,7 +181,12 @@ var hideElements = function(selectors) { if ( shadow !== null && shadow.className === sessionId ) { continue; } - shadow = elem.createShadowRoot(); + // not all nodes can be shadowed + try { + shadow = elem.createShadowRoot(); + } catch (ex) { + continue; + } shadow.className = sessionId; } };