Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: include.preload.js

Issue 29349823: Fixes 4328 - Multiple shadowRoot deprecated warnings (Closed)
Patch Set: Fixed indentation Created Nov. 17, 2016, 3:45 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include.preload.js
diff --git a/include.preload.js b/include.preload.js
index 7acdbb149870180bd26785a5fd8a7432da1db692..f3b22dcf1496e26d84a7007627c3a46ab3b669cb 100644
--- a/include.preload.js
+++ b/include.preload.js
@@ -459,10 +459,15 @@ function init(document)
//
// Also, using shadow DOM causes issues on some Google websites,
// including Google Docs, Gmail and Blogger (#1770, #2602, #2687).
+ //
+ // Finally since some users have both AdBlock and Adblock Plus installed we
+ // have to consider how the two extensions interact. For example we want to
+ // avoid creating the shadowRoot twice.
if ("createShadowRoot" in document.documentElement &&
!/\.(?:google|blogger)\.com$/.test(document.domain))
{
- shadow = document.documentElement.createShadowRoot();
+ shadow = document.documentElement.shadowRoot ||
+ document.documentElement.createShadowRoot();
shadow.appendChild(document.createElement("shadow"));
// Stop the website from messing with our shadowRoot
@@ -471,6 +476,8 @@ function init(document)
runInDocument(document, function()
{
var ourShadowRoot = document.documentElement.shadowRoot;
+ if (!ourShadowRoot)
+ return;
var desc = Object.getOwnPropertyDescriptor(Element.prototype, "shadowRoot");
var shadowRoot = Function.prototype.call.bind(desc.get);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld