OLD | NEW |
1 /** | 1 /** |
2 * @license | 2 * @license |
3 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | 3 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. |
4 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt | 4 * This code may only be used under the BSD style license found at http://polyme
r.github.io/LICENSE.txt |
5 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt | 5 * The complete set of authors may be found at http://polymer.github.io/AUTHORS.
txt |
6 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt | 6 * The complete set of contributors may be found at http://polymer.github.io/CON
TRIBUTORS.txt |
7 * Code distributed by Google as part of the polymer project is also | 7 * Code distributed by Google as part of the polymer project is also |
8 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt | 8 * subject to an additional IP rights grant found at http://polymer.github.io/PA
TENTS.txt |
9 */ | 9 */ |
10 // @version 0.7.22 | 10 // @version 0.6.1 |
11 if (typeof WeakMap === "undefined") { | 11 if (typeof WeakMap === "undefined") { |
12 (function() { | 12 (function() { |
13 var defineProperty = Object.defineProperty; | 13 var defineProperty = Object.defineProperty; |
14 var counter = Date.now() % 1e9; | 14 var counter = Date.now() % 1e9; |
15 var WeakMap = function() { | 15 var WeakMap = function() { |
16 this.name = "__st" + (Math.random() * 1e9 >>> 0) + (counter++ + "__"); | 16 this.name = "__st" + (Math.random() * 1e9 >>> 0) + (counter++ + "__"); |
17 }; | 17 }; |
18 WeakMap.prototype = { | 18 WeakMap.prototype = { |
19 set: function(key, value) { | 19 set: function(key, value) { |
20 var entry = key[this.name]; | 20 var entry = key[this.name]; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 value: undefined, | 106 value: undefined, |
107 configurable: true, | 107 configurable: true, |
108 enumerable: false, | 108 enumerable: false, |
109 writable: true | 109 writable: true |
110 }; | 110 }; |
111 function defineNonEnumerableDataProperty(object, name, value) { | 111 function defineNonEnumerableDataProperty(object, name, value) { |
112 nonEnumerableDataDescriptor.value = value; | 112 nonEnumerableDataDescriptor.value = value; |
113 defineProperty(object, name, nonEnumerableDataDescriptor); | 113 defineProperty(object, name, nonEnumerableDataDescriptor); |
114 } | 114 } |
115 getOwnPropertyNames(window); | 115 getOwnPropertyNames(window); |
116 function getWrapperConstructor(node, opt_instance) { | 116 function getWrapperConstructor(node) { |
117 var nativePrototype = node.__proto__ || Object.getPrototypeOf(node); | 117 var nativePrototype = node.__proto__ || Object.getPrototypeOf(node); |
118 if (isFirefox) { | 118 if (isFirefox) { |
119 try { | 119 try { |
120 getOwnPropertyNames(nativePrototype); | 120 getOwnPropertyNames(nativePrototype); |
121 } catch (error) { | 121 } catch (error) { |
122 nativePrototype = nativePrototype.__proto__; | 122 nativePrototype = nativePrototype.__proto__; |
123 } | 123 } |
124 } | 124 } |
125 var wrapperConstructor = constructorTable.get(nativePrototype); | 125 var wrapperConstructor = constructorTable.get(nativePrototype); |
126 if (wrapperConstructor) return wrapperConstructor; | 126 if (wrapperConstructor) return wrapperConstructor; |
127 var parentWrapperConstructor = getWrapperConstructor(nativePrototype); | 127 var parentWrapperConstructor = getWrapperConstructor(nativePrototype); |
128 var GeneratedWrapper = createWrapperConstructor(parentWrapperConstructor); | 128 var GeneratedWrapper = createWrapperConstructor(parentWrapperConstructor); |
129 registerInternal(nativePrototype, GeneratedWrapper, opt_instance); | 129 registerInternal(nativePrototype, GeneratedWrapper, node); |
130 return GeneratedWrapper; | 130 return GeneratedWrapper; |
131 } | 131 } |
132 function addForwardingProperties(nativePrototype, wrapperPrototype) { | 132 function addForwardingProperties(nativePrototype, wrapperPrototype) { |
133 installProperty(nativePrototype, wrapperPrototype, true); | 133 installProperty(nativePrototype, wrapperPrototype, true); |
134 } | 134 } |
135 function registerInstanceProperties(wrapperPrototype, instanceObject) { | 135 function registerInstanceProperties(wrapperPrototype, instanceObject) { |
136 installProperty(instanceObject, wrapperPrototype, false); | 136 installProperty(instanceObject, wrapperPrototype, false); |
137 } | 137 } |
138 var isFirefox = /Firefox/.test(navigator.userAgent); | 138 var isFirefox = /Firefox/.test(navigator.userAgent); |
139 var dummyDescriptor = { | 139 var dummyDescriptor = { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 for (var i = 0; i < names.length; i++) { | 179 for (var i = 0; i < names.length; i++) { |
180 var name = names[i]; | 180 var name = names[i]; |
181 if (name === "polymerBlackList_") continue; | 181 if (name === "polymerBlackList_") continue; |
182 if (name in target) continue; | 182 if (name in target) continue; |
183 if (source.polymerBlackList_ && source.polymerBlackList_[name]) continue; | 183 if (source.polymerBlackList_ && source.polymerBlackList_[name]) continue; |
184 if (isFirefox) { | 184 if (isFirefox) { |
185 source.__lookupGetter__(name); | 185 source.__lookupGetter__(name); |
186 } | 186 } |
187 var descriptor = getDescriptor(source, name); | 187 var descriptor = getDescriptor(source, name); |
188 var getter, setter; | 188 var getter, setter; |
189 if (typeof descriptor.value === "function") { | 189 if (allowMethod && typeof descriptor.value === "function") { |
190 if (allowMethod) { | 190 target[name] = getMethod(name); |
191 target[name] = getMethod(name); | |
192 } | |
193 continue; | 191 continue; |
194 } | 192 } |
195 var isEvent = isEventHandlerName(name); | 193 var isEvent = isEventHandlerName(name); |
196 if (isEvent) getter = scope.getEventHandlerGetter(name); else getter = get
Getter(name); | 194 if (isEvent) getter = scope.getEventHandlerGetter(name); else getter = get
Getter(name); |
197 if (descriptor.writable || descriptor.set || isBrokenSafari) { | 195 if (descriptor.writable || descriptor.set || isBrokenSafari) { |
198 if (isEvent) setter = scope.getEventHandlerSetter(name); else setter = g
etSetter(name); | 196 if (isEvent) setter = scope.getEventHandlerSetter(name); else setter = g
etSetter(name); |
199 } | 197 } |
200 var configurable = isBrokenSafari || descriptor.configurable; | 198 var configurable = isBrokenSafari || descriptor.configurable; |
201 defineProperty(target, name, { | 199 defineProperty(target, name, { |
202 get: getter, | 200 get: getter, |
203 set: setter, | 201 set: setter, |
204 configurable: configurable, | 202 configurable: configurable, |
205 enumerable: descriptor.enumerable | 203 enumerable: descriptor.enumerable |
206 }); | 204 }); |
207 } | 205 } |
208 } | 206 } |
209 function register(nativeConstructor, wrapperConstructor, opt_instance) { | 207 function register(nativeConstructor, wrapperConstructor, opt_instance) { |
210 if (nativeConstructor == null) { | |
211 return; | |
212 } | |
213 var nativePrototype = nativeConstructor.prototype; | 208 var nativePrototype = nativeConstructor.prototype; |
214 registerInternal(nativePrototype, wrapperConstructor, opt_instance); | 209 registerInternal(nativePrototype, wrapperConstructor, opt_instance); |
215 mixinStatics(wrapperConstructor, nativeConstructor); | 210 mixinStatics(wrapperConstructor, nativeConstructor); |
216 } | 211 } |
217 function registerInternal(nativePrototype, wrapperConstructor, opt_instance) { | 212 function registerInternal(nativePrototype, wrapperConstructor, opt_instance) { |
218 var wrapperPrototype = wrapperConstructor.prototype; | 213 var wrapperPrototype = wrapperConstructor.prototype; |
219 assert(constructorTable.get(nativePrototype) === undefined); | 214 assert(constructorTable.get(nativePrototype) === undefined); |
220 constructorTable.set(nativePrototype, wrapperConstructor); | 215 constructorTable.set(nativePrototype, wrapperConstructor); |
221 nativePrototypeTable.set(wrapperPrototype, nativePrototype); | 216 nativePrototypeTable.set(wrapperPrototype, nativePrototype); |
222 addForwardingProperties(nativePrototype, wrapperPrototype); | 217 addForwardingProperties(nativePrototype, wrapperPrototype); |
(...skipping 22 matching lines...) Expand all Loading... |
245 } | 240 } |
246 function isWrapper(object) { | 241 function isWrapper(object) { |
247 return object && object.__impl4cf1e782hg__; | 242 return object && object.__impl4cf1e782hg__; |
248 } | 243 } |
249 function isNative(object) { | 244 function isNative(object) { |
250 return !isWrapper(object); | 245 return !isWrapper(object); |
251 } | 246 } |
252 function wrap(impl) { | 247 function wrap(impl) { |
253 if (impl === null) return null; | 248 if (impl === null) return null; |
254 assert(isNative(impl)); | 249 assert(isNative(impl)); |
255 var wrapper = impl.__wrapper8e3dd93a60__; | 250 return impl.__wrapper8e3dd93a60__ || (impl.__wrapper8e3dd93a60__ = new (getW
rapperConstructor(impl))(impl)); |
256 if (wrapper != null) { | |
257 return wrapper; | |
258 } | |
259 return impl.__wrapper8e3dd93a60__ = new (getWrapperConstructor(impl, impl))(
impl); | |
260 } | 251 } |
261 function unwrap(wrapper) { | 252 function unwrap(wrapper) { |
262 if (wrapper === null) return null; | 253 if (wrapper === null) return null; |
263 assert(isWrapper(wrapper)); | 254 assert(isWrapper(wrapper)); |
264 return wrapper.__impl4cf1e782hg__; | 255 return wrapper.__impl4cf1e782hg__; |
265 } | 256 } |
266 function unsafeUnwrap(wrapper) { | 257 function unsafeUnwrap(wrapper) { |
267 return wrapper.__impl4cf1e782hg__; | 258 return wrapper.__impl4cf1e782hg__; |
268 } | 259 } |
269 function setWrapper(impl, wrapper) { | 260 function setWrapper(impl, wrapper) { |
(...skipping 29 matching lines...) Expand all Loading... |
299 function forwardMethodsToWrapper(constructors, names) { | 290 function forwardMethodsToWrapper(constructors, names) { |
300 constructors.forEach(function(constructor) { | 291 constructors.forEach(function(constructor) { |
301 names.forEach(function(name) { | 292 names.forEach(function(name) { |
302 constructor.prototype[name] = function() { | 293 constructor.prototype[name] = function() { |
303 var w = wrapIfNeeded(this); | 294 var w = wrapIfNeeded(this); |
304 return w[name].apply(w, arguments); | 295 return w[name].apply(w, arguments); |
305 }; | 296 }; |
306 }); | 297 }); |
307 }); | 298 }); |
308 } | 299 } |
309 scope.addForwardingProperties = addForwardingProperties; | |
310 scope.assert = assert; | 300 scope.assert = assert; |
311 scope.constructorTable = constructorTable; | 301 scope.constructorTable = constructorTable; |
312 scope.defineGetter = defineGetter; | 302 scope.defineGetter = defineGetter; |
313 scope.defineWrapGetter = defineWrapGetter; | 303 scope.defineWrapGetter = defineWrapGetter; |
314 scope.forwardMethodsToWrapper = forwardMethodsToWrapper; | 304 scope.forwardMethodsToWrapper = forwardMethodsToWrapper; |
315 scope.isIdentifierName = isIdentifierName; | 305 scope.isIdentifierName = isIdentifierName; |
316 scope.isWrapper = isWrapper; | 306 scope.isWrapper = isWrapper; |
317 scope.isWrapperFor = isWrapperFor; | 307 scope.isWrapperFor = isWrapperFor; |
318 scope.mixin = mixin; | 308 scope.mixin = mixin; |
319 scope.nativePrototypeTable = nativePrototypeTable; | 309 scope.nativePrototypeTable = nativePrototypeTable; |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 return eventPath.slice(); | 1102 return eventPath.slice(); |
1113 }, | 1103 }, |
1114 stopPropagation: function() { | 1104 stopPropagation: function() { |
1115 stopPropagationTable.set(this, true); | 1105 stopPropagationTable.set(this, true); |
1116 }, | 1106 }, |
1117 stopImmediatePropagation: function() { | 1107 stopImmediatePropagation: function() { |
1118 stopPropagationTable.set(this, true); | 1108 stopPropagationTable.set(this, true); |
1119 stopImmediatePropagationTable.set(this, true); | 1109 stopImmediatePropagationTable.set(this, true); |
1120 } | 1110 } |
1121 }; | 1111 }; |
1122 var supportsDefaultPrevented = function() { | |
1123 var e = document.createEvent("Event"); | |
1124 e.initEvent("test", true, true); | |
1125 e.preventDefault(); | |
1126 return e.defaultPrevented; | |
1127 }(); | |
1128 if (!supportsDefaultPrevented) { | |
1129 Event.prototype.preventDefault = function() { | |
1130 if (!this.cancelable) return; | |
1131 unsafeUnwrap(this).preventDefault(); | |
1132 Object.defineProperty(this, "defaultPrevented", { | |
1133 get: function() { | |
1134 return true; | |
1135 }, | |
1136 configurable: true | |
1137 }); | |
1138 }; | |
1139 } | |
1140 registerWrapper(OriginalEvent, Event, document.createEvent("Event")); | 1112 registerWrapper(OriginalEvent, Event, document.createEvent("Event")); |
1141 function unwrapOptions(options) { | 1113 function unwrapOptions(options) { |
1142 if (!options || !options.relatedTarget) return options; | 1114 if (!options || !options.relatedTarget) return options; |
1143 return Object.create(options, { | 1115 return Object.create(options, { |
1144 relatedTarget: { | 1116 relatedTarget: { |
1145 value: unwrap(options.relatedTarget) | 1117 value: unwrap(options.relatedTarget) |
1146 } | 1118 } |
1147 }); | 1119 }); |
1148 } | 1120 } |
1149 function registerGenericEvent(name, SuperEvent, prototype) { | 1121 function registerGenericEvent(name, SuperEvent, prototype) { |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1757 this.previousSibling_ = undefined; | 1729 this.previousSibling_ = undefined; |
1758 this.treeScope_ = undefined; | 1730 this.treeScope_ = undefined; |
1759 } | 1731 } |
1760 var OriginalDocumentFragment = window.DocumentFragment; | 1732 var OriginalDocumentFragment = window.DocumentFragment; |
1761 var originalAppendChild = OriginalNode.prototype.appendChild; | 1733 var originalAppendChild = OriginalNode.prototype.appendChild; |
1762 var originalCompareDocumentPosition = OriginalNode.prototype.compareDocumentPo
sition; | 1734 var originalCompareDocumentPosition = OriginalNode.prototype.compareDocumentPo
sition; |
1763 var originalIsEqualNode = OriginalNode.prototype.isEqualNode; | 1735 var originalIsEqualNode = OriginalNode.prototype.isEqualNode; |
1764 var originalInsertBefore = OriginalNode.prototype.insertBefore; | 1736 var originalInsertBefore = OriginalNode.prototype.insertBefore; |
1765 var originalRemoveChild = OriginalNode.prototype.removeChild; | 1737 var originalRemoveChild = OriginalNode.prototype.removeChild; |
1766 var originalReplaceChild = OriginalNode.prototype.replaceChild; | 1738 var originalReplaceChild = OriginalNode.prototype.replaceChild; |
1767 var isIEOrEdge = /Trident|Edge/.test(navigator.userAgent); | 1739 var isIe = /Trident|Edge/.test(navigator.userAgent); |
1768 var removeChildOriginalHelper = isIEOrEdge ? function(parent, child) { | 1740 var removeChildOriginalHelper = isIe ? function(parent, child) { |
1769 try { | 1741 try { |
1770 originalRemoveChild.call(parent, child); | 1742 originalRemoveChild.call(parent, child); |
1771 } catch (ex) { | 1743 } catch (ex) { |
1772 if (!(parent instanceof OriginalDocumentFragment)) throw ex; | 1744 if (!(parent instanceof OriginalDocumentFragment)) throw ex; |
1773 } | 1745 } |
1774 } : function(parent, child) { | 1746 } : function(parent, child) { |
1775 originalRemoveChild.call(parent, child); | 1747 originalRemoveChild.call(parent, child); |
1776 }; | 1748 }; |
1777 Node.prototype = Object.create(EventTarget.prototype); | 1749 Node.prototype = Object.create(EventTarget.prototype); |
1778 mixin(Node.prototype, { | 1750 mixin(Node.prototype, { |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2270 } | 2242 } |
2271 }; | 2243 }; |
2272 var ChildNodeInterface = { | 2244 var ChildNodeInterface = { |
2273 get nextElementSibling() { | 2245 get nextElementSibling() { |
2274 return forwardElement(this.nextSibling); | 2246 return forwardElement(this.nextSibling); |
2275 }, | 2247 }, |
2276 get previousElementSibling() { | 2248 get previousElementSibling() { |
2277 return backwardsElement(this.previousSibling); | 2249 return backwardsElement(this.previousSibling); |
2278 } | 2250 } |
2279 }; | 2251 }; |
2280 var NonElementParentNodeInterface = { | |
2281 getElementById: function(id) { | |
2282 if (/[ \t\n\r\f]/.test(id)) return null; | |
2283 return this.querySelector('[id="' + id + '"]'); | |
2284 } | |
2285 }; | |
2286 scope.ChildNodeInterface = ChildNodeInterface; | 2252 scope.ChildNodeInterface = ChildNodeInterface; |
2287 scope.NonElementParentNodeInterface = NonElementParentNodeInterface; | |
2288 scope.ParentNodeInterface = ParentNodeInterface; | 2253 scope.ParentNodeInterface = ParentNodeInterface; |
2289 })(window.ShadowDOMPolyfill); | 2254 })(window.ShadowDOMPolyfill); |
2290 | 2255 |
2291 (function(scope) { | 2256 (function(scope) { |
2292 "use strict"; | 2257 "use strict"; |
2293 var ChildNodeInterface = scope.ChildNodeInterface; | 2258 var ChildNodeInterface = scope.ChildNodeInterface; |
2294 var Node = scope.wrappers.Node; | 2259 var Node = scope.wrappers.Node; |
2295 var enqueueMutation = scope.enqueueMutation; | 2260 var enqueueMutation = scope.enqueueMutation; |
2296 var mixin = scope.mixin; | 2261 var mixin = scope.mixin; |
2297 var registerWrapper = scope.registerWrapper; | 2262 var registerWrapper = scope.registerWrapper; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2558 } | 2523 } |
2559 function makeSet(arr) { | 2524 function makeSet(arr) { |
2560 var set = {}; | 2525 var set = {}; |
2561 for (var i = 0; i < arr.length; i++) { | 2526 for (var i = 0; i < arr.length; i++) { |
2562 set[arr[i]] = true; | 2527 set[arr[i]] = true; |
2563 } | 2528 } |
2564 return set; | 2529 return set; |
2565 } | 2530 } |
2566 var voidElements = makeSet([ "area", "base", "br", "col", "command", "embed",
"hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr
" ]); | 2531 var voidElements = makeSet([ "area", "base", "br", "col", "command", "embed",
"hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr
" ]); |
2567 var plaintextParents = makeSet([ "style", "script", "xmp", "iframe", "noembed"
, "noframes", "plaintext", "noscript" ]); | 2532 var plaintextParents = makeSet([ "style", "script", "xmp", "iframe", "noembed"
, "noframes", "plaintext", "noscript" ]); |
2568 var XHTML_NS = "http://www.w3.org/1999/xhtml"; | |
2569 function needsSelfClosingSlash(node) { | |
2570 if (node.namespaceURI !== XHTML_NS) return true; | |
2571 var doctype = node.ownerDocument.doctype; | |
2572 return doctype && doctype.publicId && doctype.systemId; | |
2573 } | |
2574 function getOuterHTML(node, parentNode) { | 2533 function getOuterHTML(node, parentNode) { |
2575 switch (node.nodeType) { | 2534 switch (node.nodeType) { |
2576 case Node.ELEMENT_NODE: | 2535 case Node.ELEMENT_NODE: |
2577 var tagName = node.tagName.toLowerCase(); | 2536 var tagName = node.tagName.toLowerCase(); |
2578 var s = "<" + tagName; | 2537 var s = "<" + tagName; |
2579 var attrs = node.attributes; | 2538 var attrs = node.attributes; |
2580 for (var i = 0, attr; attr = attrs[i]; i++) { | 2539 for (var i = 0, attr; attr = attrs[i]; i++) { |
2581 s += " " + attr.name + '="' + escapeAttr(attr.value) + '"'; | 2540 s += " " + attr.name + '="' + escapeAttr(attr.value) + '"'; |
2582 } | 2541 } |
2583 if (voidElements[tagName]) { | 2542 s += ">"; |
2584 if (needsSelfClosingSlash(node)) s += "/"; | 2543 if (voidElements[tagName]) return s; |
2585 return s + ">"; | 2544 return s + getInnerHTML(node) + "</" + tagName + ">"; |
2586 } | |
2587 return s + ">" + getInnerHTML(node) + "</" + tagName + ">"; | |
2588 | 2545 |
2589 case Node.TEXT_NODE: | 2546 case Node.TEXT_NODE: |
2590 var data = node.data; | 2547 var data = node.data; |
2591 if (parentNode && plaintextParents[parentNode.localName]) return data; | 2548 if (parentNode && plaintextParents[parentNode.localName]) return data; |
2592 return escapeData(data); | 2549 return escapeData(data); |
2593 | 2550 |
2594 case Node.COMMENT_NODE: | 2551 case Node.COMMENT_NODE: |
2595 return "<!--" + node.data + "-->"; | 2552 return "<!--" + node.data + "-->"; |
2596 | 2553 |
2597 default: | 2554 default: |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2735 function methodRequiresRendering(name) { | 2692 function methodRequiresRendering(name) { |
2736 Object.defineProperty(HTMLElement.prototype, name, { | 2693 Object.defineProperty(HTMLElement.prototype, name, { |
2737 value: function() { | 2694 value: function() { |
2738 scope.renderAllPending(); | 2695 scope.renderAllPending(); |
2739 return unsafeUnwrap(this)[name].apply(unsafeUnwrap(this), arguments); | 2696 return unsafeUnwrap(this)[name].apply(unsafeUnwrap(this), arguments); |
2740 }, | 2697 }, |
2741 configurable: true, | 2698 configurable: true, |
2742 enumerable: true | 2699 enumerable: true |
2743 }); | 2700 }); |
2744 } | 2701 } |
2745 [ "focus", "getBoundingClientRect", "getClientRects", "scrollIntoView" ].forEa
ch(methodRequiresRendering); | 2702 [ "getBoundingClientRect", "getClientRects", "scrollIntoView" ].forEach(method
RequiresRendering); |
2746 registerWrapper(OriginalHTMLElement, HTMLElement, document.createElement("b"))
; | 2703 registerWrapper(OriginalHTMLElement, HTMLElement, document.createElement("b"))
; |
2747 scope.wrappers.HTMLElement = HTMLElement; | 2704 scope.wrappers.HTMLElement = HTMLElement; |
2748 scope.getInnerHTML = getInnerHTML; | 2705 scope.getInnerHTML = getInnerHTML; |
2749 scope.setInnerHTML = setInnerHTML; | 2706 scope.setInnerHTML = setInnerHTML; |
2750 })(window.ShadowDOMPolyfill); | 2707 })(window.ShadowDOMPolyfill); |
2751 | 2708 |
2752 (function(scope) { | 2709 (function(scope) { |
2753 "use strict"; | 2710 "use strict"; |
2754 var HTMLElement = scope.wrappers.HTMLElement; | 2711 var HTMLElement = scope.wrappers.HTMLElement; |
2755 var mixin = scope.mixin; | 2712 var mixin = scope.mixin; |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3157 } | 3114 } |
3158 HTMLUnknownElement.prototype = Object.create(HTMLElement.prototype); | 3115 HTMLUnknownElement.prototype = Object.create(HTMLElement.prototype); |
3159 registerWrapper(OriginalHTMLUnknownElement, HTMLUnknownElement); | 3116 registerWrapper(OriginalHTMLUnknownElement, HTMLUnknownElement); |
3160 scope.wrappers.HTMLUnknownElement = HTMLUnknownElement; | 3117 scope.wrappers.HTMLUnknownElement = HTMLUnknownElement; |
3161 })(window.ShadowDOMPolyfill); | 3118 })(window.ShadowDOMPolyfill); |
3162 | 3119 |
3163 (function(scope) { | 3120 (function(scope) { |
3164 "use strict"; | 3121 "use strict"; |
3165 var Element = scope.wrappers.Element; | 3122 var Element = scope.wrappers.Element; |
3166 var HTMLElement = scope.wrappers.HTMLElement; | 3123 var HTMLElement = scope.wrappers.HTMLElement; |
3167 var registerWrapper = scope.registerWrapper; | 3124 var registerObject = scope.registerObject; |
3168 var defineWrapGetter = scope.defineWrapGetter; | 3125 var defineWrapGetter = scope.defineWrapGetter; |
3169 var unsafeUnwrap = scope.unsafeUnwrap; | |
3170 var wrap = scope.wrap; | |
3171 var mixin = scope.mixin; | |
3172 var SVG_NS = "http://www.w3.org/2000/svg"; | 3126 var SVG_NS = "http://www.w3.org/2000/svg"; |
3173 var OriginalSVGElement = window.SVGElement; | |
3174 var svgTitleElement = document.createElementNS(SVG_NS, "title"); | 3127 var svgTitleElement = document.createElementNS(SVG_NS, "title"); |
| 3128 var SVGTitleElement = registerObject(svgTitleElement); |
| 3129 var SVGElement = Object.getPrototypeOf(SVGTitleElement.prototype).constructor; |
3175 if (!("classList" in svgTitleElement)) { | 3130 if (!("classList" in svgTitleElement)) { |
3176 var descr = Object.getOwnPropertyDescriptor(Element.prototype, "classList"); | 3131 var descr = Object.getOwnPropertyDescriptor(Element.prototype, "classList"); |
3177 Object.defineProperty(HTMLElement.prototype, "classList", descr); | 3132 Object.defineProperty(HTMLElement.prototype, "classList", descr); |
3178 delete Element.prototype.classList; | 3133 delete Element.prototype.classList; |
3179 } | 3134 } |
3180 function SVGElement(node) { | 3135 defineWrapGetter(SVGElement, "ownerSVGElement"); |
3181 Element.call(this, node); | |
3182 } | |
3183 SVGElement.prototype = Object.create(Element.prototype); | |
3184 mixin(SVGElement.prototype, { | |
3185 get ownerSVGElement() { | |
3186 return wrap(unsafeUnwrap(this).ownerSVGElement); | |
3187 } | |
3188 }); | |
3189 registerWrapper(OriginalSVGElement, SVGElement, document.createElementNS(SVG_N
S, "title")); | |
3190 scope.wrappers.SVGElement = SVGElement; | 3136 scope.wrappers.SVGElement = SVGElement; |
3191 })(window.ShadowDOMPolyfill); | 3137 })(window.ShadowDOMPolyfill); |
3192 | 3138 |
3193 (function(scope) { | 3139 (function(scope) { |
3194 "use strict"; | 3140 "use strict"; |
3195 var mixin = scope.mixin; | 3141 var mixin = scope.mixin; |
3196 var registerWrapper = scope.registerWrapper; | 3142 var registerWrapper = scope.registerWrapper; |
3197 var unwrap = scope.unwrap; | 3143 var unwrap = scope.unwrap; |
3198 var wrap = scope.wrap; | 3144 var wrap = scope.wrap; |
3199 var OriginalSVGUseElement = window.SVGUseElement; | 3145 var OriginalSVGUseElement = window.SVGUseElement; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3289 arguments[0] = unwrap(arguments[0]); | 3235 arguments[0] = unwrap(arguments[0]); |
3290 return unsafeUnwrap(this).createPattern.apply(unsafeUnwrap(this), argument
s); | 3236 return unsafeUnwrap(this).createPattern.apply(unsafeUnwrap(this), argument
s); |
3291 } | 3237 } |
3292 }); | 3238 }); |
3293 registerWrapper(OriginalCanvasRenderingContext2D, CanvasRenderingContext2D, do
cument.createElement("canvas").getContext("2d")); | 3239 registerWrapper(OriginalCanvasRenderingContext2D, CanvasRenderingContext2D, do
cument.createElement("canvas").getContext("2d")); |
3294 scope.wrappers.CanvasRenderingContext2D = CanvasRenderingContext2D; | 3240 scope.wrappers.CanvasRenderingContext2D = CanvasRenderingContext2D; |
3295 })(window.ShadowDOMPolyfill); | 3241 })(window.ShadowDOMPolyfill); |
3296 | 3242 |
3297 (function(scope) { | 3243 (function(scope) { |
3298 "use strict"; | 3244 "use strict"; |
3299 var addForwardingProperties = scope.addForwardingProperties; | |
3300 var mixin = scope.mixin; | 3245 var mixin = scope.mixin; |
3301 var registerWrapper = scope.registerWrapper; | 3246 var registerWrapper = scope.registerWrapper; |
3302 var setWrapper = scope.setWrapper; | 3247 var setWrapper = scope.setWrapper; |
3303 var unsafeUnwrap = scope.unsafeUnwrap; | 3248 var unsafeUnwrap = scope.unsafeUnwrap; |
3304 var unwrapIfNeeded = scope.unwrapIfNeeded; | 3249 var unwrapIfNeeded = scope.unwrapIfNeeded; |
3305 var wrap = scope.wrap; | 3250 var wrap = scope.wrap; |
3306 var OriginalWebGLRenderingContext = window.WebGLRenderingContext; | 3251 var OriginalWebGLRenderingContext = window.WebGLRenderingContext; |
3307 if (!OriginalWebGLRenderingContext) return; | 3252 if (!OriginalWebGLRenderingContext) return; |
3308 function WebGLRenderingContext(impl) { | 3253 function WebGLRenderingContext(impl) { |
3309 setWrapper(impl, this); | 3254 setWrapper(impl, this); |
3310 } | 3255 } |
3311 mixin(WebGLRenderingContext.prototype, { | 3256 mixin(WebGLRenderingContext.prototype, { |
3312 get canvas() { | 3257 get canvas() { |
3313 return wrap(unsafeUnwrap(this).canvas); | 3258 return wrap(unsafeUnwrap(this).canvas); |
3314 }, | 3259 }, |
3315 texImage2D: function() { | 3260 texImage2D: function() { |
3316 arguments[5] = unwrapIfNeeded(arguments[5]); | 3261 arguments[5] = unwrapIfNeeded(arguments[5]); |
3317 unsafeUnwrap(this).texImage2D.apply(unsafeUnwrap(this), arguments); | 3262 unsafeUnwrap(this).texImage2D.apply(unsafeUnwrap(this), arguments); |
3318 }, | 3263 }, |
3319 texSubImage2D: function() { | 3264 texSubImage2D: function() { |
3320 arguments[6] = unwrapIfNeeded(arguments[6]); | 3265 arguments[6] = unwrapIfNeeded(arguments[6]); |
3321 unsafeUnwrap(this).texSubImage2D.apply(unsafeUnwrap(this), arguments); | 3266 unsafeUnwrap(this).texSubImage2D.apply(unsafeUnwrap(this), arguments); |
3322 } | 3267 } |
3323 }); | 3268 }); |
3324 var OriginalWebGLRenderingContextBase = Object.getPrototypeOf(OriginalWebGLRen
deringContext.prototype); | |
3325 if (OriginalWebGLRenderingContextBase !== Object.prototype) { | |
3326 addForwardingProperties(OriginalWebGLRenderingContextBase, WebGLRenderingCon
text.prototype); | |
3327 } | |
3328 var instanceProperties = /WebKit/.test(navigator.userAgent) ? { | 3269 var instanceProperties = /WebKit/.test(navigator.userAgent) ? { |
3329 drawingBufferHeight: null, | 3270 drawingBufferHeight: null, |
3330 drawingBufferWidth: null | 3271 drawingBufferWidth: null |
3331 } : {}; | 3272 } : {}; |
3332 registerWrapper(OriginalWebGLRenderingContext, WebGLRenderingContext, instance
Properties); | 3273 registerWrapper(OriginalWebGLRenderingContext, WebGLRenderingContext, instance
Properties); |
3333 scope.wrappers.WebGLRenderingContext = WebGLRenderingContext; | 3274 scope.wrappers.WebGLRenderingContext = WebGLRenderingContext; |
3334 })(window.ShadowDOMPolyfill); | 3275 })(window.ShadowDOMPolyfill); |
3335 | 3276 |
3336 (function(scope) { | 3277 (function(scope) { |
3337 "use strict"; | 3278 "use strict"; |
3338 var Node = scope.wrappers.Node; | |
3339 var GetElementsByInterface = scope.GetElementsByInterface; | 3279 var GetElementsByInterface = scope.GetElementsByInterface; |
3340 var NonElementParentNodeInterface = scope.NonElementParentNodeInterface; | |
3341 var ParentNodeInterface = scope.ParentNodeInterface; | 3280 var ParentNodeInterface = scope.ParentNodeInterface; |
3342 var SelectorsInterface = scope.SelectorsInterface; | 3281 var SelectorsInterface = scope.SelectorsInterface; |
3343 var mixin = scope.mixin; | 3282 var mixin = scope.mixin; |
3344 var registerObject = scope.registerObject; | 3283 var registerObject = scope.registerObject; |
3345 var registerWrapper = scope.registerWrapper; | 3284 var DocumentFragment = registerObject(document.createDocumentFragment()); |
3346 var OriginalDocumentFragment = window.DocumentFragment; | |
3347 function DocumentFragment(node) { | |
3348 Node.call(this, node); | |
3349 } | |
3350 DocumentFragment.prototype = Object.create(Node.prototype); | |
3351 mixin(DocumentFragment.prototype, ParentNodeInterface); | 3285 mixin(DocumentFragment.prototype, ParentNodeInterface); |
3352 mixin(DocumentFragment.prototype, SelectorsInterface); | 3286 mixin(DocumentFragment.prototype, SelectorsInterface); |
3353 mixin(DocumentFragment.prototype, GetElementsByInterface); | 3287 mixin(DocumentFragment.prototype, GetElementsByInterface); |
3354 mixin(DocumentFragment.prototype, NonElementParentNodeInterface); | |
3355 registerWrapper(OriginalDocumentFragment, DocumentFragment, document.createDoc
umentFragment()); | |
3356 scope.wrappers.DocumentFragment = DocumentFragment; | |
3357 var Comment = registerObject(document.createComment("")); | 3288 var Comment = registerObject(document.createComment("")); |
3358 scope.wrappers.Comment = Comment; | 3289 scope.wrappers.Comment = Comment; |
| 3290 scope.wrappers.DocumentFragment = DocumentFragment; |
3359 })(window.ShadowDOMPolyfill); | 3291 })(window.ShadowDOMPolyfill); |
3360 | 3292 |
3361 (function(scope) { | 3293 (function(scope) { |
3362 "use strict"; | 3294 "use strict"; |
3363 var DocumentFragment = scope.wrappers.DocumentFragment; | 3295 var DocumentFragment = scope.wrappers.DocumentFragment; |
3364 var TreeScope = scope.TreeScope; | 3296 var TreeScope = scope.TreeScope; |
3365 var elementFromPoint = scope.elementFromPoint; | 3297 var elementFromPoint = scope.elementFromPoint; |
3366 var getInnerHTML = scope.getInnerHTML; | 3298 var getInnerHTML = scope.getInnerHTML; |
3367 var getTreeScope = scope.getTreeScope; | 3299 var getTreeScope = scope.getTreeScope; |
3368 var mixin = scope.mixin; | 3300 var mixin = scope.mixin; |
3369 var rewrap = scope.rewrap; | 3301 var rewrap = scope.rewrap; |
3370 var setInnerHTML = scope.setInnerHTML; | 3302 var setInnerHTML = scope.setInnerHTML; |
3371 var unsafeUnwrap = scope.unsafeUnwrap; | 3303 var unsafeUnwrap = scope.unsafeUnwrap; |
3372 var unwrap = scope.unwrap; | 3304 var unwrap = scope.unwrap; |
3373 var wrap = scope.wrap; | |
3374 var shadowHostTable = new WeakMap(); | 3305 var shadowHostTable = new WeakMap(); |
3375 var nextOlderShadowTreeTable = new WeakMap(); | 3306 var nextOlderShadowTreeTable = new WeakMap(); |
| 3307 var spaceCharRe = /[ \t\n\r\f]/; |
3376 function ShadowRoot(hostWrapper) { | 3308 function ShadowRoot(hostWrapper) { |
3377 var node = unwrap(unsafeUnwrap(hostWrapper).ownerDocument.createDocumentFrag
ment()); | 3309 var node = unwrap(unsafeUnwrap(hostWrapper).ownerDocument.createDocumentFrag
ment()); |
3378 DocumentFragment.call(this, node); | 3310 DocumentFragment.call(this, node); |
3379 rewrap(node, this); | 3311 rewrap(node, this); |
3380 var oldShadowRoot = hostWrapper.shadowRoot; | 3312 var oldShadowRoot = hostWrapper.shadowRoot; |
3381 nextOlderShadowTreeTable.set(this, oldShadowRoot); | 3313 nextOlderShadowTreeTable.set(this, oldShadowRoot); |
3382 this.treeScope_ = new TreeScope(this, getTreeScope(oldShadowRoot || hostWrap
per)); | 3314 this.treeScope_ = new TreeScope(this, getTreeScope(oldShadowRoot || hostWrap
per)); |
3383 shadowHostTable.set(this, hostWrapper); | 3315 shadowHostTable.set(this, hostWrapper); |
3384 } | 3316 } |
3385 ShadowRoot.prototype = Object.create(DocumentFragment.prototype); | 3317 ShadowRoot.prototype = Object.create(DocumentFragment.prototype); |
(...skipping 11 matching lines...) Expand all Loading... |
3397 }, | 3329 }, |
3398 get host() { | 3330 get host() { |
3399 return shadowHostTable.get(this) || null; | 3331 return shadowHostTable.get(this) || null; |
3400 }, | 3332 }, |
3401 invalidateShadowRenderer: function() { | 3333 invalidateShadowRenderer: function() { |
3402 return shadowHostTable.get(this).invalidateShadowRenderer(); | 3334 return shadowHostTable.get(this).invalidateShadowRenderer(); |
3403 }, | 3335 }, |
3404 elementFromPoint: function(x, y) { | 3336 elementFromPoint: function(x, y) { |
3405 return elementFromPoint(this, this.ownerDocument, x, y); | 3337 return elementFromPoint(this, this.ownerDocument, x, y); |
3406 }, | 3338 }, |
3407 getSelection: function() { | 3339 getElementById: function(id) { |
3408 return document.getSelection(); | 3340 if (spaceCharRe.test(id)) return null; |
3409 }, | 3341 return this.querySelector('[id="' + id + '"]'); |
3410 get activeElement() { | |
3411 var unwrappedActiveElement = unwrap(this).ownerDocument.activeElement; | |
3412 if (!unwrappedActiveElement || !unwrappedActiveElement.nodeType) return nu
ll; | |
3413 var activeElement = wrap(unwrappedActiveElement); | |
3414 while (!this.contains(activeElement)) { | |
3415 while (activeElement.parentNode) { | |
3416 activeElement = activeElement.parentNode; | |
3417 } | |
3418 if (activeElement.host) { | |
3419 activeElement = activeElement.host; | |
3420 } else { | |
3421 return null; | |
3422 } | |
3423 } | |
3424 return activeElement; | |
3425 } | 3342 } |
3426 }); | 3343 }); |
3427 scope.wrappers.ShadowRoot = ShadowRoot; | 3344 scope.wrappers.ShadowRoot = ShadowRoot; |
3428 })(window.ShadowDOMPolyfill); | 3345 })(window.ShadowDOMPolyfill); |
3429 | 3346 |
3430 (function(scope) { | 3347 (function(scope) { |
3431 "use strict"; | 3348 "use strict"; |
3432 var registerWrapper = scope.registerWrapper; | 3349 var registerWrapper = scope.registerWrapper; |
3433 var setWrapper = scope.setWrapper; | 3350 var setWrapper = scope.setWrapper; |
3434 var unsafeUnwrap = scope.unsafeUnwrap; | 3351 var unsafeUnwrap = scope.unsafeUnwrap; |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4006 containsNode: function(node, allowPartial) { | 3923 containsNode: function(node, allowPartial) { |
4007 return unsafeUnwrap(this).containsNode(unwrapIfNeeded(node), allowPartial)
; | 3924 return unsafeUnwrap(this).containsNode(unwrapIfNeeded(node), allowPartial)
; |
4008 }, | 3925 }, |
4009 getRangeAt: function(index) { | 3926 getRangeAt: function(index) { |
4010 return wrap(unsafeUnwrap(this).getRangeAt(index)); | 3927 return wrap(unsafeUnwrap(this).getRangeAt(index)); |
4011 }, | 3928 }, |
4012 removeRange: function(range) { | 3929 removeRange: function(range) { |
4013 unsafeUnwrap(this).removeRange(unwrap(range)); | 3930 unsafeUnwrap(this).removeRange(unwrap(range)); |
4014 }, | 3931 }, |
4015 selectAllChildren: function(node) { | 3932 selectAllChildren: function(node) { |
4016 unsafeUnwrap(this).selectAllChildren(node instanceof ShadowRoot ? unsafeUn
wrap(node.host) : unwrapIfNeeded(node)); | 3933 unsafeUnwrap(this).selectAllChildren(unwrapIfNeeded(node)); |
4017 }, | 3934 }, |
4018 toString: function() { | 3935 toString: function() { |
4019 return unsafeUnwrap(this).toString(); | 3936 return unsafeUnwrap(this).toString(); |
4020 } | 3937 } |
4021 }; | 3938 }; |
4022 if (OriginalSelection.prototype.extend) { | 3939 if (OriginalSelection.prototype.extend) { |
4023 Selection.prototype.extend = function(node, offset) { | 3940 Selection.prototype.extend = function(node, offset) { |
4024 unsafeUnwrap(this).extend(unwrapIfNeeded(node), offset); | 3941 unsafeUnwrap(this).extend(unwrapIfNeeded(node), offset); |
4025 }; | 3942 }; |
4026 } | 3943 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4073 }; | 3990 }; |
4074 registerWrapper(OriginalTreeWalker, TreeWalker); | 3991 registerWrapper(OriginalTreeWalker, TreeWalker); |
4075 scope.wrappers.TreeWalker = TreeWalker; | 3992 scope.wrappers.TreeWalker = TreeWalker; |
4076 })(window.ShadowDOMPolyfill); | 3993 })(window.ShadowDOMPolyfill); |
4077 | 3994 |
4078 (function(scope) { | 3995 (function(scope) { |
4079 "use strict"; | 3996 "use strict"; |
4080 var GetElementsByInterface = scope.GetElementsByInterface; | 3997 var GetElementsByInterface = scope.GetElementsByInterface; |
4081 var Node = scope.wrappers.Node; | 3998 var Node = scope.wrappers.Node; |
4082 var ParentNodeInterface = scope.ParentNodeInterface; | 3999 var ParentNodeInterface = scope.ParentNodeInterface; |
4083 var NonElementParentNodeInterface = scope.NonElementParentNodeInterface; | |
4084 var Selection = scope.wrappers.Selection; | 4000 var Selection = scope.wrappers.Selection; |
4085 var SelectorsInterface = scope.SelectorsInterface; | 4001 var SelectorsInterface = scope.SelectorsInterface; |
4086 var ShadowRoot = scope.wrappers.ShadowRoot; | 4002 var ShadowRoot = scope.wrappers.ShadowRoot; |
4087 var TreeScope = scope.TreeScope; | 4003 var TreeScope = scope.TreeScope; |
4088 var cloneNode = scope.cloneNode; | 4004 var cloneNode = scope.cloneNode; |
4089 var defineGetter = scope.defineGetter; | |
4090 var defineWrapGetter = scope.defineWrapGetter; | 4005 var defineWrapGetter = scope.defineWrapGetter; |
4091 var elementFromPoint = scope.elementFromPoint; | 4006 var elementFromPoint = scope.elementFromPoint; |
4092 var forwardMethodsToWrapper = scope.forwardMethodsToWrapper; | 4007 var forwardMethodsToWrapper = scope.forwardMethodsToWrapper; |
4093 var matchesNames = scope.matchesNames; | 4008 var matchesNames = scope.matchesNames; |
4094 var mixin = scope.mixin; | 4009 var mixin = scope.mixin; |
4095 var registerWrapper = scope.registerWrapper; | 4010 var registerWrapper = scope.registerWrapper; |
4096 var renderAllPending = scope.renderAllPending; | 4011 var renderAllPending = scope.renderAllPending; |
4097 var rewrap = scope.rewrap; | 4012 var rewrap = scope.rewrap; |
4098 var setWrapper = scope.setWrapper; | 4013 var setWrapper = scope.setWrapper; |
4099 var unsafeUnwrap = scope.unsafeUnwrap; | 4014 var unsafeUnwrap = scope.unsafeUnwrap; |
4100 var unwrap = scope.unwrap; | 4015 var unwrap = scope.unwrap; |
4101 var wrap = scope.wrap; | 4016 var wrap = scope.wrap; |
4102 var wrapEventTargetMethods = scope.wrapEventTargetMethods; | 4017 var wrapEventTargetMethods = scope.wrapEventTargetMethods; |
4103 var wrapNodeList = scope.wrapNodeList; | 4018 var wrapNodeList = scope.wrapNodeList; |
4104 var implementationTable = new WeakMap(); | 4019 var implementationTable = new WeakMap(); |
4105 function Document(node) { | 4020 function Document(node) { |
4106 Node.call(this, node); | 4021 Node.call(this, node); |
4107 this.treeScope_ = new TreeScope(this, null); | 4022 this.treeScope_ = new TreeScope(this, null); |
4108 } | 4023 } |
4109 Document.prototype = Object.create(Node.prototype); | 4024 Document.prototype = Object.create(Node.prototype); |
4110 defineWrapGetter(Document, "documentElement"); | 4025 defineWrapGetter(Document, "documentElement"); |
4111 defineWrapGetter(Document, "body"); | 4026 defineWrapGetter(Document, "body"); |
4112 defineWrapGetter(Document, "head"); | 4027 defineWrapGetter(Document, "head"); |
4113 defineGetter(Document, "activeElement", function() { | |
4114 var unwrappedActiveElement = unwrap(this).activeElement; | |
4115 if (!unwrappedActiveElement || !unwrappedActiveElement.nodeType) return null
; | |
4116 var activeElement = wrap(unwrappedActiveElement); | |
4117 while (!this.contains(activeElement)) { | |
4118 while (activeElement.parentNode) { | |
4119 activeElement = activeElement.parentNode; | |
4120 } | |
4121 if (activeElement.host) { | |
4122 activeElement = activeElement.host; | |
4123 } else { | |
4124 return null; | |
4125 } | |
4126 } | |
4127 return activeElement; | |
4128 }); | |
4129 function wrapMethod(name) { | 4028 function wrapMethod(name) { |
4130 var original = document[name]; | 4029 var original = document[name]; |
4131 Document.prototype[name] = function() { | 4030 Document.prototype[name] = function() { |
4132 return wrap(original.apply(unsafeUnwrap(this), arguments)); | 4031 return wrap(original.apply(unsafeUnwrap(this), arguments)); |
4133 }; | 4032 }; |
4134 } | 4033 } |
4135 [ "createComment", "createDocumentFragment", "createElement", "createElementNS
", "createEvent", "createEventNS", "createRange", "createTextNode" ].forEach(wra
pMethod); | 4034 [ "createComment", "createDocumentFragment", "createElement", "createElementNS
", "createEvent", "createEventNS", "createRange", "createTextNode", "getElementB
yId" ].forEach(wrapMethod); |
4136 var originalAdoptNode = document.adoptNode; | 4035 var originalAdoptNode = document.adoptNode; |
4137 function adoptNodeNoRemove(node, doc) { | 4036 function adoptNodeNoRemove(node, doc) { |
4138 originalAdoptNode.call(unsafeUnwrap(doc), unwrap(node)); | 4037 originalAdoptNode.call(unsafeUnwrap(doc), unwrap(node)); |
4139 adoptSubtree(node, doc); | 4038 adoptSubtree(node, doc); |
4140 } | 4039 } |
4141 function adoptSubtree(node, doc) { | 4040 function adoptSubtree(node, doc) { |
4142 if (node.shadowRoot) doc.adoptNode(node.shadowRoot); | 4041 if (node.shadowRoot) doc.adoptNode(node.shadowRoot); |
4143 if (node instanceof ShadowRoot) adoptOlderShadowRoots(node, doc); | 4042 if (node instanceof ShadowRoot) adoptOlderShadowRoots(node, doc); |
4144 for (var child = node.firstChild; child; child = child.nextSibling) { | 4043 for (var child = node.firstChild; child; child = child.nextSibling) { |
4145 adoptSubtree(child, doc); | 4044 adoptSubtree(child, doc); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4249 return CustomElementConstructor; | 4148 return CustomElementConstructor; |
4250 }; | 4149 }; |
4251 forwardMethodsToWrapper([ window.HTMLDocument || window.Document ], [ "regis
terElement" ]); | 4150 forwardMethodsToWrapper([ window.HTMLDocument || window.Document ], [ "regis
terElement" ]); |
4252 } | 4151 } |
4253 forwardMethodsToWrapper([ window.HTMLBodyElement, window.HTMLDocument || windo
w.Document, window.HTMLHeadElement, window.HTMLHtmlElement ], [ "appendChild", "
compareDocumentPosition", "contains", "getElementsByClassName", "getElementsByTa
gName", "getElementsByTagNameNS", "insertBefore", "querySelector", "querySelecto
rAll", "removeChild", "replaceChild" ]); | 4152 forwardMethodsToWrapper([ window.HTMLBodyElement, window.HTMLDocument || windo
w.Document, window.HTMLHeadElement, window.HTMLHtmlElement ], [ "appendChild", "
compareDocumentPosition", "contains", "getElementsByClassName", "getElementsByTa
gName", "getElementsByTagNameNS", "insertBefore", "querySelector", "querySelecto
rAll", "removeChild", "replaceChild" ]); |
4254 forwardMethodsToWrapper([ window.HTMLBodyElement, window.HTMLHeadElement, wind
ow.HTMLHtmlElement ], matchesNames); | 4153 forwardMethodsToWrapper([ window.HTMLBodyElement, window.HTMLHeadElement, wind
ow.HTMLHtmlElement ], matchesNames); |
4255 forwardMethodsToWrapper([ window.HTMLDocument || window.Document ], [ "adoptNo
de", "importNode", "contains", "createComment", "createDocumentFragment", "creat
eElement", "createElementNS", "createEvent", "createEventNS", "createRange", "cr
eateTextNode", "createTreeWalker", "elementFromPoint", "getElementById", "getEle
mentsByName", "getSelection" ]); | 4154 forwardMethodsToWrapper([ window.HTMLDocument || window.Document ], [ "adoptNo
de", "importNode", "contains", "createComment", "createDocumentFragment", "creat
eElement", "createElementNS", "createEvent", "createEventNS", "createRange", "cr
eateTextNode", "createTreeWalker", "elementFromPoint", "getElementById", "getEle
mentsByName", "getSelection" ]); |
4256 mixin(Document.prototype, GetElementsByInterface); | 4155 mixin(Document.prototype, GetElementsByInterface); |
4257 mixin(Document.prototype, ParentNodeInterface); | 4156 mixin(Document.prototype, ParentNodeInterface); |
4258 mixin(Document.prototype, SelectorsInterface); | 4157 mixin(Document.prototype, SelectorsInterface); |
4259 mixin(Document.prototype, NonElementParentNodeInterface); | |
4260 mixin(Document.prototype, { | 4158 mixin(Document.prototype, { |
4261 get implementation() { | 4159 get implementation() { |
4262 var implementation = implementationTable.get(this); | 4160 var implementation = implementationTable.get(this); |
4263 if (implementation) return implementation; | 4161 if (implementation) return implementation; |
4264 implementation = new DOMImplementation(unwrap(this).implementation); | 4162 implementation = new DOMImplementation(unwrap(this).implementation); |
4265 implementationTable.set(this, implementation); | 4163 implementationTable.set(this, implementation); |
4266 return implementation; | 4164 return implementation; |
4267 }, | 4165 }, |
4268 get defaultView() { | 4166 get defaultView() { |
4269 return wrap(unwrap(this).defaultView); | 4167 return wrap(unwrap(this).defaultView); |
4270 } | 4168 } |
4271 }); | 4169 }); |
4272 registerWrapper(window.Document, Document, document.implementation.createHTMLD
ocument("")); | 4170 registerWrapper(window.Document, Document, document.implementation.createHTMLD
ocument("")); |
4273 if (window.HTMLDocument) registerWrapper(window.HTMLDocument, Document); | 4171 if (window.HTMLDocument) registerWrapper(window.HTMLDocument, Document); |
4274 wrapEventTargetMethods([ window.HTMLBodyElement, window.HTMLDocument || window
.Document, window.HTMLHeadElement ]); | 4172 wrapEventTargetMethods([ window.HTMLBodyElement, window.HTMLDocument || window
.Document, window.HTMLHeadElement ]); |
4275 function DOMImplementation(impl) { | 4173 function DOMImplementation(impl) { |
4276 setWrapper(impl, this); | 4174 setWrapper(impl, this); |
4277 } | 4175 } |
4278 var originalCreateDocument = document.implementation.createDocument; | |
4279 DOMImplementation.prototype.createDocument = function() { | |
4280 arguments[2] = unwrap(arguments[2]); | |
4281 return wrap(originalCreateDocument.apply(unsafeUnwrap(this), arguments)); | |
4282 }; | |
4283 function wrapImplMethod(constructor, name) { | 4176 function wrapImplMethod(constructor, name) { |
4284 var original = document.implementation[name]; | 4177 var original = document.implementation[name]; |
4285 constructor.prototype[name] = function() { | 4178 constructor.prototype[name] = function() { |
4286 return wrap(original.apply(unsafeUnwrap(this), arguments)); | 4179 return wrap(original.apply(unsafeUnwrap(this), arguments)); |
4287 }; | 4180 }; |
4288 } | 4181 } |
4289 function forwardImplMethod(constructor, name) { | 4182 function forwardImplMethod(constructor, name) { |
4290 var original = document.implementation[name]; | 4183 var original = document.implementation[name]; |
4291 constructor.prototype[name] = function() { | 4184 constructor.prototype[name] = function() { |
4292 return original.apply(unsafeUnwrap(this), arguments); | 4185 return original.apply(unsafeUnwrap(this), arguments); |
4293 }; | 4186 }; |
4294 } | 4187 } |
4295 wrapImplMethod(DOMImplementation, "createDocumentType"); | 4188 wrapImplMethod(DOMImplementation, "createDocumentType"); |
| 4189 wrapImplMethod(DOMImplementation, "createDocument"); |
4296 wrapImplMethod(DOMImplementation, "createHTMLDocument"); | 4190 wrapImplMethod(DOMImplementation, "createHTMLDocument"); |
4297 forwardImplMethod(DOMImplementation, "hasFeature"); | 4191 forwardImplMethod(DOMImplementation, "hasFeature"); |
4298 registerWrapper(window.DOMImplementation, DOMImplementation); | 4192 registerWrapper(window.DOMImplementation, DOMImplementation); |
4299 forwardMethodsToWrapper([ window.DOMImplementation ], [ "createDocument", "cre
ateDocumentType", "createHTMLDocument", "hasFeature" ]); | 4193 forwardMethodsToWrapper([ window.DOMImplementation ], [ "createDocumentType",
"createDocument", "createHTMLDocument", "hasFeature" ]); |
4300 scope.adoptNodeNoRemove = adoptNodeNoRemove; | 4194 scope.adoptNodeNoRemove = adoptNodeNoRemove; |
4301 scope.wrappers.DOMImplementation = DOMImplementation; | 4195 scope.wrappers.DOMImplementation = DOMImplementation; |
4302 scope.wrappers.Document = Document; | 4196 scope.wrappers.Document = Document; |
4303 })(window.ShadowDOMPolyfill); | 4197 })(window.ShadowDOMPolyfill); |
4304 | 4198 |
4305 (function(scope) { | 4199 (function(scope) { |
4306 "use strict"; | 4200 "use strict"; |
4307 var EventTarget = scope.wrappers.EventTarget; | 4201 var EventTarget = scope.wrappers.EventTarget; |
4308 var Selection = scope.wrappers.Selection; | 4202 var Selection = scope.wrappers.Selection; |
4309 var mixin = scope.mixin; | 4203 var mixin = scope.mixin; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4484 if (!nativeConstructor) return; | 4378 if (!nativeConstructor) return; |
4485 var element = document.createElement(tagName); | 4379 var element = document.createElement(tagName); |
4486 var wrapperConstructor = element.constructor; | 4380 var wrapperConstructor = element.constructor; |
4487 window[nativeConstructorName] = wrapperConstructor; | 4381 window[nativeConstructorName] = wrapperConstructor; |
4488 } | 4382 } |
4489 Object.keys(elements).forEach(overrideConstructor); | 4383 Object.keys(elements).forEach(overrideConstructor); |
4490 Object.getOwnPropertyNames(scope.wrappers).forEach(function(name) { | 4384 Object.getOwnPropertyNames(scope.wrappers).forEach(function(name) { |
4491 window[name] = scope.wrappers[name]; | 4385 window[name] = scope.wrappers[name]; |
4492 }); | 4386 }); |
4493 })(window.ShadowDOMPolyfill); | 4387 })(window.ShadowDOMPolyfill); |
OLD | NEW |