Index: include.preload.js |
=================================================================== |
--- a/include.preload.js |
+++ b/include.preload.js |
@@ -25,16 +25,24 @@ |
if (elemhideElt && elemhideElt.parentNode) |
elemhideElt.parentNode.removeChild(elemhideElt); |
Sebastian Noack
2014/04/15 09:58:06
Storing the inserted <style> tag into a global var
Wladimir Palant
2014/04/15 13:13:14
I somewhat remember that AdThwart had issues with
|
- if (!selectors) |
+ if (selectors.length == 0) |
Sebastian Noack
2014/04/15 09:58:06
Skip inserting a style tag, if there are no elemen
Wladimir Palant
2014/04/15 13:13:14
That doesn't make much difference in reality - if
Sebastian Noack
2014/04/15 19:21:54
I am aware that at least when using EASYList there
|
return; |
- elemhideElt = document.createElement("style"); |
- elemhideElt.setAttribute("type", "text/css"); |
- |
// Try to insert the style into the <head> tag, inserting directly under the |
// document root breaks dev tools functionality: |
// http://code.google.com/p/chromium/issues/detail?id=178109 |
- (document.head || document.documentElement).appendChild(elemhideElt); |
+ var container = document.head || document.documentElement; |
+ |
+ // Use Shadow DOM if available to don't mess with web pages |
+ // that rely on the order of their own <style> tags (#309) |
+ if ("createShadowRoot" in container) |
+ container = container.createShadowRoot(); |
Wladimir Palant
2014/04/15 13:13:14
Given that this standard is still very much in flu
Sebastian Noack
2014/04/15 19:21:54
Done.
|
+ else if ("webkitCreateShadowRoot" in container) |
+ container = container.webkitCreateShadowRoot(); |
Wladimir Palant
2014/04/15 13:13:14
Please add a <shadow> element to our shadow root t
Sebastian Noack
2014/04/15 19:21:54
Done.
|
+ |
+ elemhideElt = document.createElement("style"); |
+ elemhideElt.setAttribute("type", "text/css"); |
+ container.appendChild(elemhideElt); |
Wladimir Palant
2014/04/15 13:13:14
Will these styles affect the regular elements or o
Sebastian Noack
2014/04/15 19:21:54
You are right, it actually didn't worked with the
|
var elt = elemhideElt; // Use a local variable to avoid racing conditions |
function setRules() |