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

Side by Side 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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 addElemHideSelectors); 452 addElemHideSelectors);
453 453
454 // Use Shadow DOM if available to don't mess with web pages that rely on 454 // Use Shadow DOM if available to don't mess with web pages that rely on
455 // the order of their own <style> tags (#309). 455 // the order of their own <style> tags (#309).
456 // 456 //
457 // However, creating a shadow root breaks running CSS transitions. So we 457 // However, creating a shadow root breaks running CSS transitions. So we
458 // have to create the shadow root before transistions might start (#452). 458 // have to create the shadow root before transistions might start (#452).
459 // 459 //
460 // Also, using shadow DOM causes issues on some Google websites, 460 // Also, using shadow DOM causes issues on some Google websites,
461 // including Google Docs, Gmail and Blogger (#1770, #2602, #2687). 461 // including Google Docs, Gmail and Blogger (#1770, #2602, #2687).
462 //
463 // Finally since some users have both AdBlock and Adblock Plus installed we
464 // have to consider how the two extensions interact. For example we want to
465 // avoid creating the shadowRoot twice.
462 if ("createShadowRoot" in document.documentElement && 466 if ("createShadowRoot" in document.documentElement &&
463 !/\.(?:google|blogger)\.com$/.test(document.domain)) 467 !/\.(?:google|blogger)\.com$/.test(document.domain))
464 { 468 {
465 shadow = document.documentElement.createShadowRoot(); 469 shadow = document.documentElement.shadowRoot ||
470 document.documentElement.createShadowRoot();
466 shadow.appendChild(document.createElement("shadow")); 471 shadow.appendChild(document.createElement("shadow"));
467 472
468 // Stop the website from messing with our shadowRoot 473 // Stop the website from messing with our shadowRoot
469 if ("shadowRoot" in Element.prototype) 474 if ("shadowRoot" in Element.prototype)
470 { 475 {
471 runInDocument(document, function() 476 runInDocument(document, function()
472 { 477 {
473 var ourShadowRoot = document.documentElement.shadowRoot; 478 var ourShadowRoot = document.documentElement.shadowRoot;
479 if (!ourShadowRoot)
480 return;
474 var desc = Object.getOwnPropertyDescriptor(Element.prototype, "shadowRoo t"); 481 var desc = Object.getOwnPropertyDescriptor(Element.prototype, "shadowRoo t");
475 var shadowRoot = Function.prototype.call.bind(desc.get); 482 var shadowRoot = Function.prototype.call.bind(desc.get);
476 483
477 Object.defineProperty(Element.prototype, "shadowRoot", { 484 Object.defineProperty(Element.prototype, "shadowRoot", {
478 configurable: true, enumerable: true, get: function() 485 configurable: true, enumerable: true, get: function()
479 { 486 {
480 var shadow = shadowRoot(this); 487 var shadow = shadowRoot(this);
481 return shadow == ourShadowRoot ? null : shadow; 488 return shadow == ourShadowRoot ? null : shadow;
482 } 489 }
483 }); 490 });
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 }, true); 618 }, true);
612 619
613 return updateStylesheet; 620 return updateStylesheet;
614 } 621 }
615 622
616 if (document instanceof HTMLDocument) 623 if (document instanceof HTMLDocument)
617 { 624 {
618 checkSitekey(); 625 checkSitekey();
619 window.updateStylesheet = init(document); 626 window.updateStylesheet = init(document);
620 } 627 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld