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

Unified Diff: include.preload.js

Issue 29714555: Issue 6441 - Avoid unnecessary shadow root (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created March 5, 2018, 9:47 a.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
===================================================================
--- a/include.preload.js
+++ b/include.preload.js
@@ -336,17 +336,17 @@
document.removeEventListener("DOMContentLoaded", this.trace);
this.observer.disconnect();
clearTimeout(this.timeout);
}
};
function ElemHide()
{
- this.shadow = this.createShadowTree();
+ this.shadow = null;
this.styles = new Map();
this.tracer = null;
this.inline = true;
this.inlineEmulated = true;
this.emulatedPatterns = null;
this.elemHideEmulation = new ElemHideEmulation(
this.addSelectors.bind(this),
@@ -390,16 +390,19 @@
style.sheet.deleteRule(0);
}
if (selectors.length == 0)
return;
if (!style)
{
+ if (!this.shadow)
+ this.shadow = this.createShadowTree();
+
// Create <style> element lazily, only if we add styles. Add it to
// the shadow DOM if possible. Otherwise fallback to the <head> or
// <html> element. If we have injected a style element before that
// has been removed (the sheet property is null), create a new one.
style = document.createElement("style");
(this.shadow || document.head ||
document.documentElement).appendChild(style);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld