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

Unified Diff: include.preload.js

Issue 5171381998190592: Issue 450 - Create shadow root immediatelly instead inside the reponse callback (Closed)
Patch Set: Addressed comment Created May 14, 2014, 2:59 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
===================================================================
--- a/include.preload.js
+++ b/include.preload.js
@@ -17,6 +17,19 @@
var SELECTOR_GROUP_SIZE = 20;
+// use Shadow DOM if available to don't mess with web pages that
+// rely on the order of their own <style> tags. However
+// the <shadow> element is broken in some Chrome 32 builds (#309)
+//
+// also we must not create the shadow root in the response callback passed
+// to sendMessage(), otherwise Chrome breaks some websites (#450)
+var shadow = null;
+if ("webkitCreateShadowRoot" in document.documentElement && !/\bChrome\/32\b/.test(navigator.userAgent))
+{
+ shadow = document.documentElement.webkitCreateShadowRoot();
+ shadow.appendChild(document.createElement("shadow"));
+}
+
// Sets the currently used CSS rules for elemhide filters
function setElemhideCSSRules(selectors)
{
@@ -26,13 +39,8 @@
var style = document.createElement("style");
style.setAttribute("type", "text/css");
- // Use Shadow DOM if available to don't mess with web pages that
- // rely on the order of their own <style> tags. However
- // the <shadow> element is broken in some Chrome 32 builts (#309)
- if ("webkitCreateShadowRoot" in document.documentElement && !/\bChrome\/32\b/.test(navigator.userAgent))
+ if (shadow)
{
- var shadow = document.documentElement.webkitCreateShadowRoot();
- shadow.appendChild(document.createElement("shadow"));
shadow.appendChild(style);
try
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld