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

Unified Diff: include.preload.js

Issue 5978149049335808: Issue 1290 - Added support for un-prefixedcreateShadowRoot (Closed)
Patch Set: Created Aug. 29, 2014, 8:24 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
@@ -114,34 +114,20 @@
function init(document)
{
- var canUseShadow = "webkitCreateShadowRoot" in document.documentElement;
- var fixInlineFrames = false;
-
+ // prior to Chrome 37, content scripts don't run on about:blank
+ // and about:srcdoc. So we have to apply element hiding and collapsing
+ // from the parent frame, when inline frames are loaded.
var match = navigator.userAgent.match(/\bChrome\/(\d+)/);
- if (match)
- {
- var chromeVersion = parseInt(match[1]);
-
- // the <shadow> element is ignored in Chrome 32 (#309). Also Chrome 31-33
- // crashes in some situations on some pages when using shadow DOM (#498).
- // So we must not use Shadow DOM on those versions of Chrome.
- if (chromeVersion >= 31 && chromeVersion <= 33)
- canUseShadow = false;
-
- // prior to Chrome 37, content scripts don't run on about:blank
- // and about:srcdoc. So we have to apply element hiding and collapsing
- // from the parent frame, when inline frames are loaded.
- if (chromeVersion < 37)
- fixInlineFrames = true;
- }
+ var fixInlineFrames = match && parseInt(match[1]) < 37);
// use Shadow DOM if available to don't mess with web pages that
// rely on the order of their own <style> tags (#309). However we
// must not create the shadow root in the response callback passed
// to sendMessage(), otherwise Chrome breaks some websites (#450).
+ var canUseShadow = "createShadowRoot" in document.documentElement;
if (canUseShadow)
{
- var shadow = document.documentElement.webkitCreateShadowRoot();
+ var shadow = document.documentElement.createShadowRoot();
Wladimir Palant 2014/08/29 20:49:51 I apparently missed that in the previous review -
Sebastian Noack 2014/08/29 22:19:29 Done.
shadow.appendChild(document.createElement("shadow"));
}
@@ -158,18 +144,8 @@
{
shadow.appendChild(style);
- try
- {
- document.querySelector("::content");
-
- for (var i = 0; i < selectors.length; i++)
- selectors[i] = "::content " + selectors[i];
- }
- catch (e)
- {
- for (var i = 0; i < selectors.length; i++)
- selectors[i] = "::-webkit-distributed(" + selectors[i] + ")";
- }
+ for (var i = 0; i < selectors.length; i++)
+ selectors[i] = "::content " + selectors[i];
}
else
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld