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

Unified Diff: include.preload.js

Issue 29349749: Issue 4191 - Check shadowRoot getter exists before wrapping (Closed)
Patch Set: Created Aug. 11, 2016, 3:32 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
diff --git a/include.preload.js b/include.preload.js
index 02661d39c86ace26fcddea8395726dddf7018df8..2b89e11b38bb3a8a297f19e32697e11b9282806b 100644
--- a/include.preload.js
+++ b/include.preload.js
@@ -457,20 +457,23 @@ function init(document)
shadow.appendChild(document.createElement("shadow"));
// Stop the website from messing with our shadowRoot
- runInDocument(document, function()
+ if ("shadowRoot" in Element.prototype)
{
- var ourShadowRoot = document.documentElement.shadowRoot;
- var desc = Object.getOwnPropertyDescriptor(Element.prototype, "shadowRoot");
- var shadowRoot = Function.prototype.call.bind(desc.get);
+ runInDocument(document, function()
+ {
+ var ourShadowRoot = document.documentElement.shadowRoot;
+ var desc = Object.getOwnPropertyDescriptor(Element.prototype, "shadowRoot");
+ var shadowRoot = Function.prototype.call.bind(desc.get);
- Object.defineProperty(Element.prototype, "shadowRoot", {
- conifgurable: true, enumerable: true, get: function()
- {
- var shadow = shadowRoot(this);
- return shadow == ourShadowRoot ? null : shadow;
- }
- });
- }, null);
+ Object.defineProperty(Element.prototype, "shadowRoot", {
+ conifgurable: true, enumerable: true, get: function()
+ {
+ var shadow = shadowRoot(this);
+ return shadow == ourShadowRoot ? null : shadow;
+ }
+ });
+ }, null);
+ }
}
function addElemHideSelectors(selectors)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld