From 8624ed23741c0eb36b1b011c31e88900d99a9973 Mon Sep 17 00:00:00 2001 From: Tim Date: Sun, 27 Oct 2013 20:30:10 +0800 Subject: [PATCH] Explicitly read/write ShadowDOMPolyfill on window Breaks when executed inside non-top level window context. --- src/ShadowRenderer.js | 2 +- src/querySelector.js | 2 +- src/wrappers.js | 4 ++-- src/wrappers/CanvasRenderingContext2D.js | 2 +- src/wrappers/CharacterData.js | 2 +- src/wrappers/Document.js | 2 +- src/wrappers/Element.js | 2 +- src/wrappers/HTMLCanvasElement.js | 2 +- src/wrappers/HTMLContentElement.js | 2 +- src/wrappers/HTMLElement.js | 2 +- src/wrappers/HTMLImageElement.js | 2 +- src/wrappers/HTMLShadowElement.js | 2 +- src/wrappers/HTMLTemplateElement.js | 2 +- src/wrappers/HTMLUnknownElement.js | 2 +- src/wrappers/MutationObserver.js | 2 +- src/wrappers/Node.js | 2 +- src/wrappers/NodeList.js | 2 +- src/wrappers/Range.js | 2 +- src/wrappers/ShadowRoot.js | 2 +- src/wrappers/WebGLRenderingContext.js | 2 +- src/wrappers/Window.js | 2 +- src/wrappers/elements-with-form-property.js | 2 +- src/wrappers/events.js | 2 +- src/wrappers/generic.js | 2 +- src/wrappers/node-interfaces.js | 2 +- src/wrappers/override-constructors.js | 2 +- 26 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/ShadowRenderer.js b/src/ShadowRenderer.js index 575949a..2af830f 100644 --- a/src/ShadowRenderer.js +++ b/src/ShadowRenderer.js @@ -659,4 +659,4 @@ remove: remove, }; -})(this.ShadowDOMPolyfill); \ No newline at end of file +})(window.ShadowDOMPolyfill); diff --git a/src/querySelector.js b/src/querySelector.js index d8ae54a..f1da41e 100644 --- a/src/querySelector.js +++ b/src/querySelector.js @@ -70,4 +70,4 @@ scope.GetElementsByInterface = GetElementsByInterface; scope.SelectorsInterface = SelectorsInterface; -})(this.ShadowDOMPolyfill); +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers.js b/src/wrappers.js index 28f7536..c8a17b2 100644 --- a/src/wrappers.js +++ b/src/wrappers.js @@ -2,7 +2,7 @@ // Use of this source code is goverened by a BSD-style // license that can be found in the LICENSE file. -var ShadowDOMPolyfill = {}; +window.ShadowDOMPolyfill = {}; (function(scope) { 'use strict'; @@ -370,4 +370,4 @@ var ShadowDOMPolyfill = {}; scope.wrapIfNeeded = wrapIfNeeded; scope.wrappers = wrappers; -})(this.ShadowDOMPolyfill); \ No newline at end of file +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/CanvasRenderingContext2D.js b/src/wrappers/CanvasRenderingContext2D.js index 7aaf236..f8b7810 100644 --- a/src/wrappers/CanvasRenderingContext2D.js +++ b/src/wrappers/CanvasRenderingContext2D.js @@ -35,4 +35,4 @@ registerWrapper(OriginalCanvasRenderingContext2D, CanvasRenderingContext2D); scope.wrappers.CanvasRenderingContext2D = CanvasRenderingContext2D; -})(this.ShadowDOMPolyfill); +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/CharacterData.js b/src/wrappers/CharacterData.js index 0f94e77..146b9bd 100644 --- a/src/wrappers/CharacterData.js +++ b/src/wrappers/CharacterData.js @@ -31,4 +31,4 @@ document.createTextNode('')); scope.wrappers.CharacterData = CharacterData; -})(this.ShadowDOMPolyfill); +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/Document.js b/src/wrappers/Document.js index e132592..6d73a7d 100644 --- a/src/wrappers/Document.js +++ b/src/wrappers/Document.js @@ -281,4 +281,4 @@ scope.wrappers.DOMImplementation = DOMImplementation; scope.wrappers.Document = Document; -})(this.ShadowDOMPolyfill); +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/Element.js b/src/wrappers/Element.js index 00efc14..02e0ce0 100644 --- a/src/wrappers/Element.js +++ b/src/wrappers/Element.js @@ -114,4 +114,4 @@ // that reflect attributes. scope.matchesName = matchesName; scope.wrappers.Element = Element; -})(this.ShadowDOMPolyfill); +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/HTMLCanvasElement.js b/src/wrappers/HTMLCanvasElement.js index ca90a4b..63e3556 100644 --- a/src/wrappers/HTMLCanvasElement.js +++ b/src/wrappers/HTMLCanvasElement.js @@ -28,4 +28,4 @@ document.createElement('canvas')); scope.wrappers.HTMLCanvasElement = HTMLCanvasElement; -})(this.ShadowDOMPolyfill); +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/HTMLContentElement.js b/src/wrappers/HTMLContentElement.js index 898d424..c4ef3c5 100644 --- a/src/wrappers/HTMLContentElement.js +++ b/src/wrappers/HTMLContentElement.js @@ -38,4 +38,4 @@ registerWrapper(OriginalHTMLContentElement, HTMLContentElement); scope.wrappers.HTMLContentElement = HTMLContentElement; -})(this.ShadowDOMPolyfill); \ No newline at end of file +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/HTMLElement.js b/src/wrappers/HTMLElement.js index 4dff036..1bae2cc 100644 --- a/src/wrappers/HTMLElement.js +++ b/src/wrappers/HTMLElement.js @@ -197,4 +197,4 @@ // TODO: Find a better way to share these two with WrapperShadowRoot. scope.getInnerHTML = getInnerHTML; scope.setInnerHTML = setInnerHTML -})(this.ShadowDOMPolyfill); \ No newline at end of file +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/HTMLImageElement.js b/src/wrappers/HTMLImageElement.js index 8168413..0159f98 100644 --- a/src/wrappers/HTMLImageElement.js +++ b/src/wrappers/HTMLImageElement.js @@ -39,4 +39,4 @@ scope.wrappers.HTMLImageElement = HTMLImageElement; scope.wrappers.Image = Image; -})(this.ShadowDOMPolyfill); +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/HTMLShadowElement.js b/src/wrappers/HTMLShadowElement.js index 9f6b761..2116ed5 100644 --- a/src/wrappers/HTMLShadowElement.js +++ b/src/wrappers/HTMLShadowElement.js @@ -23,4 +23,4 @@ registerWrapper(OriginalHTMLShadowElement, HTMLShadowElement); scope.wrappers.HTMLShadowElement = HTMLShadowElement; -})(this.ShadowDOMPolyfill); +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/HTMLTemplateElement.js b/src/wrappers/HTMLTemplateElement.js index 52fef46..e218aa3 100644 --- a/src/wrappers/HTMLTemplateElement.js +++ b/src/wrappers/HTMLTemplateElement.js @@ -81,4 +81,4 @@ registerWrapper(OriginalHTMLTemplateElement, HTMLTemplateElement); scope.wrappers.HTMLTemplateElement = HTMLTemplateElement; -})(this.ShadowDOMPolyfill); \ No newline at end of file +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/HTMLUnknownElement.js b/src/wrappers/HTMLUnknownElement.js index fe76f98..79c16e8 100644 --- a/src/wrappers/HTMLUnknownElement.js +++ b/src/wrappers/HTMLUnknownElement.js @@ -28,4 +28,4 @@ HTMLUnknownElement.prototype = Object.create(HTMLElement.prototype); registerWrapper(OriginalHTMLUnknownElement, HTMLUnknownElement); scope.wrappers.HTMLUnknownElement = HTMLUnknownElement; -})(this.ShadowDOMPolyfill); \ No newline at end of file +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/MutationObserver.js b/src/wrappers/MutationObserver.js index cdd667d..ee10d95 100644 --- a/src/wrappers/MutationObserver.js +++ b/src/wrappers/MutationObserver.js @@ -84,4 +84,4 @@ scope.wrappers.MutationObserver = MutationObserver; scope.wrappers.MutationRecord = MutationRecord; -})(this.ShadowDOMPolyfill); +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/Node.js b/src/wrappers/Node.js index 1aa4819..cc40b34 100644 --- a/src/wrappers/Node.js +++ b/src/wrappers/Node.js @@ -494,4 +494,4 @@ scope.wrappers.Node = Node; -})(this.ShadowDOMPolyfill); +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/NodeList.js b/src/wrappers/NodeList.js index 16baf68..83cb21b 100644 --- a/src/wrappers/NodeList.js +++ b/src/wrappers/NodeList.js @@ -43,4 +43,4 @@ scope.addWrapNodeListMethod = addWrapNodeListMethod; scope.wrapNodeList = wrapNodeList; -})(this.ShadowDOMPolyfill); \ No newline at end of file +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/Range.js b/src/wrappers/Range.js index d084638..6de7971 100644 --- a/src/wrappers/Range.js +++ b/src/wrappers/Range.js @@ -89,4 +89,4 @@ scope.wrappers.Range = Range; -})(this.ShadowDOMPolyfill); +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/ShadowRoot.js b/src/wrappers/ShadowRoot.js index 75b7c78..9287c6a 100644 --- a/src/wrappers/ShadowRoot.js +++ b/src/wrappers/ShadowRoot.js @@ -60,4 +60,4 @@ scope.getHostForShadowRoot = function(node) { return shadowHostTable.get(node); }; -})(this.ShadowDOMPolyfill); \ No newline at end of file +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/WebGLRenderingContext.js b/src/wrappers/WebGLRenderingContext.js index 74de34f..f4949d0 100644 --- a/src/wrappers/WebGLRenderingContext.js +++ b/src/wrappers/WebGLRenderingContext.js @@ -39,4 +39,4 @@ registerWrapper(OriginalWebGLRenderingContext, WebGLRenderingContext); scope.wrappers.WebGLRenderingContext = WebGLRenderingContext; -})(this.ShadowDOMPolyfill); +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/Window.js b/src/wrappers/Window.js index 2c00323..588cb1d 100644 --- a/src/wrappers/Window.js +++ b/src/wrappers/Window.js @@ -46,4 +46,4 @@ scope.wrappers.Window = Window; -})(this.ShadowDOMPolyfill); +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/elements-with-form-property.js b/src/wrappers/elements-with-form-property.js index 1617ada..972312e 100644 --- a/src/wrappers/elements-with-form-property.js +++ b/src/wrappers/elements-with-form-property.js @@ -51,4 +51,4 @@ elementsWithFormProperty.forEach(createWrapperConstructor); -})(this.ShadowDOMPolyfill); +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/events.js b/src/wrappers/events.js index 7e64bb9..8957d1b 100644 --- a/src/wrappers/events.js +++ b/src/wrappers/events.js @@ -746,4 +746,4 @@ scope.wrappers.MutationEvent = MutationEvent; scope.wrappers.UIEvent = UIEvent; -})(this.ShadowDOMPolyfill); +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/generic.js b/src/wrappers/generic.js index 89d96e8..bb0b3c6 100644 --- a/src/wrappers/generic.js +++ b/src/wrappers/generic.js @@ -23,4 +23,4 @@ scope.wrappers.DocumentFragment = DocumentFragment; scope.wrappers.Text = Text; -})(this.ShadowDOMPolyfill); +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/node-interfaces.js b/src/wrappers/node-interfaces.js index e606dd1..d0b174f 100644 --- a/src/wrappers/node-interfaces.js +++ b/src/wrappers/node-interfaces.js @@ -66,4 +66,4 @@ scope.ChildNodeInterface = ChildNodeInterface; scope.ParentNodeInterface = ParentNodeInterface; -})(this.ShadowDOMPolyfill); +})(window.ShadowDOMPolyfill); diff --git a/src/wrappers/override-constructors.js b/src/wrappers/override-constructors.js index 2b0af6d..20dcbeb 100644 --- a/src/wrappers/override-constructors.js +++ b/src/wrappers/override-constructors.js @@ -100,4 +100,4 @@ // Export for testing. scope.knownElements = elements; -})(this.ShadowDOMPolyfill); \ No newline at end of file +})(window.ShadowDOMPolyfill);