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.5 | 10 // @version 0.7.20 |
11 window.WebComponents = window.WebComponents || {}; | 11 (function() { |
12 | 12 window.WebComponents = window.WebComponents || { |
13 (function(scope) { | 13 flags: {} |
14 var flags = scope.flags || {}; | 14 }; |
15 var file = "webcomponents.js"; | 15 var file = "webcomponents.js"; |
16 var script = document.querySelector('script[src*="' + file + '"]'); | 16 var script = document.querySelector('script[src*="' + file + '"]'); |
| 17 var flags = {}; |
17 if (!flags.noOpts) { | 18 if (!flags.noOpts) { |
18 location.search.slice(1).split("&").forEach(function(option) { | 19 location.search.slice(1).split("&").forEach(function(option) { |
19 var parts = option.split("="); | 20 var parts = option.split("="); |
20 var match; | 21 var match; |
21 if (parts[0] && (match = parts[0].match(/wc-(.+)/))) { | 22 if (parts[0] && (match = parts[0].match(/wc-(.+)/))) { |
22 flags[match[1]] = parts[1] || true; | 23 flags[match[1]] = parts[1] || true; |
23 } | 24 } |
24 }); | 25 }); |
25 if (script) { | 26 if (script) { |
26 for (var i = 0, a; a = script.attributes[i]; i++) { | 27 for (var i = 0, a; a = script.attributes[i]; i++) { |
(...skipping 17 matching lines...) Expand all Loading... |
44 flags.shadow = false; | 45 flags.shadow = false; |
45 } else { | 46 } else { |
46 flags.shadow = flags.shadow || !HTMLElement.prototype.createShadowRoot; | 47 flags.shadow = flags.shadow || !HTMLElement.prototype.createShadowRoot; |
47 } | 48 } |
48 if (flags.register) { | 49 if (flags.register) { |
49 window.CustomElements = window.CustomElements || { | 50 window.CustomElements = window.CustomElements || { |
50 flags: {} | 51 flags: {} |
51 }; | 52 }; |
52 window.CustomElements.flags.register = flags.register; | 53 window.CustomElements.flags.register = flags.register; |
53 } | 54 } |
54 scope.flags = flags; | 55 WebComponents.flags = flags; |
55 })(WebComponents); | 56 })(); |
56 | 57 |
57 if (WebComponents.flags.shadow) { | 58 if (WebComponents.flags.shadow) { |
58 if (typeof WeakMap === "undefined") { | 59 if (typeof WeakMap === "undefined") { |
59 (function() { | 60 (function() { |
60 var defineProperty = Object.defineProperty; | 61 var defineProperty = Object.defineProperty; |
61 var counter = Date.now() % 1e9; | 62 var counter = Date.now() % 1e9; |
62 var WeakMap = function() { | 63 var WeakMap = function() { |
63 this.name = "__st" + (Math.random() * 1e9 >>> 0) + (counter++ + "__"); | 64 this.name = "__st" + (Math.random() * 1e9 >>> 0) + (counter++ + "__"); |
64 }; | 65 }; |
65 WeakMap.prototype = { | 66 WeakMap.prototype = { |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 function forwardMethodsToWrapper(constructors, names) { | 345 function forwardMethodsToWrapper(constructors, names) { |
345 constructors.forEach(function(constructor) { | 346 constructors.forEach(function(constructor) { |
346 names.forEach(function(name) { | 347 names.forEach(function(name) { |
347 constructor.prototype[name] = function() { | 348 constructor.prototype[name] = function() { |
348 var w = wrapIfNeeded(this); | 349 var w = wrapIfNeeded(this); |
349 return w[name].apply(w, arguments); | 350 return w[name].apply(w, arguments); |
350 }; | 351 }; |
351 }); | 352 }); |
352 }); | 353 }); |
353 } | 354 } |
| 355 scope.addForwardingProperties = addForwardingProperties; |
354 scope.assert = assert; | 356 scope.assert = assert; |
355 scope.constructorTable = constructorTable; | 357 scope.constructorTable = constructorTable; |
356 scope.defineGetter = defineGetter; | 358 scope.defineGetter = defineGetter; |
357 scope.defineWrapGetter = defineWrapGetter; | 359 scope.defineWrapGetter = defineWrapGetter; |
358 scope.forwardMethodsToWrapper = forwardMethodsToWrapper; | 360 scope.forwardMethodsToWrapper = forwardMethodsToWrapper; |
359 scope.isIdentifierName = isIdentifierName; | 361 scope.isIdentifierName = isIdentifierName; |
360 scope.isWrapper = isWrapper; | 362 scope.isWrapper = isWrapper; |
361 scope.isWrapperFor = isWrapperFor; | 363 scope.isWrapperFor = isWrapperFor; |
362 scope.mixin = mixin; | 364 scope.mixin = mixin; |
363 scope.nativePrototypeTable = nativePrototypeTable; | 365 scope.nativePrototypeTable = nativePrototypeTable; |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 return eventPath.slice(); | 1153 return eventPath.slice(); |
1152 }, | 1154 }, |
1153 stopPropagation: function() { | 1155 stopPropagation: function() { |
1154 stopPropagationTable.set(this, true); | 1156 stopPropagationTable.set(this, true); |
1155 }, | 1157 }, |
1156 stopImmediatePropagation: function() { | 1158 stopImmediatePropagation: function() { |
1157 stopPropagationTable.set(this, true); | 1159 stopPropagationTable.set(this, true); |
1158 stopImmediatePropagationTable.set(this, true); | 1160 stopImmediatePropagationTable.set(this, true); |
1159 } | 1161 } |
1160 }; | 1162 }; |
| 1163 var supportsDefaultPrevented = function() { |
| 1164 var e = document.createEvent("Event"); |
| 1165 e.initEvent("test", true, true); |
| 1166 e.preventDefault(); |
| 1167 return e.defaultPrevented; |
| 1168 }(); |
| 1169 if (!supportsDefaultPrevented) { |
| 1170 Event.prototype.preventDefault = function() { |
| 1171 if (!this.cancelable) return; |
| 1172 unsafeUnwrap(this).preventDefault(); |
| 1173 Object.defineProperty(this, "defaultPrevented", { |
| 1174 get: function() { |
| 1175 return true; |
| 1176 }, |
| 1177 configurable: true |
| 1178 }); |
| 1179 }; |
| 1180 } |
1161 registerWrapper(OriginalEvent, Event, document.createEvent("Event")); | 1181 registerWrapper(OriginalEvent, Event, document.createEvent("Event")); |
1162 function unwrapOptions(options) { | 1182 function unwrapOptions(options) { |
1163 if (!options || !options.relatedTarget) return options; | 1183 if (!options || !options.relatedTarget) return options; |
1164 return Object.create(options, { | 1184 return Object.create(options, { |
1165 relatedTarget: { | 1185 relatedTarget: { |
1166 value: unwrap(options.relatedTarget) | 1186 value: unwrap(options.relatedTarget) |
1167 } | 1187 } |
1168 }); | 1188 }); |
1169 } | 1189 } |
1170 function registerGenericEvent(name, SuperEvent, prototype) { | 1190 function registerGenericEvent(name, SuperEvent, prototype) { |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1774 this.previousSibling_ = undefined; | 1794 this.previousSibling_ = undefined; |
1775 this.treeScope_ = undefined; | 1795 this.treeScope_ = undefined; |
1776 } | 1796 } |
1777 var OriginalDocumentFragment = window.DocumentFragment; | 1797 var OriginalDocumentFragment = window.DocumentFragment; |
1778 var originalAppendChild = OriginalNode.prototype.appendChild; | 1798 var originalAppendChild = OriginalNode.prototype.appendChild; |
1779 var originalCompareDocumentPosition = OriginalNode.prototype.compareDocument
Position; | 1799 var originalCompareDocumentPosition = OriginalNode.prototype.compareDocument
Position; |
1780 var originalIsEqualNode = OriginalNode.prototype.isEqualNode; | 1800 var originalIsEqualNode = OriginalNode.prototype.isEqualNode; |
1781 var originalInsertBefore = OriginalNode.prototype.insertBefore; | 1801 var originalInsertBefore = OriginalNode.prototype.insertBefore; |
1782 var originalRemoveChild = OriginalNode.prototype.removeChild; | 1802 var originalRemoveChild = OriginalNode.prototype.removeChild; |
1783 var originalReplaceChild = OriginalNode.prototype.replaceChild; | 1803 var originalReplaceChild = OriginalNode.prototype.replaceChild; |
1784 var isIe = /Trident|Edge/.test(navigator.userAgent); | 1804 var isIEOrEdge = /Trident|Edge/.test(navigator.userAgent); |
1785 var removeChildOriginalHelper = isIe ? function(parent, child) { | 1805 var removeChildOriginalHelper = isIEOrEdge ? function(parent, child) { |
1786 try { | 1806 try { |
1787 originalRemoveChild.call(parent, child); | 1807 originalRemoveChild.call(parent, child); |
1788 } catch (ex) { | 1808 } catch (ex) { |
1789 if (!(parent instanceof OriginalDocumentFragment)) throw ex; | 1809 if (!(parent instanceof OriginalDocumentFragment)) throw ex; |
1790 } | 1810 } |
1791 } : function(parent, child) { | 1811 } : function(parent, child) { |
1792 originalRemoveChild.call(parent, child); | 1812 originalRemoveChild.call(parent, child); |
1793 }; | 1813 }; |
1794 Node.prototype = Object.create(EventTarget.prototype); | 1814 Node.prototype = Object.create(EventTarget.prototype); |
1795 mixin(Node.prototype, { | 1815 mixin(Node.prototype, { |
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2745 function methodRequiresRendering(name) { | 2765 function methodRequiresRendering(name) { |
2746 Object.defineProperty(HTMLElement.prototype, name, { | 2766 Object.defineProperty(HTMLElement.prototype, name, { |
2747 value: function() { | 2767 value: function() { |
2748 scope.renderAllPending(); | 2768 scope.renderAllPending(); |
2749 return unsafeUnwrap(this)[name].apply(unsafeUnwrap(this), arguments); | 2769 return unsafeUnwrap(this)[name].apply(unsafeUnwrap(this), arguments); |
2750 }, | 2770 }, |
2751 configurable: true, | 2771 configurable: true, |
2752 enumerable: true | 2772 enumerable: true |
2753 }); | 2773 }); |
2754 } | 2774 } |
2755 [ "getBoundingClientRect", "getClientRects", "scrollIntoView" ].forEach(meth
odRequiresRendering); | 2775 [ "focus", "getBoundingClientRect", "getClientRects", "scrollIntoView" ].for
Each(methodRequiresRendering); |
2756 registerWrapper(OriginalHTMLElement, HTMLElement, document.createElement("b"
)); | 2776 registerWrapper(OriginalHTMLElement, HTMLElement, document.createElement("b"
)); |
2757 scope.wrappers.HTMLElement = HTMLElement; | 2777 scope.wrappers.HTMLElement = HTMLElement; |
2758 scope.getInnerHTML = getInnerHTML; | 2778 scope.getInnerHTML = getInnerHTML; |
2759 scope.setInnerHTML = setInnerHTML; | 2779 scope.setInnerHTML = setInnerHTML; |
2760 })(window.ShadowDOMPolyfill); | 2780 })(window.ShadowDOMPolyfill); |
2761 (function(scope) { | 2781 (function(scope) { |
2762 "use strict"; | 2782 "use strict"; |
2763 var HTMLElement = scope.wrappers.HTMLElement; | 2783 var HTMLElement = scope.wrappers.HTMLElement; |
2764 var mixin = scope.mixin; | 2784 var mixin = scope.mixin; |
2765 var registerWrapper = scope.registerWrapper; | 2785 var registerWrapper = scope.registerWrapper; |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3152 HTMLElement.call(this, node); | 3172 HTMLElement.call(this, node); |
3153 } | 3173 } |
3154 HTMLUnknownElement.prototype = Object.create(HTMLElement.prototype); | 3174 HTMLUnknownElement.prototype = Object.create(HTMLElement.prototype); |
3155 registerWrapper(OriginalHTMLUnknownElement, HTMLUnknownElement); | 3175 registerWrapper(OriginalHTMLUnknownElement, HTMLUnknownElement); |
3156 scope.wrappers.HTMLUnknownElement = HTMLUnknownElement; | 3176 scope.wrappers.HTMLUnknownElement = HTMLUnknownElement; |
3157 })(window.ShadowDOMPolyfill); | 3177 })(window.ShadowDOMPolyfill); |
3158 (function(scope) { | 3178 (function(scope) { |
3159 "use strict"; | 3179 "use strict"; |
3160 var Element = scope.wrappers.Element; | 3180 var Element = scope.wrappers.Element; |
3161 var HTMLElement = scope.wrappers.HTMLElement; | 3181 var HTMLElement = scope.wrappers.HTMLElement; |
3162 var registerObject = scope.registerObject; | 3182 var registerWrapper = scope.registerWrapper; |
3163 var defineWrapGetter = scope.defineWrapGetter; | 3183 var defineWrapGetter = scope.defineWrapGetter; |
| 3184 var unsafeUnwrap = scope.unsafeUnwrap; |
| 3185 var wrap = scope.wrap; |
| 3186 var mixin = scope.mixin; |
3164 var SVG_NS = "http://www.w3.org/2000/svg"; | 3187 var SVG_NS = "http://www.w3.org/2000/svg"; |
| 3188 var OriginalSVGElement = window.SVGElement; |
3165 var svgTitleElement = document.createElementNS(SVG_NS, "title"); | 3189 var svgTitleElement = document.createElementNS(SVG_NS, "title"); |
3166 var SVGTitleElement = registerObject(svgTitleElement); | |
3167 var SVGElement = Object.getPrototypeOf(SVGTitleElement.prototype).constructo
r; | |
3168 if (!("classList" in svgTitleElement)) { | 3190 if (!("classList" in svgTitleElement)) { |
3169 var descr = Object.getOwnPropertyDescriptor(Element.prototype, "classList"
); | 3191 var descr = Object.getOwnPropertyDescriptor(Element.prototype, "classList"
); |
3170 Object.defineProperty(HTMLElement.prototype, "classList", descr); | 3192 Object.defineProperty(HTMLElement.prototype, "classList", descr); |
3171 delete Element.prototype.classList; | 3193 delete Element.prototype.classList; |
3172 } | 3194 } |
3173 defineWrapGetter(SVGElement, "ownerSVGElement"); | 3195 function SVGElement(node) { |
| 3196 Element.call(this, node); |
| 3197 } |
| 3198 SVGElement.prototype = Object.create(Element.prototype); |
| 3199 mixin(SVGElement.prototype, { |
| 3200 get ownerSVGElement() { |
| 3201 return wrap(unsafeUnwrap(this).ownerSVGElement); |
| 3202 } |
| 3203 }); |
| 3204 registerWrapper(OriginalSVGElement, SVGElement, document.createElementNS(SVG
_NS, "title")); |
3174 scope.wrappers.SVGElement = SVGElement; | 3205 scope.wrappers.SVGElement = SVGElement; |
3175 })(window.ShadowDOMPolyfill); | 3206 })(window.ShadowDOMPolyfill); |
3176 (function(scope) { | 3207 (function(scope) { |
3177 "use strict"; | 3208 "use strict"; |
3178 var mixin = scope.mixin; | 3209 var mixin = scope.mixin; |
3179 var registerWrapper = scope.registerWrapper; | 3210 var registerWrapper = scope.registerWrapper; |
3180 var unwrap = scope.unwrap; | 3211 var unwrap = scope.unwrap; |
3181 var wrap = scope.wrap; | 3212 var wrap = scope.wrap; |
3182 var OriginalSVGUseElement = window.SVGUseElement; | 3213 var OriginalSVGUseElement = window.SVGUseElement; |
3183 var SVG_NS = "http://www.w3.org/2000/svg"; | 3214 var SVG_NS = "http://www.w3.org/2000/svg"; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3269 createPattern: function() { | 3300 createPattern: function() { |
3270 arguments[0] = unwrap(arguments[0]); | 3301 arguments[0] = unwrap(arguments[0]); |
3271 return unsafeUnwrap(this).createPattern.apply(unsafeUnwrap(this), argume
nts); | 3302 return unsafeUnwrap(this).createPattern.apply(unsafeUnwrap(this), argume
nts); |
3272 } | 3303 } |
3273 }); | 3304 }); |
3274 registerWrapper(OriginalCanvasRenderingContext2D, CanvasRenderingContext2D,
document.createElement("canvas").getContext("2d")); | 3305 registerWrapper(OriginalCanvasRenderingContext2D, CanvasRenderingContext2D,
document.createElement("canvas").getContext("2d")); |
3275 scope.wrappers.CanvasRenderingContext2D = CanvasRenderingContext2D; | 3306 scope.wrappers.CanvasRenderingContext2D = CanvasRenderingContext2D; |
3276 })(window.ShadowDOMPolyfill); | 3307 })(window.ShadowDOMPolyfill); |
3277 (function(scope) { | 3308 (function(scope) { |
3278 "use strict"; | 3309 "use strict"; |
| 3310 var addForwardingProperties = scope.addForwardingProperties; |
3279 var mixin = scope.mixin; | 3311 var mixin = scope.mixin; |
3280 var registerWrapper = scope.registerWrapper; | 3312 var registerWrapper = scope.registerWrapper; |
3281 var setWrapper = scope.setWrapper; | 3313 var setWrapper = scope.setWrapper; |
3282 var unsafeUnwrap = scope.unsafeUnwrap; | 3314 var unsafeUnwrap = scope.unsafeUnwrap; |
3283 var unwrapIfNeeded = scope.unwrapIfNeeded; | 3315 var unwrapIfNeeded = scope.unwrapIfNeeded; |
3284 var wrap = scope.wrap; | 3316 var wrap = scope.wrap; |
3285 var OriginalWebGLRenderingContext = window.WebGLRenderingContext; | 3317 var OriginalWebGLRenderingContext = window.WebGLRenderingContext; |
3286 if (!OriginalWebGLRenderingContext) return; | 3318 if (!OriginalWebGLRenderingContext) return; |
3287 function WebGLRenderingContext(impl) { | 3319 function WebGLRenderingContext(impl) { |
3288 setWrapper(impl, this); | 3320 setWrapper(impl, this); |
3289 } | 3321 } |
3290 mixin(WebGLRenderingContext.prototype, { | 3322 mixin(WebGLRenderingContext.prototype, { |
3291 get canvas() { | 3323 get canvas() { |
3292 return wrap(unsafeUnwrap(this).canvas); | 3324 return wrap(unsafeUnwrap(this).canvas); |
3293 }, | 3325 }, |
3294 texImage2D: function() { | 3326 texImage2D: function() { |
3295 arguments[5] = unwrapIfNeeded(arguments[5]); | 3327 arguments[5] = unwrapIfNeeded(arguments[5]); |
3296 unsafeUnwrap(this).texImage2D.apply(unsafeUnwrap(this), arguments); | 3328 unsafeUnwrap(this).texImage2D.apply(unsafeUnwrap(this), arguments); |
3297 }, | 3329 }, |
3298 texSubImage2D: function() { | 3330 texSubImage2D: function() { |
3299 arguments[6] = unwrapIfNeeded(arguments[6]); | 3331 arguments[6] = unwrapIfNeeded(arguments[6]); |
3300 unsafeUnwrap(this).texSubImage2D.apply(unsafeUnwrap(this), arguments); | 3332 unsafeUnwrap(this).texSubImage2D.apply(unsafeUnwrap(this), arguments); |
3301 } | 3333 } |
3302 }); | 3334 }); |
| 3335 var OriginalWebGLRenderingContextBase = Object.getPrototypeOf(OriginalWebGLR
enderingContext.prototype); |
| 3336 if (OriginalWebGLRenderingContextBase !== Object.prototype) { |
| 3337 addForwardingProperties(OriginalWebGLRenderingContextBase, WebGLRenderingC
ontext.prototype); |
| 3338 } |
3303 var instanceProperties = /WebKit/.test(navigator.userAgent) ? { | 3339 var instanceProperties = /WebKit/.test(navigator.userAgent) ? { |
3304 drawingBufferHeight: null, | 3340 drawingBufferHeight: null, |
3305 drawingBufferWidth: null | 3341 drawingBufferWidth: null |
3306 } : {}; | 3342 } : {}; |
3307 registerWrapper(OriginalWebGLRenderingContext, WebGLRenderingContext, instan
ceProperties); | 3343 registerWrapper(OriginalWebGLRenderingContext, WebGLRenderingContext, instan
ceProperties); |
3308 scope.wrappers.WebGLRenderingContext = WebGLRenderingContext; | 3344 scope.wrappers.WebGLRenderingContext = WebGLRenderingContext; |
3309 })(window.ShadowDOMPolyfill); | 3345 })(window.ShadowDOMPolyfill); |
3310 (function(scope) { | 3346 (function(scope) { |
3311 "use strict"; | 3347 "use strict"; |
| 3348 var Node = scope.wrappers.Node; |
3312 var GetElementsByInterface = scope.GetElementsByInterface; | 3349 var GetElementsByInterface = scope.GetElementsByInterface; |
3313 var NonElementParentNodeInterface = scope.NonElementParentNodeInterface; | 3350 var NonElementParentNodeInterface = scope.NonElementParentNodeInterface; |
3314 var ParentNodeInterface = scope.ParentNodeInterface; | 3351 var ParentNodeInterface = scope.ParentNodeInterface; |
3315 var SelectorsInterface = scope.SelectorsInterface; | 3352 var SelectorsInterface = scope.SelectorsInterface; |
3316 var mixin = scope.mixin; | 3353 var mixin = scope.mixin; |
3317 var registerObject = scope.registerObject; | 3354 var registerObject = scope.registerObject; |
3318 var DocumentFragment = registerObject(document.createDocumentFragment()); | 3355 var registerWrapper = scope.registerWrapper; |
| 3356 var OriginalDocumentFragment = window.DocumentFragment; |
| 3357 function DocumentFragment(node) { |
| 3358 Node.call(this, node); |
| 3359 } |
| 3360 DocumentFragment.prototype = Object.create(Node.prototype); |
3319 mixin(DocumentFragment.prototype, ParentNodeInterface); | 3361 mixin(DocumentFragment.prototype, ParentNodeInterface); |
3320 mixin(DocumentFragment.prototype, SelectorsInterface); | 3362 mixin(DocumentFragment.prototype, SelectorsInterface); |
3321 mixin(DocumentFragment.prototype, GetElementsByInterface); | 3363 mixin(DocumentFragment.prototype, GetElementsByInterface); |
3322 mixin(DocumentFragment.prototype, NonElementParentNodeInterface); | 3364 mixin(DocumentFragment.prototype, NonElementParentNodeInterface); |
| 3365 registerWrapper(OriginalDocumentFragment, DocumentFragment, document.createD
ocumentFragment()); |
| 3366 scope.wrappers.DocumentFragment = DocumentFragment; |
3323 var Comment = registerObject(document.createComment("")); | 3367 var Comment = registerObject(document.createComment("")); |
3324 scope.wrappers.Comment = Comment; | 3368 scope.wrappers.Comment = Comment; |
3325 scope.wrappers.DocumentFragment = DocumentFragment; | |
3326 })(window.ShadowDOMPolyfill); | 3369 })(window.ShadowDOMPolyfill); |
3327 (function(scope) { | 3370 (function(scope) { |
3328 "use strict"; | 3371 "use strict"; |
3329 var DocumentFragment = scope.wrappers.DocumentFragment; | 3372 var DocumentFragment = scope.wrappers.DocumentFragment; |
3330 var TreeScope = scope.TreeScope; | 3373 var TreeScope = scope.TreeScope; |
3331 var elementFromPoint = scope.elementFromPoint; | 3374 var elementFromPoint = scope.elementFromPoint; |
3332 var getInnerHTML = scope.getInnerHTML; | 3375 var getInnerHTML = scope.getInnerHTML; |
3333 var getTreeScope = scope.getTreeScope; | 3376 var getTreeScope = scope.getTreeScope; |
3334 var mixin = scope.mixin; | 3377 var mixin = scope.mixin; |
3335 var rewrap = scope.rewrap; | 3378 var rewrap = scope.rewrap; |
3336 var setInnerHTML = scope.setInnerHTML; | 3379 var setInnerHTML = scope.setInnerHTML; |
3337 var unsafeUnwrap = scope.unsafeUnwrap; | 3380 var unsafeUnwrap = scope.unsafeUnwrap; |
3338 var unwrap = scope.unwrap; | 3381 var unwrap = scope.unwrap; |
| 3382 var wrap = scope.wrap; |
3339 var shadowHostTable = new WeakMap(); | 3383 var shadowHostTable = new WeakMap(); |
3340 var nextOlderShadowTreeTable = new WeakMap(); | 3384 var nextOlderShadowTreeTable = new WeakMap(); |
3341 function ShadowRoot(hostWrapper) { | 3385 function ShadowRoot(hostWrapper) { |
3342 var node = unwrap(unsafeUnwrap(hostWrapper).ownerDocument.createDocumentFr
agment()); | 3386 var node = unwrap(unsafeUnwrap(hostWrapper).ownerDocument.createDocumentFr
agment()); |
3343 DocumentFragment.call(this, node); | 3387 DocumentFragment.call(this, node); |
3344 rewrap(node, this); | 3388 rewrap(node, this); |
3345 var oldShadowRoot = hostWrapper.shadowRoot; | 3389 var oldShadowRoot = hostWrapper.shadowRoot; |
3346 nextOlderShadowTreeTable.set(this, oldShadowRoot); | 3390 nextOlderShadowTreeTable.set(this, oldShadowRoot); |
3347 this.treeScope_ = new TreeScope(this, getTreeScope(oldShadowRoot || hostWr
apper)); | 3391 this.treeScope_ = new TreeScope(this, getTreeScope(oldShadowRoot || hostWr
apper)); |
3348 shadowHostTable.set(this, hostWrapper); | 3392 shadowHostTable.set(this, hostWrapper); |
(...skipping 12 matching lines...) Expand all Loading... |
3361 return nextOlderShadowTreeTable.get(this) || null; | 3405 return nextOlderShadowTreeTable.get(this) || null; |
3362 }, | 3406 }, |
3363 get host() { | 3407 get host() { |
3364 return shadowHostTable.get(this) || null; | 3408 return shadowHostTable.get(this) || null; |
3365 }, | 3409 }, |
3366 invalidateShadowRenderer: function() { | 3410 invalidateShadowRenderer: function() { |
3367 return shadowHostTable.get(this).invalidateShadowRenderer(); | 3411 return shadowHostTable.get(this).invalidateShadowRenderer(); |
3368 }, | 3412 }, |
3369 elementFromPoint: function(x, y) { | 3413 elementFromPoint: function(x, y) { |
3370 return elementFromPoint(this, this.ownerDocument, x, y); | 3414 return elementFromPoint(this, this.ownerDocument, x, y); |
| 3415 }, |
| 3416 getSelection: function() { |
| 3417 return document.getSelection(); |
| 3418 }, |
| 3419 get activeElement() { |
| 3420 var unwrappedActiveElement = unwrap(this).ownerDocument.activeElement; |
| 3421 if (!unwrappedActiveElement || !unwrappedActiveElement.nodeType) return
null; |
| 3422 var activeElement = wrap(unwrappedActiveElement); |
| 3423 if (activeElement === this.host) { |
| 3424 return null; |
| 3425 } |
| 3426 while (!this.contains(activeElement) && !this.host.contains(activeElemen
t)) { |
| 3427 while (activeElement.parentNode) { |
| 3428 activeElement = activeElement.parentNode; |
| 3429 } |
| 3430 if (activeElement.host) { |
| 3431 activeElement = activeElement.host; |
| 3432 } else { |
| 3433 return null; |
| 3434 } |
| 3435 } |
| 3436 return activeElement; |
3371 } | 3437 } |
3372 }); | 3438 }); |
3373 scope.wrappers.ShadowRoot = ShadowRoot; | 3439 scope.wrappers.ShadowRoot = ShadowRoot; |
3374 })(window.ShadowDOMPolyfill); | 3440 })(window.ShadowDOMPolyfill); |
3375 (function(scope) { | 3441 (function(scope) { |
3376 "use strict"; | 3442 "use strict"; |
3377 var registerWrapper = scope.registerWrapper; | 3443 var registerWrapper = scope.registerWrapper; |
3378 var setWrapper = scope.setWrapper; | 3444 var setWrapper = scope.setWrapper; |
3379 var unsafeUnwrap = scope.unsafeUnwrap; | 3445 var unsafeUnwrap = scope.unsafeUnwrap; |
3380 var unwrap = scope.unwrap; | 3446 var unwrap = scope.unwrap; |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3948 containsNode: function(node, allowPartial) { | 4014 containsNode: function(node, allowPartial) { |
3949 return unsafeUnwrap(this).containsNode(unwrapIfNeeded(node), allowPartia
l); | 4015 return unsafeUnwrap(this).containsNode(unwrapIfNeeded(node), allowPartia
l); |
3950 }, | 4016 }, |
3951 getRangeAt: function(index) { | 4017 getRangeAt: function(index) { |
3952 return wrap(unsafeUnwrap(this).getRangeAt(index)); | 4018 return wrap(unsafeUnwrap(this).getRangeAt(index)); |
3953 }, | 4019 }, |
3954 removeRange: function(range) { | 4020 removeRange: function(range) { |
3955 unsafeUnwrap(this).removeRange(unwrap(range)); | 4021 unsafeUnwrap(this).removeRange(unwrap(range)); |
3956 }, | 4022 }, |
3957 selectAllChildren: function(node) { | 4023 selectAllChildren: function(node) { |
3958 unsafeUnwrap(this).selectAllChildren(unwrapIfNeeded(node)); | 4024 unsafeUnwrap(this).selectAllChildren(node instanceof ShadowRoot ? unsafe
Unwrap(node.host) : unwrapIfNeeded(node)); |
3959 }, | 4025 }, |
3960 toString: function() { | 4026 toString: function() { |
3961 return unsafeUnwrap(this).toString(); | 4027 return unsafeUnwrap(this).toString(); |
3962 } | 4028 } |
3963 }; | 4029 }; |
3964 if (OriginalSelection.prototype.extend) { | 4030 if (OriginalSelection.prototype.extend) { |
3965 Selection.prototype.extend = function(node, offset) { | 4031 Selection.prototype.extend = function(node, offset) { |
3966 unsafeUnwrap(this).extend(unwrapIfNeeded(node), offset); | 4032 unsafeUnwrap(this).extend(unwrapIfNeeded(node), offset); |
3967 }; | 4033 }; |
3968 } | 4034 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4019 "use strict"; | 4085 "use strict"; |
4020 var GetElementsByInterface = scope.GetElementsByInterface; | 4086 var GetElementsByInterface = scope.GetElementsByInterface; |
4021 var Node = scope.wrappers.Node; | 4087 var Node = scope.wrappers.Node; |
4022 var ParentNodeInterface = scope.ParentNodeInterface; | 4088 var ParentNodeInterface = scope.ParentNodeInterface; |
4023 var NonElementParentNodeInterface = scope.NonElementParentNodeInterface; | 4089 var NonElementParentNodeInterface = scope.NonElementParentNodeInterface; |
4024 var Selection = scope.wrappers.Selection; | 4090 var Selection = scope.wrappers.Selection; |
4025 var SelectorsInterface = scope.SelectorsInterface; | 4091 var SelectorsInterface = scope.SelectorsInterface; |
4026 var ShadowRoot = scope.wrappers.ShadowRoot; | 4092 var ShadowRoot = scope.wrappers.ShadowRoot; |
4027 var TreeScope = scope.TreeScope; | 4093 var TreeScope = scope.TreeScope; |
4028 var cloneNode = scope.cloneNode; | 4094 var cloneNode = scope.cloneNode; |
| 4095 var defineGetter = scope.defineGetter; |
4029 var defineWrapGetter = scope.defineWrapGetter; | 4096 var defineWrapGetter = scope.defineWrapGetter; |
4030 var elementFromPoint = scope.elementFromPoint; | 4097 var elementFromPoint = scope.elementFromPoint; |
4031 var forwardMethodsToWrapper = scope.forwardMethodsToWrapper; | 4098 var forwardMethodsToWrapper = scope.forwardMethodsToWrapper; |
4032 var matchesNames = scope.matchesNames; | 4099 var matchesNames = scope.matchesNames; |
4033 var mixin = scope.mixin; | 4100 var mixin = scope.mixin; |
4034 var registerWrapper = scope.registerWrapper; | 4101 var registerWrapper = scope.registerWrapper; |
4035 var renderAllPending = scope.renderAllPending; | 4102 var renderAllPending = scope.renderAllPending; |
4036 var rewrap = scope.rewrap; | 4103 var rewrap = scope.rewrap; |
4037 var setWrapper = scope.setWrapper; | 4104 var setWrapper = scope.setWrapper; |
4038 var unsafeUnwrap = scope.unsafeUnwrap; | 4105 var unsafeUnwrap = scope.unsafeUnwrap; |
4039 var unwrap = scope.unwrap; | 4106 var unwrap = scope.unwrap; |
4040 var wrap = scope.wrap; | 4107 var wrap = scope.wrap; |
4041 var wrapEventTargetMethods = scope.wrapEventTargetMethods; | 4108 var wrapEventTargetMethods = scope.wrapEventTargetMethods; |
4042 var wrapNodeList = scope.wrapNodeList; | 4109 var wrapNodeList = scope.wrapNodeList; |
4043 var implementationTable = new WeakMap(); | 4110 var implementationTable = new WeakMap(); |
4044 function Document(node) { | 4111 function Document(node) { |
4045 Node.call(this, node); | 4112 Node.call(this, node); |
4046 this.treeScope_ = new TreeScope(this, null); | 4113 this.treeScope_ = new TreeScope(this, null); |
4047 } | 4114 } |
4048 Document.prototype = Object.create(Node.prototype); | 4115 Document.prototype = Object.create(Node.prototype); |
4049 defineWrapGetter(Document, "documentElement"); | 4116 defineWrapGetter(Document, "documentElement"); |
4050 defineWrapGetter(Document, "body"); | 4117 defineWrapGetter(Document, "body"); |
4051 defineWrapGetter(Document, "head"); | 4118 defineWrapGetter(Document, "head"); |
| 4119 defineGetter(Document, "activeElement", function() { |
| 4120 var unwrappedActiveElement = unwrap(this).activeElement; |
| 4121 if (!unwrappedActiveElement || !unwrappedActiveElement.nodeType) return nu
ll; |
| 4122 var activeElement = wrap(unwrappedActiveElement); |
| 4123 while (!this.contains(activeElement)) { |
| 4124 while (activeElement.parentNode) { |
| 4125 activeElement = activeElement.parentNode; |
| 4126 } |
| 4127 if (activeElement.host) { |
| 4128 activeElement = activeElement.host; |
| 4129 } else { |
| 4130 return null; |
| 4131 } |
| 4132 } |
| 4133 return activeElement; |
| 4134 }); |
4052 function wrapMethod(name) { | 4135 function wrapMethod(name) { |
4053 var original = document[name]; | 4136 var original = document[name]; |
4054 Document.prototype[name] = function() { | 4137 Document.prototype[name] = function() { |
4055 return wrap(original.apply(unsafeUnwrap(this), arguments)); | 4138 return wrap(original.apply(unsafeUnwrap(this), arguments)); |
4056 }; | 4139 }; |
4057 } | 4140 } |
4058 [ "createComment", "createDocumentFragment", "createElement", "createElement
NS", "createEvent", "createEventNS", "createRange", "createTextNode" ].forEach(w
rapMethod); | 4141 [ "createComment", "createDocumentFragment", "createElement", "createElement
NS", "createEvent", "createEventNS", "createRange", "createTextNode" ].forEach(w
rapMethod); |
4059 var originalAdoptNode = document.adoptNode; | 4142 var originalAdoptNode = document.adoptNode; |
4060 function adoptNodeNoRemove(node, doc) { | 4143 function adoptNodeNoRemove(node, doc) { |
4061 originalAdoptNode.call(unsafeUnwrap(doc), unwrap(node)); | 4144 originalAdoptNode.call(unsafeUnwrap(doc), unwrap(node)); |
(...skipping 1310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5372 var OriginalURL = scope.URL; | 5455 var OriginalURL = scope.URL; |
5373 if (OriginalURL) { | 5456 if (OriginalURL) { |
5374 jURL.createObjectURL = function(blob) { | 5457 jURL.createObjectURL = function(blob) { |
5375 return OriginalURL.createObjectURL.apply(OriginalURL, arguments); | 5458 return OriginalURL.createObjectURL.apply(OriginalURL, arguments); |
5376 }; | 5459 }; |
5377 jURL.revokeObjectURL = function(url) { | 5460 jURL.revokeObjectURL = function(url) { |
5378 OriginalURL.revokeObjectURL(url); | 5461 OriginalURL.revokeObjectURL(url); |
5379 }; | 5462 }; |
5380 } | 5463 } |
5381 scope.URL = jURL; | 5464 scope.URL = jURL; |
5382 })(this); | 5465 })(self); |
5383 | 5466 |
5384 (function(global) { | 5467 (function(global) { |
| 5468 if (global.JsMutationObserver) { |
| 5469 return; |
| 5470 } |
5385 var registrationsTable = new WeakMap(); | 5471 var registrationsTable = new WeakMap(); |
5386 var setImmediate; | 5472 var setImmediate; |
5387 if (/Trident|Edge/.test(navigator.userAgent)) { | 5473 if (/Trident|Edge/.test(navigator.userAgent)) { |
5388 setImmediate = setTimeout; | 5474 setImmediate = setTimeout; |
5389 } else if (window.setImmediate) { | 5475 } else if (window.setImmediate) { |
5390 setImmediate = window.setImmediate; | 5476 setImmediate = window.setImmediate; |
5391 } else { | 5477 } else { |
5392 var setImmediateQueue = []; | 5478 var setImmediateQueue = []; |
5393 var sentinel = String(Math.random()); | 5479 var sentinel = String(Math.random()); |
5394 window.addEventListener("message", function(e) { | 5480 window.addEventListener("message", function(e) { |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5670 record.nextSibling = nextSibling; | 5756 record.nextSibling = nextSibling; |
5671 forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function(options)
{ | 5757 forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function(options)
{ |
5672 if (!options.childList) return; | 5758 if (!options.childList) return; |
5673 return record; | 5759 return record; |
5674 }); | 5760 }); |
5675 } | 5761 } |
5676 clearRecords(); | 5762 clearRecords(); |
5677 } | 5763 } |
5678 }; | 5764 }; |
5679 global.JsMutationObserver = JsMutationObserver; | 5765 global.JsMutationObserver = JsMutationObserver; |
5680 if (!global.MutationObserver) global.MutationObserver = JsMutationObserver; | 5766 if (!global.MutationObserver) { |
5681 })(this); | 5767 global.MutationObserver = JsMutationObserver; |
| 5768 JsMutationObserver._isPolyfilled = true; |
| 5769 } |
| 5770 })(self); |
| 5771 |
| 5772 (function(scope) { |
| 5773 "use strict"; |
| 5774 if (!window.performance) { |
| 5775 var start = Date.now(); |
| 5776 window.performance = { |
| 5777 now: function() { |
| 5778 return Date.now() - start; |
| 5779 } |
| 5780 }; |
| 5781 } |
| 5782 if (!window.requestAnimationFrame) { |
| 5783 window.requestAnimationFrame = function() { |
| 5784 var nativeRaf = window.webkitRequestAnimationFrame || window.mozRequestAni
mationFrame; |
| 5785 return nativeRaf ? function(callback) { |
| 5786 return nativeRaf(function() { |
| 5787 callback(performance.now()); |
| 5788 }); |
| 5789 } : function(callback) { |
| 5790 return window.setTimeout(callback, 1e3 / 60); |
| 5791 }; |
| 5792 }(); |
| 5793 } |
| 5794 if (!window.cancelAnimationFrame) { |
| 5795 window.cancelAnimationFrame = function() { |
| 5796 return window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame
|| function(id) { |
| 5797 clearTimeout(id); |
| 5798 }; |
| 5799 }(); |
| 5800 } |
| 5801 var workingDefaultPrevented = function() { |
| 5802 var e = document.createEvent("Event"); |
| 5803 e.initEvent("foo", true, true); |
| 5804 e.preventDefault(); |
| 5805 return e.defaultPrevented; |
| 5806 }(); |
| 5807 if (!workingDefaultPrevented) { |
| 5808 var origPreventDefault = Event.prototype.preventDefault; |
| 5809 Event.prototype.preventDefault = function() { |
| 5810 if (!this.cancelable) { |
| 5811 return; |
| 5812 } |
| 5813 origPreventDefault.call(this); |
| 5814 Object.defineProperty(this, "defaultPrevented", { |
| 5815 get: function() { |
| 5816 return true; |
| 5817 }, |
| 5818 configurable: true |
| 5819 }); |
| 5820 }; |
| 5821 } |
| 5822 var isIE = /Trident/.test(navigator.userAgent); |
| 5823 if (!window.CustomEvent || isIE && typeof window.CustomEvent !== "function") { |
| 5824 window.CustomEvent = function(inType, params) { |
| 5825 params = params || {}; |
| 5826 var e = document.createEvent("CustomEvent"); |
| 5827 e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelab
le), params.detail); |
| 5828 return e; |
| 5829 }; |
| 5830 window.CustomEvent.prototype = window.Event.prototype; |
| 5831 } |
| 5832 if (!window.Event || isIE && typeof window.Event !== "function") { |
| 5833 var origEvent = window.Event; |
| 5834 window.Event = function(inType, params) { |
| 5835 params = params || {}; |
| 5836 var e = document.createEvent("Event"); |
| 5837 e.initEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable)); |
| 5838 return e; |
| 5839 }; |
| 5840 window.Event.prototype = origEvent.prototype; |
| 5841 } |
| 5842 })(window.WebComponents); |
5682 | 5843 |
5683 window.HTMLImports = window.HTMLImports || { | 5844 window.HTMLImports = window.HTMLImports || { |
5684 flags: {} | 5845 flags: {} |
5685 }; | 5846 }; |
5686 | 5847 |
5687 (function(scope) { | 5848 (function(scope) { |
5688 var IMPORT_LINK_TYPE = "import"; | 5849 var IMPORT_LINK_TYPE = "import"; |
5689 var useNative = Boolean(IMPORT_LINK_TYPE in document.createElement("link")); | 5850 var useNative = Boolean(IMPORT_LINK_TYPE in document.createElement("link")); |
5690 var hasShadowDOMPolyfill = Boolean(window.ShadowDOMPolyfill); | 5851 var hasShadowDOMPolyfill = Boolean(window.ShadowDOMPolyfill); |
5691 var wrap = function(node) { | 5852 var wrap = function(node) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5748 checkDone(); | 5909 checkDone(); |
5749 } | 5910 } |
5750 function errorLoadingImport(e) { | 5911 function errorLoadingImport(e) { |
5751 errorImports.push(this); | 5912 errorImports.push(this); |
5752 parsedCount++; | 5913 parsedCount++; |
5753 checkDone(); | 5914 checkDone(); |
5754 } | 5915 } |
5755 if (importCount) { | 5916 if (importCount) { |
5756 for (var i = 0, imp; i < importCount && (imp = imports[i]); i++) { | 5917 for (var i = 0, imp; i < importCount && (imp = imports[i]); i++) { |
5757 if (isImportLoaded(imp)) { | 5918 if (isImportLoaded(imp)) { |
| 5919 newImports.push(this); |
5758 parsedCount++; | 5920 parsedCount++; |
5759 checkDone(); | 5921 checkDone(); |
5760 } else { | 5922 } else { |
5761 imp.addEventListener("load", loadedImport); | 5923 imp.addEventListener("load", loadedImport); |
5762 imp.addEventListener("error", errorLoadingImport); | 5924 imp.addEventListener("error", errorLoadingImport); |
5763 } | 5925 } |
5764 } | 5926 } |
5765 } else { | 5927 } else { |
5766 checkDone(); | 5928 checkDone(); |
5767 } | 5929 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5874 return request.status >= 200 && request.status < 300 || request.status ===
304 || request.status === 0; | 6036 return request.status >= 200 && request.status < 300 || request.status ===
304 || request.status === 0; |
5875 }, | 6037 }, |
5876 load: function(url, next, nextContext) { | 6038 load: function(url, next, nextContext) { |
5877 var request = new XMLHttpRequest(); | 6039 var request = new XMLHttpRequest(); |
5878 if (scope.flags.debug || scope.flags.bust) { | 6040 if (scope.flags.debug || scope.flags.bust) { |
5879 url += "?" + Math.random(); | 6041 url += "?" + Math.random(); |
5880 } | 6042 } |
5881 request.open("GET", url, xhr.async); | 6043 request.open("GET", url, xhr.async); |
5882 request.addEventListener("readystatechange", function(e) { | 6044 request.addEventListener("readystatechange", function(e) { |
5883 if (request.readyState === 4) { | 6045 if (request.readyState === 4) { |
5884 var locationHeader = request.getResponseHeader("Location"); | |
5885 var redirectedUrl = null; | 6046 var redirectedUrl = null; |
5886 if (locationHeader) { | 6047 try { |
5887 var redirectedUrl = locationHeader.substr(0, 1) === "/" ? location.o
rigin + locationHeader : locationHeader; | 6048 var locationHeader = request.getResponseHeader("Location"); |
| 6049 if (locationHeader) { |
| 6050 redirectedUrl = locationHeader.substr(0, 1) === "/" ? location.ori
gin + locationHeader : locationHeader; |
| 6051 } |
| 6052 } catch (e) { |
| 6053 console.error(e.message); |
5888 } | 6054 } |
5889 next.call(nextContext, !xhr.ok(request) && request, request.response |
| request.responseText, redirectedUrl); | 6055 next.call(nextContext, !xhr.ok(request) && request, request.response |
| request.responseText, redirectedUrl); |
5890 } | 6056 } |
5891 }); | 6057 }); |
5892 request.send(); | 6058 request.send(); |
5893 return request; | 6059 return request; |
5894 }, | 6060 }, |
5895 loadDocument: function(url, next, nextContext) { | 6061 loadDocument: function(url, next, nextContext) { |
5896 this.load(url, next, nextContext).responseType = "document"; | 6062 this.load(url, next, nextContext).responseType = "document"; |
5897 } | 6063 } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6027 | 6193 |
6028 window.HTMLImports.addModule(function(scope) { | 6194 window.HTMLImports.addModule(function(scope) { |
6029 var path = scope.path; | 6195 var path = scope.path; |
6030 var rootDocument = scope.rootDocument; | 6196 var rootDocument = scope.rootDocument; |
6031 var flags = scope.flags; | 6197 var flags = scope.flags; |
6032 var isIE = scope.isIE; | 6198 var isIE = scope.isIE; |
6033 var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE; | 6199 var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE; |
6034 var IMPORT_SELECTOR = "link[rel=" + IMPORT_LINK_TYPE + "]"; | 6200 var IMPORT_SELECTOR = "link[rel=" + IMPORT_LINK_TYPE + "]"; |
6035 var importParser = { | 6201 var importParser = { |
6036 documentSelectors: IMPORT_SELECTOR, | 6202 documentSelectors: IMPORT_SELECTOR, |
6037 importsSelectors: [ IMPORT_SELECTOR, "link[rel=stylesheet]", "style", "scrip
t:not([type])", 'script[type="application/javascript"]', 'script[type="text/java
script"]' ].join(","), | 6203 importsSelectors: [ IMPORT_SELECTOR, "link[rel=stylesheet]:not([type])", "st
yle:not([type])", "script:not([type])", 'script[type="application/javascript"]',
'script[type="text/javascript"]' ].join(","), |
6038 map: { | 6204 map: { |
6039 link: "parseLink", | 6205 link: "parseLink", |
6040 script: "parseScript", | 6206 script: "parseScript", |
6041 style: "parseStyle" | 6207 style: "parseStyle" |
6042 }, | 6208 }, |
6043 dynamicElements: [], | 6209 dynamicElements: [], |
6044 parseNext: function() { | 6210 parseNext: function() { |
6045 var next = this.nextToParse(); | 6211 var next = this.nextToParse(); |
6046 if (next) { | 6212 if (next) { |
6047 this.parse(next); | 6213 this.parse(next); |
(...skipping 30 matching lines...) Expand all Loading... |
6078 this.parsingElement = null; | 6244 this.parsingElement = null; |
6079 flags.parse && console.log("completed", elt); | 6245 flags.parse && console.log("completed", elt); |
6080 }, | 6246 }, |
6081 markDynamicParsingComplete: function(elt) { | 6247 markDynamicParsingComplete: function(elt) { |
6082 var i = this.dynamicElements.indexOf(elt); | 6248 var i = this.dynamicElements.indexOf(elt); |
6083 if (i >= 0) { | 6249 if (i >= 0) { |
6084 this.dynamicElements.splice(i, 1); | 6250 this.dynamicElements.splice(i, 1); |
6085 } | 6251 } |
6086 }, | 6252 }, |
6087 parseImport: function(elt) { | 6253 parseImport: function(elt) { |
| 6254 elt.import = elt.__doc; |
6088 if (window.HTMLImports.__importsParsingHook) { | 6255 if (window.HTMLImports.__importsParsingHook) { |
6089 window.HTMLImports.__importsParsingHook(elt); | 6256 window.HTMLImports.__importsParsingHook(elt); |
6090 } | 6257 } |
6091 if (elt.import) { | 6258 if (elt.import) { |
6092 elt.import.__importParsed = true; | 6259 elt.import.__importParsed = true; |
6093 } | 6260 } |
6094 this.markParsingComplete(elt); | 6261 this.markParsingComplete(elt); |
6095 if (elt.__resource && !elt.__error) { | 6262 if (elt.__resource && !elt.__error) { |
6096 elt.dispatchEvent(new CustomEvent("load", { | 6263 elt.dispatchEvent(new CustomEvent("load", { |
6097 bubbles: false | 6264 bubbles: false |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6140 } | 6307 } |
6141 return n; | 6308 return n; |
6142 }, | 6309 }, |
6143 addElementToDocument: function(elt) { | 6310 addElementToDocument: function(elt) { |
6144 var port = this.rootImportForElement(elt.__importElement || elt); | 6311 var port = this.rootImportForElement(elt.__importElement || elt); |
6145 port.parentNode.insertBefore(elt, port); | 6312 port.parentNode.insertBefore(elt, port); |
6146 }, | 6313 }, |
6147 trackElement: function(elt, callback) { | 6314 trackElement: function(elt, callback) { |
6148 var self = this; | 6315 var self = this; |
6149 var done = function(e) { | 6316 var done = function(e) { |
| 6317 elt.removeEventListener("load", done); |
| 6318 elt.removeEventListener("error", done); |
6150 if (callback) { | 6319 if (callback) { |
6151 callback(e); | 6320 callback(e); |
6152 } | 6321 } |
6153 self.markParsingComplete(elt); | 6322 self.markParsingComplete(elt); |
6154 self.parseNext(); | 6323 self.parseNext(); |
6155 }; | 6324 }; |
6156 elt.addEventListener("load", done); | 6325 elt.addEventListener("load", done); |
6157 elt.addEventListener("error", done); | 6326 elt.addEventListener("error", done); |
6158 if (isIE && elt.localName === "style") { | 6327 if (isIE && elt.localName === "style") { |
6159 var fakeLoad = false; | 6328 var fakeLoad = false; |
(...skipping 17 matching lines...) Expand all Loading... |
6177 }); | 6346 }); |
6178 } | 6347 } |
6179 } | 6348 } |
6180 }, | 6349 }, |
6181 parseScript: function(scriptElt) { | 6350 parseScript: function(scriptElt) { |
6182 var script = document.createElement("script"); | 6351 var script = document.createElement("script"); |
6183 script.__importElement = scriptElt; | 6352 script.__importElement = scriptElt; |
6184 script.src = scriptElt.src ? scriptElt.src : generateScriptDataUrl(scriptE
lt); | 6353 script.src = scriptElt.src ? scriptElt.src : generateScriptDataUrl(scriptE
lt); |
6185 scope.currentScript = scriptElt; | 6354 scope.currentScript = scriptElt; |
6186 this.trackElement(script, function(e) { | 6355 this.trackElement(script, function(e) { |
6187 script.parentNode.removeChild(script); | 6356 if (script.parentNode) { |
| 6357 script.parentNode.removeChild(script); |
| 6358 } |
6188 scope.currentScript = null; | 6359 scope.currentScript = null; |
6189 }); | 6360 }); |
6190 this.addElementToDocument(script); | 6361 this.addElementToDocument(script); |
6191 }, | 6362 }, |
6192 nextToParse: function() { | 6363 nextToParse: function() { |
6193 this._mayParse = []; | 6364 this._mayParse = []; |
6194 return !this.parsingElement && (this.nextToParseInDoc(rootDocument) || thi
s.nextToParseDynamic()); | 6365 return !this.parsingElement && (this.nextToParseInDoc(rootDocument) || thi
s.nextToParseDynamic()); |
6195 }, | 6366 }, |
6196 nextToParseInDoc: function(doc, link) { | 6367 nextToParseInDoc: function(doc, link) { |
6197 if (doc && this._mayParse.indexOf(doc) < 0) { | 6368 if (doc && this._mayParse.indexOf(doc) < 0) { |
6198 this._mayParse.push(doc); | 6369 this._mayParse.push(doc); |
6199 var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc)); | 6370 var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc)); |
6200 for (var i = 0, l = nodes.length, p = 0, n; i < l && (n = nodes[i]); i++
) { | 6371 for (var i = 0, l = nodes.length, p = 0, n; i < l && (n = nodes[i]); i++
) { |
6201 if (!this.isParsed(n)) { | 6372 if (!this.isParsed(n)) { |
6202 if (this.hasResource(n)) { | 6373 if (this.hasResource(n)) { |
6203 return nodeIsImport(n) ? this.nextToParseInDoc(n.import, n) : n; | 6374 return nodeIsImport(n) ? this.nextToParseInDoc(n.__doc, n) : n; |
6204 } else { | 6375 } else { |
6205 return; | 6376 return; |
6206 } | 6377 } |
6207 } | 6378 } |
6208 } | 6379 } |
6209 } | 6380 } |
6210 return link; | 6381 return link; |
6211 }, | 6382 }, |
6212 nextToParseDynamic: function() { | 6383 nextToParseDynamic: function() { |
6213 return this.dynamicElements[0]; | 6384 return this.dynamicElements[0]; |
6214 }, | 6385 }, |
6215 parseSelectorsForNode: function(node) { | 6386 parseSelectorsForNode: function(node) { |
6216 var doc = node.ownerDocument || node; | 6387 var doc = node.ownerDocument || node; |
6217 return doc === rootDocument ? this.documentSelectors : this.importsSelecto
rs; | 6388 return doc === rootDocument ? this.documentSelectors : this.importsSelecto
rs; |
6218 }, | 6389 }, |
6219 isParsed: function(node) { | 6390 isParsed: function(node) { |
6220 return node.__importParsed; | 6391 return node.__importParsed; |
6221 }, | 6392 }, |
6222 needsDynamicParsing: function(elt) { | 6393 needsDynamicParsing: function(elt) { |
6223 return this.dynamicElements.indexOf(elt) >= 0; | 6394 return this.dynamicElements.indexOf(elt) >= 0; |
6224 }, | 6395 }, |
6225 hasResource: function(node) { | 6396 hasResource: function(node) { |
6226 if (nodeIsImport(node) && node.import === undefined) { | 6397 if (nodeIsImport(node) && node.__doc === undefined) { |
6227 return false; | 6398 return false; |
6228 } | 6399 } |
6229 return true; | 6400 return true; |
6230 } | 6401 } |
6231 }; | 6402 }; |
6232 function nodeIsImport(elt) { | 6403 function nodeIsImport(elt) { |
6233 return elt.localName === "link" && elt.rel === IMPORT_LINK_TYPE; | 6404 return elt.localName === "link" && elt.rel === IMPORT_LINK_TYPE; |
6234 } | 6405 } |
6235 function generateScriptDataUrl(script) { | 6406 function generateScriptDataUrl(script) { |
6236 var scriptContent = generateScriptContent(script); | 6407 var scriptContent = generateScriptContent(script); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6290 if (isImportLink(elt)) { | 6461 if (isImportLink(elt)) { |
6291 var doc = this.documents[url]; | 6462 var doc = this.documents[url]; |
6292 if (doc === undefined) { | 6463 if (doc === undefined) { |
6293 doc = err ? null : makeDocument(resource, redirectedUrl || url); | 6464 doc = err ? null : makeDocument(resource, redirectedUrl || url); |
6294 if (doc) { | 6465 if (doc) { |
6295 doc.__importLink = elt; | 6466 doc.__importLink = elt; |
6296 this.bootDocument(doc); | 6467 this.bootDocument(doc); |
6297 } | 6468 } |
6298 this.documents[url] = doc; | 6469 this.documents[url] = doc; |
6299 } | 6470 } |
6300 elt.import = doc; | 6471 elt.__doc = doc; |
6301 } | 6472 } |
6302 parser.parseNext(); | 6473 parser.parseNext(); |
6303 }, | 6474 }, |
6304 bootDocument: function(doc) { | 6475 bootDocument: function(doc) { |
6305 this.loadSubtree(doc); | 6476 this.loadSubtree(doc); |
6306 this.observer.observe(doc); | 6477 this.observer.observe(doc); |
6307 parser.parseNext(); | 6478 parser.parseNext(); |
6308 }, | 6479 }, |
6309 loadedAll: function() { | 6480 loadedAll: function() { |
6310 parser.parseNext(); | 6481 parser.parseNext(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6386 importer.observer.addCallback = dynamic.added.bind(dynamic); | 6557 importer.observer.addCallback = dynamic.added.bind(dynamic); |
6387 var matches = HTMLElement.prototype.matches || HTMLElement.prototype.matchesSe
lector || HTMLElement.prototype.webkitMatchesSelector || HTMLElement.prototype.m
ozMatchesSelector || HTMLElement.prototype.msMatchesSelector; | 6558 var matches = HTMLElement.prototype.matches || HTMLElement.prototype.matchesSe
lector || HTMLElement.prototype.webkitMatchesSelector || HTMLElement.prototype.m
ozMatchesSelector || HTMLElement.prototype.msMatchesSelector; |
6388 }); | 6559 }); |
6389 | 6560 |
6390 (function(scope) { | 6561 (function(scope) { |
6391 var initializeModules = scope.initializeModules; | 6562 var initializeModules = scope.initializeModules; |
6392 var isIE = scope.isIE; | 6563 var isIE = scope.isIE; |
6393 if (scope.useNative) { | 6564 if (scope.useNative) { |
6394 return; | 6565 return; |
6395 } | 6566 } |
6396 if (isIE && typeof window.CustomEvent !== "function") { | |
6397 window.CustomEvent = function(inType, params) { | |
6398 params = params || {}; | |
6399 var e = document.createEvent("CustomEvent"); | |
6400 e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelab
le), params.detail); | |
6401 e.preventDefault = function() { | |
6402 Object.defineProperty(this, "defaultPrevented", { | |
6403 get: function() { | |
6404 return true; | |
6405 } | |
6406 }); | |
6407 }; | |
6408 return e; | |
6409 }; | |
6410 window.CustomEvent.prototype = window.Event.prototype; | |
6411 } | |
6412 initializeModules(); | 6567 initializeModules(); |
6413 var rootDocument = scope.rootDocument; | 6568 var rootDocument = scope.rootDocument; |
6414 function bootstrap() { | 6569 function bootstrap() { |
6415 window.HTMLImports.importer.bootDocument(rootDocument); | 6570 window.HTMLImports.importer.bootDocument(rootDocument); |
6416 } | 6571 } |
6417 if (document.readyState === "complete" || document.readyState === "interactive
" && !window.attachEvent) { | 6572 if (document.readyState === "complete" || document.readyState === "interactive
" && !window.attachEvent) { |
6418 bootstrap(); | 6573 bootstrap(); |
6419 } else { | 6574 } else { |
6420 document.addEventListener("DOMContentLoaded", bootstrap); | 6575 document.addEventListener("DOMContentLoaded", bootstrap); |
6421 } | 6576 } |
(...skipping 10 matching lines...) Expand all Loading... |
6432 modules.push(module); | 6587 modules.push(module); |
6433 }; | 6588 }; |
6434 var initializeModules = function() { | 6589 var initializeModules = function() { |
6435 modules.forEach(function(module) { | 6590 modules.forEach(function(module) { |
6436 module(scope); | 6591 module(scope); |
6437 }); | 6592 }); |
6438 }; | 6593 }; |
6439 scope.addModule = addModule; | 6594 scope.addModule = addModule; |
6440 scope.initializeModules = initializeModules; | 6595 scope.initializeModules = initializeModules; |
6441 scope.hasNative = Boolean(document.registerElement); | 6596 scope.hasNative = Boolean(document.registerElement); |
| 6597 scope.isIE = /Trident/.test(navigator.userAgent); |
6442 scope.useNative = !flags.register && scope.hasNative && !window.ShadowDOMPolyf
ill && (!window.HTMLImports || window.HTMLImports.useNative); | 6598 scope.useNative = !flags.register && scope.hasNative && !window.ShadowDOMPolyf
ill && (!window.HTMLImports || window.HTMLImports.useNative); |
6443 })(window.CustomElements); | 6599 })(window.CustomElements); |
6444 | 6600 |
6445 window.CustomElements.addModule(function(scope) { | 6601 window.CustomElements.addModule(function(scope) { |
6446 var IMPORT_LINK_TYPE = window.HTMLImports ? window.HTMLImports.IMPORT_LINK_TYP
E : "none"; | 6602 var IMPORT_LINK_TYPE = window.HTMLImports ? window.HTMLImports.IMPORT_LINK_TYP
E : "none"; |
6447 function forSubtree(node, cb) { | 6603 function forSubtree(node, cb) { |
6448 findAllElements(node, function(e) { | 6604 findAllElements(node, function(e) { |
6449 if (cb(e)) { | 6605 if (cb(e)) { |
6450 return true; | 6606 return true; |
6451 } | 6607 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6494 cb(doc); | 6650 cb(doc); |
6495 } | 6651 } |
6496 scope.forDocumentTree = forDocumentTree; | 6652 scope.forDocumentTree = forDocumentTree; |
6497 scope.forSubtree = forSubtree; | 6653 scope.forSubtree = forSubtree; |
6498 }); | 6654 }); |
6499 | 6655 |
6500 window.CustomElements.addModule(function(scope) { | 6656 window.CustomElements.addModule(function(scope) { |
6501 var flags = scope.flags; | 6657 var flags = scope.flags; |
6502 var forSubtree = scope.forSubtree; | 6658 var forSubtree = scope.forSubtree; |
6503 var forDocumentTree = scope.forDocumentTree; | 6659 var forDocumentTree = scope.forDocumentTree; |
6504 function addedNode(node) { | 6660 function addedNode(node, isAttached) { |
6505 return added(node) || addedSubtree(node); | 6661 return added(node, isAttached) || addedSubtree(node, isAttached); |
6506 } | 6662 } |
6507 function added(node) { | 6663 function added(node, isAttached) { |
6508 if (scope.upgrade(node)) { | 6664 if (scope.upgrade(node, isAttached)) { |
6509 return true; | 6665 return true; |
6510 } | 6666 } |
6511 attached(node); | 6667 if (isAttached) { |
| 6668 attached(node); |
| 6669 } |
6512 } | 6670 } |
6513 function addedSubtree(node) { | 6671 function addedSubtree(node, isAttached) { |
6514 forSubtree(node, function(e) { | 6672 forSubtree(node, function(e) { |
6515 if (added(e)) { | 6673 if (added(e, isAttached)) { |
6516 return true; | 6674 return true; |
6517 } | 6675 } |
6518 }); | 6676 }); |
6519 } | 6677 } |
6520 function attachedNode(node) { | 6678 var hasThrottledAttached = window.MutationObserver._isPolyfilled && flags["thr
ottle-attached"]; |
6521 attached(node); | 6679 scope.hasPolyfillMutations = hasThrottledAttached; |
6522 if (inDocument(node)) { | 6680 scope.hasThrottledAttached = hasThrottledAttached; |
6523 forSubtree(node, function(e) { | |
6524 attached(e); | |
6525 }); | |
6526 } | |
6527 } | |
6528 var hasPolyfillMutations = !window.MutationObserver || window.MutationObserver
=== window.JsMutationObserver; | |
6529 scope.hasPolyfillMutations = hasPolyfillMutations; | |
6530 var isPendingMutations = false; | 6681 var isPendingMutations = false; |
6531 var pendingMutations = []; | 6682 var pendingMutations = []; |
6532 function deferMutation(fn) { | 6683 function deferMutation(fn) { |
6533 pendingMutations.push(fn); | 6684 pendingMutations.push(fn); |
6534 if (!isPendingMutations) { | 6685 if (!isPendingMutations) { |
6535 isPendingMutations = true; | 6686 isPendingMutations = true; |
6536 setTimeout(takeMutations); | 6687 setTimeout(takeMutations); |
6537 } | 6688 } |
6538 } | 6689 } |
6539 function takeMutations() { | 6690 function takeMutations() { |
6540 isPendingMutations = false; | 6691 isPendingMutations = false; |
6541 var $p = pendingMutations; | 6692 var $p = pendingMutations; |
6542 for (var i = 0, l = $p.length, p; i < l && (p = $p[i]); i++) { | 6693 for (var i = 0, l = $p.length, p; i < l && (p = $p[i]); i++) { |
6543 p(); | 6694 p(); |
6544 } | 6695 } |
6545 pendingMutations = []; | 6696 pendingMutations = []; |
6546 } | 6697 } |
6547 function attached(element) { | 6698 function attached(element) { |
6548 if (hasPolyfillMutations) { | 6699 if (hasThrottledAttached) { |
6549 deferMutation(function() { | 6700 deferMutation(function() { |
6550 _attached(element); | 6701 _attached(element); |
6551 }); | 6702 }); |
6552 } else { | 6703 } else { |
6553 _attached(element); | 6704 _attached(element); |
6554 } | 6705 } |
6555 } | 6706 } |
6556 function _attached(element) { | 6707 function _attached(element) { |
6557 if (element.__upgraded__ && (element.attachedCallback || element.detachedCal
lback)) { | 6708 if (element.__upgraded__ && !element.__attached) { |
6558 if (!element.__attached && inDocument(element)) { | 6709 element.__attached = true; |
6559 element.__attached = true; | 6710 if (element.attachedCallback) { |
6560 if (element.attachedCallback) { | 6711 element.attachedCallback(); |
6561 element.attachedCallback(); | |
6562 } | |
6563 } | 6712 } |
6564 } | 6713 } |
6565 } | 6714 } |
6566 function detachedNode(node) { | 6715 function detachedNode(node) { |
6567 detached(node); | 6716 detached(node); |
6568 forSubtree(node, function(e) { | 6717 forSubtree(node, function(e) { |
6569 detached(e); | 6718 detached(e); |
6570 }); | 6719 }); |
6571 } | 6720 } |
6572 function detached(element) { | 6721 function detached(element) { |
6573 if (hasPolyfillMutations) { | 6722 if (hasThrottledAttached) { |
6574 deferMutation(function() { | 6723 deferMutation(function() { |
6575 _detached(element); | 6724 _detached(element); |
6576 }); | 6725 }); |
6577 } else { | 6726 } else { |
6578 _detached(element); | 6727 _detached(element); |
6579 } | 6728 } |
6580 } | 6729 } |
6581 function _detached(element) { | 6730 function _detached(element) { |
6582 if (element.__upgraded__ && (element.attachedCallback || element.detachedCal
lback)) { | 6731 if (element.__upgraded__ && element.__attached) { |
6583 if (element.__attached && !inDocument(element)) { | 6732 element.__attached = false; |
6584 element.__attached = false; | 6733 if (element.detachedCallback) { |
6585 if (element.detachedCallback) { | 6734 element.detachedCallback(); |
6586 element.detachedCallback(); | |
6587 } | |
6588 } | 6735 } |
6589 } | 6736 } |
6590 } | 6737 } |
6591 function inDocument(element) { | 6738 function inDocument(element) { |
6592 var p = element; | 6739 var p = element; |
6593 var doc = wrap(document); | 6740 var doc = window.wrap(document); |
6594 while (p) { | 6741 while (p) { |
6595 if (p == doc) { | 6742 if (p == doc) { |
6596 return true; | 6743 return true; |
6597 } | 6744 } |
6598 p = p.parentNode || p.nodeType === Node.DOCUMENT_FRAGMENT_NODE && p.host; | 6745 p = p.parentNode || p.nodeType === Node.DOCUMENT_FRAGMENT_NODE && p.host; |
6599 } | 6746 } |
6600 } | 6747 } |
6601 function watchShadow(node) { | 6748 function watchShadow(node) { |
6602 if (node.shadowRoot && !node.shadowRoot.__watched) { | 6749 if (node.shadowRoot && !node.shadowRoot.__watched) { |
6603 flags.dom && console.log("watching shadow-root for: ", node.localName); | 6750 flags.dom && console.log("watching shadow-root for: ", node.localName); |
6604 var root = node.shadowRoot; | 6751 var root = node.shadowRoot; |
6605 while (root) { | 6752 while (root) { |
6606 observe(root); | 6753 observe(root); |
6607 root = root.olderShadowRoot; | 6754 root = root.olderShadowRoot; |
6608 } | 6755 } |
6609 } | 6756 } |
6610 } | 6757 } |
6611 function handler(mutations) { | 6758 function handler(root, mutations) { |
6612 if (flags.dom) { | 6759 if (flags.dom) { |
6613 var mx = mutations[0]; | 6760 var mx = mutations[0]; |
6614 if (mx && mx.type === "childList" && mx.addedNodes) { | 6761 if (mx && mx.type === "childList" && mx.addedNodes) { |
6615 if (mx.addedNodes) { | 6762 if (mx.addedNodes) { |
6616 var d = mx.addedNodes[0]; | 6763 var d = mx.addedNodes[0]; |
6617 while (d && d !== document && !d.host) { | 6764 while (d && d !== document && !d.host) { |
6618 d = d.parentNode; | 6765 d = d.parentNode; |
6619 } | 6766 } |
6620 var u = d && (d.URL || d._URL || d.host && d.host.localName) || ""; | 6767 var u = d && (d.URL || d._URL || d.host && d.host.localName) || ""; |
6621 u = u.split("/?").shift().split("/").pop(); | 6768 u = u.split("/?").shift().split("/").pop(); |
6622 } | 6769 } |
6623 } | 6770 } |
6624 console.group("mutations (%d) [%s]", mutations.length, u || ""); | 6771 console.group("mutations (%d) [%s]", mutations.length, u || ""); |
6625 } | 6772 } |
| 6773 var isAttached = inDocument(root); |
6626 mutations.forEach(function(mx) { | 6774 mutations.forEach(function(mx) { |
6627 if (mx.type === "childList") { | 6775 if (mx.type === "childList") { |
6628 forEach(mx.addedNodes, function(n) { | 6776 forEach(mx.addedNodes, function(n) { |
6629 if (!n.localName) { | 6777 if (!n.localName) { |
6630 return; | 6778 return; |
6631 } | 6779 } |
6632 addedNode(n); | 6780 addedNode(n, isAttached); |
6633 }); | 6781 }); |
6634 forEach(mx.removedNodes, function(n) { | 6782 forEach(mx.removedNodes, function(n) { |
6635 if (!n.localName) { | 6783 if (!n.localName) { |
6636 return; | 6784 return; |
6637 } | 6785 } |
6638 detachedNode(n); | 6786 detachedNode(n); |
6639 }); | 6787 }); |
6640 } | 6788 } |
6641 }); | 6789 }); |
6642 flags.dom && console.groupEnd(); | 6790 flags.dom && console.groupEnd(); |
6643 } | 6791 } |
6644 function takeRecords(node) { | 6792 function takeRecords(node) { |
6645 node = window.wrap(node); | 6793 node = window.wrap(node); |
6646 if (!node) { | 6794 if (!node) { |
6647 node = window.wrap(document); | 6795 node = window.wrap(document); |
6648 } | 6796 } |
6649 while (node.parentNode) { | 6797 while (node.parentNode) { |
6650 node = node.parentNode; | 6798 node = node.parentNode; |
6651 } | 6799 } |
6652 var observer = node.__observer; | 6800 var observer = node.__observer; |
6653 if (observer) { | 6801 if (observer) { |
6654 handler(observer.takeRecords()); | 6802 handler(node, observer.takeRecords()); |
6655 takeMutations(); | 6803 takeMutations(); |
6656 } | 6804 } |
6657 } | 6805 } |
6658 var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach); | 6806 var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach); |
6659 function observe(inRoot) { | 6807 function observe(inRoot) { |
6660 if (inRoot.__observer) { | 6808 if (inRoot.__observer) { |
6661 return; | 6809 return; |
6662 } | 6810 } |
6663 var observer = new MutationObserver(handler); | 6811 var observer = new MutationObserver(handler.bind(this, inRoot)); |
6664 observer.observe(inRoot, { | 6812 observer.observe(inRoot, { |
6665 childList: true, | 6813 childList: true, |
6666 subtree: true | 6814 subtree: true |
6667 }); | 6815 }); |
6668 inRoot.__observer = observer; | 6816 inRoot.__observer = observer; |
6669 } | 6817 } |
6670 function upgradeDocument(doc) { | 6818 function upgradeDocument(doc) { |
6671 doc = window.wrap(doc); | 6819 doc = window.wrap(doc); |
6672 flags.dom && console.group("upgradeDocument: ", doc.baseURI.split("/").pop()
); | 6820 flags.dom && console.group("upgradeDocument: ", doc.baseURI.split("/").pop()
); |
6673 addedNode(doc); | 6821 var isMainDocument = doc === window.wrap(document); |
| 6822 addedNode(doc, isMainDocument); |
6674 observe(doc); | 6823 observe(doc); |
6675 flags.dom && console.groupEnd(); | 6824 flags.dom && console.groupEnd(); |
6676 } | 6825 } |
6677 function upgradeDocumentTree(doc) { | 6826 function upgradeDocumentTree(doc) { |
6678 forDocumentTree(doc, upgradeDocument); | 6827 forDocumentTree(doc, upgradeDocument); |
6679 } | 6828 } |
6680 var originalCreateShadowRoot = Element.prototype.createShadowRoot; | 6829 var originalCreateShadowRoot = Element.prototype.createShadowRoot; |
6681 if (originalCreateShadowRoot) { | 6830 if (originalCreateShadowRoot) { |
6682 Element.prototype.createShadowRoot = function() { | 6831 Element.prototype.createShadowRoot = function() { |
6683 var root = originalCreateShadowRoot.call(this); | 6832 var root = originalCreateShadowRoot.call(this); |
6684 window.CustomElements.watchShadow(this); | 6833 window.CustomElements.watchShadow(this); |
6685 return root; | 6834 return root; |
6686 }; | 6835 }; |
6687 } | 6836 } |
6688 scope.watchShadow = watchShadow; | 6837 scope.watchShadow = watchShadow; |
6689 scope.upgradeDocumentTree = upgradeDocumentTree; | 6838 scope.upgradeDocumentTree = upgradeDocumentTree; |
| 6839 scope.upgradeDocument = upgradeDocument; |
6690 scope.upgradeSubtree = addedSubtree; | 6840 scope.upgradeSubtree = addedSubtree; |
6691 scope.upgradeAll = addedNode; | 6841 scope.upgradeAll = addedNode; |
6692 scope.attachedNode = attachedNode; | 6842 scope.attached = attached; |
6693 scope.takeRecords = takeRecords; | 6843 scope.takeRecords = takeRecords; |
6694 }); | 6844 }); |
6695 | 6845 |
6696 window.CustomElements.addModule(function(scope) { | 6846 window.CustomElements.addModule(function(scope) { |
6697 var flags = scope.flags; | 6847 var flags = scope.flags; |
6698 function upgrade(node) { | 6848 function upgrade(node, isAttached) { |
| 6849 if (node.localName === "template") { |
| 6850 if (window.HTMLTemplateElement && HTMLTemplateElement.decorate) { |
| 6851 HTMLTemplateElement.decorate(node); |
| 6852 } |
| 6853 } |
6699 if (!node.__upgraded__ && node.nodeType === Node.ELEMENT_NODE) { | 6854 if (!node.__upgraded__ && node.nodeType === Node.ELEMENT_NODE) { |
6700 var is = node.getAttribute("is"); | 6855 var is = node.getAttribute("is"); |
6701 var definition = scope.getRegisteredDefinition(is || node.localName); | 6856 var definition = scope.getRegisteredDefinition(node.localName) || scope.ge
tRegisteredDefinition(is); |
6702 if (definition) { | 6857 if (definition) { |
6703 if (is && definition.tag == node.localName) { | 6858 if (is && definition.tag == node.localName || !is && !definition.extends
) { |
6704 return upgradeWithDefinition(node, definition); | 6859 return upgradeWithDefinition(node, definition, isAttached); |
6705 } else if (!is && !definition.extends) { | |
6706 return upgradeWithDefinition(node, definition); | |
6707 } | 6860 } |
6708 } | 6861 } |
6709 } | 6862 } |
6710 } | 6863 } |
6711 function upgradeWithDefinition(element, definition) { | 6864 function upgradeWithDefinition(element, definition, isAttached) { |
6712 flags.upgrade && console.group("upgrade:", element.localName); | 6865 flags.upgrade && console.group("upgrade:", element.localName); |
6713 if (definition.is) { | 6866 if (definition.is) { |
6714 element.setAttribute("is", definition.is); | 6867 element.setAttribute("is", definition.is); |
6715 } | 6868 } |
6716 implementPrototype(element, definition); | 6869 implementPrototype(element, definition); |
6717 element.__upgraded__ = true; | 6870 element.__upgraded__ = true; |
6718 created(element); | 6871 created(element); |
6719 scope.attachedNode(element); | 6872 if (isAttached) { |
6720 scope.upgradeSubtree(element); | 6873 scope.attached(element); |
| 6874 } |
| 6875 scope.upgradeSubtree(element, isAttached); |
6721 flags.upgrade && console.groupEnd(); | 6876 flags.upgrade && console.groupEnd(); |
6722 return element; | 6877 return element; |
6723 } | 6878 } |
6724 function implementPrototype(element, definition) { | 6879 function implementPrototype(element, definition) { |
6725 if (Object.__proto__) { | 6880 if (Object.__proto__) { |
6726 element.__proto__ = definition.prototype; | 6881 element.__proto__ = definition.prototype; |
6727 } else { | 6882 } else { |
6728 customMixin(element, definition.prototype, definition.native); | 6883 customMixin(element, definition.prototype, definition.native); |
6729 element.__proto__ = definition.prototype; | 6884 element.__proto__ = definition.prototype; |
6730 } | 6885 } |
(...skipping 16 matching lines...) Expand all Loading... |
6747 if (element.createdCallback) { | 6902 if (element.createdCallback) { |
6748 element.createdCallback(); | 6903 element.createdCallback(); |
6749 } | 6904 } |
6750 } | 6905 } |
6751 scope.upgrade = upgrade; | 6906 scope.upgrade = upgrade; |
6752 scope.upgradeWithDefinition = upgradeWithDefinition; | 6907 scope.upgradeWithDefinition = upgradeWithDefinition; |
6753 scope.implementPrototype = implementPrototype; | 6908 scope.implementPrototype = implementPrototype; |
6754 }); | 6909 }); |
6755 | 6910 |
6756 window.CustomElements.addModule(function(scope) { | 6911 window.CustomElements.addModule(function(scope) { |
6757 var isIE11OrOlder = scope.isIE11OrOlder; | 6912 var isIE = scope.isIE; |
6758 var upgradeDocumentTree = scope.upgradeDocumentTree; | 6913 var upgradeDocumentTree = scope.upgradeDocumentTree; |
6759 var upgradeAll = scope.upgradeAll; | 6914 var upgradeAll = scope.upgradeAll; |
6760 var upgradeWithDefinition = scope.upgradeWithDefinition; | 6915 var upgradeWithDefinition = scope.upgradeWithDefinition; |
6761 var implementPrototype = scope.implementPrototype; | 6916 var implementPrototype = scope.implementPrototype; |
6762 var useNative = scope.useNative; | 6917 var useNative = scope.useNative; |
6763 function register(name, options) { | 6918 function register(name, options) { |
6764 var definition = options || {}; | 6919 var definition = options || {}; |
6765 if (!name) { | 6920 if (!name) { |
6766 throw new Error("document.registerElement: first argument `name` must not
be empty"); | 6921 throw new Error("document.registerElement: first argument `name` must not
be empty"); |
6767 } | 6922 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6838 definition.tag = baseTag || definition.__name; | 6993 definition.tag = baseTag || definition.__name; |
6839 if (baseTag) { | 6994 if (baseTag) { |
6840 definition.is = definition.__name; | 6995 definition.is = definition.__name; |
6841 } | 6996 } |
6842 } | 6997 } |
6843 function resolvePrototypeChain(definition) { | 6998 function resolvePrototypeChain(definition) { |
6844 if (!Object.__proto__) { | 6999 if (!Object.__proto__) { |
6845 var nativePrototype = HTMLElement.prototype; | 7000 var nativePrototype = HTMLElement.prototype; |
6846 if (definition.is) { | 7001 if (definition.is) { |
6847 var inst = document.createElement(definition.tag); | 7002 var inst = document.createElement(definition.tag); |
6848 var expectedPrototype = Object.getPrototypeOf(inst); | 7003 nativePrototype = Object.getPrototypeOf(inst); |
6849 if (expectedPrototype === definition.prototype) { | |
6850 nativePrototype = expectedPrototype; | |
6851 } | |
6852 } | 7004 } |
6853 var proto = definition.prototype, ancestor; | 7005 var proto = definition.prototype, ancestor; |
6854 while (proto && proto !== nativePrototype) { | 7006 var foundPrototype = false; |
| 7007 while (proto) { |
| 7008 if (proto == nativePrototype) { |
| 7009 foundPrototype = true; |
| 7010 } |
6855 ancestor = Object.getPrototypeOf(proto); | 7011 ancestor = Object.getPrototypeOf(proto); |
6856 proto.__proto__ = ancestor; | 7012 if (ancestor) { |
| 7013 proto.__proto__ = ancestor; |
| 7014 } |
6857 proto = ancestor; | 7015 proto = ancestor; |
6858 } | 7016 } |
| 7017 if (!foundPrototype) { |
| 7018 console.warn(definition.tag + " prototype not found in prototype chain f
or " + definition.is); |
| 7019 } |
6859 definition.native = nativePrototype; | 7020 definition.native = nativePrototype; |
6860 } | 7021 } |
6861 } | 7022 } |
6862 function instantiate(definition) { | 7023 function instantiate(definition) { |
6863 return upgradeWithDefinition(domCreateElement(definition.tag), definition); | 7024 return upgradeWithDefinition(domCreateElement(definition.tag), definition); |
6864 } | 7025 } |
6865 var registry = {}; | 7026 var registry = {}; |
6866 function getRegisteredDefinition(name) { | 7027 function getRegisteredDefinition(name) { |
6867 if (name) { | 7028 if (name) { |
6868 return registry[name.toLowerCase()]; | 7029 return registry[name.toLowerCase()]; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6910 if (tag.indexOf("-") >= 0) { | 7071 if (tag.indexOf("-") >= 0) { |
6911 implementPrototype(element, HTMLElement); | 7072 implementPrototype(element, HTMLElement); |
6912 } | 7073 } |
6913 return element; | 7074 return element; |
6914 } | 7075 } |
6915 var domCreateElement = document.createElement.bind(document); | 7076 var domCreateElement = document.createElement.bind(document); |
6916 var domCreateElementNS = document.createElementNS.bind(document); | 7077 var domCreateElementNS = document.createElementNS.bind(document); |
6917 var isInstance; | 7078 var isInstance; |
6918 if (!Object.__proto__ && !useNative) { | 7079 if (!Object.__proto__ && !useNative) { |
6919 isInstance = function(obj, ctor) { | 7080 isInstance = function(obj, ctor) { |
| 7081 if (obj instanceof ctor) { |
| 7082 return true; |
| 7083 } |
6920 var p = obj; | 7084 var p = obj; |
6921 while (p) { | 7085 while (p) { |
6922 if (p === ctor.prototype) { | 7086 if (p === ctor.prototype) { |
6923 return true; | 7087 return true; |
6924 } | 7088 } |
6925 p = p.__proto__; | 7089 p = p.__proto__; |
6926 } | 7090 } |
6927 return false; | 7091 return false; |
6928 }; | 7092 }; |
6929 } else { | 7093 } else { |
6930 isInstance = function(obj, base) { | 7094 isInstance = function(obj, base) { |
6931 return obj instanceof base; | 7095 return obj instanceof base; |
6932 }; | 7096 }; |
6933 } | 7097 } |
6934 function wrapDomMethodToForceUpgrade(obj, methodName) { | 7098 function wrapDomMethodToForceUpgrade(obj, methodName) { |
6935 var orig = obj[methodName]; | 7099 var orig = obj[methodName]; |
6936 obj[methodName] = function() { | 7100 obj[methodName] = function() { |
6937 var n = orig.apply(this, arguments); | 7101 var n = orig.apply(this, arguments); |
6938 upgradeAll(n); | 7102 upgradeAll(n); |
6939 return n; | 7103 return n; |
6940 }; | 7104 }; |
6941 } | 7105 } |
6942 wrapDomMethodToForceUpgrade(Node.prototype, "cloneNode"); | 7106 wrapDomMethodToForceUpgrade(Node.prototype, "cloneNode"); |
6943 wrapDomMethodToForceUpgrade(document, "importNode"); | 7107 wrapDomMethodToForceUpgrade(document, "importNode"); |
6944 if (isIE11OrOlder) { | 7108 if (isIE) { |
6945 (function() { | 7109 (function() { |
6946 var importNode = document.importNode; | 7110 var importNode = document.importNode; |
6947 document.importNode = function() { | 7111 document.importNode = function() { |
6948 var n = importNode.apply(document, arguments); | 7112 var n = importNode.apply(document, arguments); |
6949 if (n.nodeType == n.DOCUMENT_FRAGMENT_NODE) { | 7113 if (n.nodeType == n.DOCUMENT_FRAGMENT_NODE) { |
6950 var f = document.createDocumentFragment(); | 7114 var f = document.createDocumentFragment(); |
6951 f.appendChild(n); | 7115 f.appendChild(n); |
6952 return f; | 7116 return f; |
6953 } else { | 7117 } else { |
6954 return n; | 7118 return n; |
6955 } | 7119 } |
6956 }; | 7120 }; |
6957 })(); | 7121 })(); |
6958 } | 7122 } |
6959 document.registerElement = register; | 7123 document.registerElement = register; |
6960 document.createElement = createElement; | 7124 document.createElement = createElement; |
6961 document.createElementNS = createElementNS; | 7125 document.createElementNS = createElementNS; |
6962 scope.registry = registry; | 7126 scope.registry = registry; |
6963 scope.instanceof = isInstance; | 7127 scope.instanceof = isInstance; |
6964 scope.reservedTagList = reservedTagList; | 7128 scope.reservedTagList = reservedTagList; |
6965 scope.getRegisteredDefinition = getRegisteredDefinition; | 7129 scope.getRegisteredDefinition = getRegisteredDefinition; |
6966 document.register = document.registerElement; | 7130 document.register = document.registerElement; |
6967 }); | 7131 }); |
6968 | 7132 |
6969 (function(scope) { | 7133 (function(scope) { |
6970 var useNative = scope.useNative; | 7134 var useNative = scope.useNative; |
6971 var initializeModules = scope.initializeModules; | 7135 var initializeModules = scope.initializeModules; |
6972 var isIE11OrOlder = /Trident/.test(navigator.userAgent); | 7136 var isIE = scope.isIE; |
6973 if (useNative) { | 7137 if (useNative) { |
6974 var nop = function() {}; | 7138 var nop = function() {}; |
6975 scope.watchShadow = nop; | 7139 scope.watchShadow = nop; |
6976 scope.upgrade = nop; | 7140 scope.upgrade = nop; |
6977 scope.upgradeAll = nop; | 7141 scope.upgradeAll = nop; |
6978 scope.upgradeDocumentTree = nop; | 7142 scope.upgradeDocumentTree = nop; |
6979 scope.upgradeSubtree = nop; | 7143 scope.upgradeSubtree = nop; |
6980 scope.takeRecords = nop; | 7144 scope.takeRecords = nop; |
6981 scope.instanceof = function(obj, base) { | 7145 scope.instanceof = function(obj, base) { |
6982 return obj instanceof base; | 7146 return obj instanceof base; |
6983 }; | 7147 }; |
6984 } else { | 7148 } else { |
6985 initializeModules(); | 7149 initializeModules(); |
6986 } | 7150 } |
6987 var upgradeDocumentTree = scope.upgradeDocumentTree; | 7151 var upgradeDocumentTree = scope.upgradeDocumentTree; |
| 7152 var upgradeDocument = scope.upgradeDocument; |
6988 if (!window.wrap) { | 7153 if (!window.wrap) { |
6989 if (window.ShadowDOMPolyfill) { | 7154 if (window.ShadowDOMPolyfill) { |
6990 window.wrap = window.ShadowDOMPolyfill.wrapIfNeeded; | 7155 window.wrap = window.ShadowDOMPolyfill.wrapIfNeeded; |
6991 window.unwrap = window.ShadowDOMPolyfill.unwrapIfNeeded; | 7156 window.unwrap = window.ShadowDOMPolyfill.unwrapIfNeeded; |
6992 } else { | 7157 } else { |
6993 window.wrap = window.unwrap = function(node) { | 7158 window.wrap = window.unwrap = function(node) { |
6994 return node; | 7159 return node; |
6995 }; | 7160 }; |
6996 } | 7161 } |
6997 } | 7162 } |
| 7163 if (window.HTMLImports) { |
| 7164 window.HTMLImports.__importsParsingHook = function(elt) { |
| 7165 if (elt.import) { |
| 7166 upgradeDocument(wrap(elt.import)); |
| 7167 } |
| 7168 }; |
| 7169 } |
6998 function bootstrap() { | 7170 function bootstrap() { |
6999 upgradeDocumentTree(window.wrap(document)); | 7171 upgradeDocumentTree(window.wrap(document)); |
7000 if (window.HTMLImports) { | |
7001 window.HTMLImports.__importsParsingHook = function(elt) { | |
7002 upgradeDocumentTree(wrap(elt.import)); | |
7003 }; | |
7004 } | |
7005 window.CustomElements.ready = true; | 7172 window.CustomElements.ready = true; |
7006 setTimeout(function() { | 7173 var requestAnimationFrame = window.requestAnimationFrame || function(f) { |
7007 window.CustomElements.readyTime = Date.now(); | 7174 setTimeout(f, 16); |
7008 if (window.HTMLImports) { | 7175 }; |
7009 window.CustomElements.elapsed = window.CustomElements.readyTime - window
.HTMLImports.readyTime; | 7176 requestAnimationFrame(function() { |
7010 } | 7177 setTimeout(function() { |
7011 document.dispatchEvent(new CustomEvent("WebComponentsReady", { | 7178 window.CustomElements.readyTime = Date.now(); |
7012 bubbles: true | 7179 if (window.HTMLImports) { |
7013 })); | 7180 window.CustomElements.elapsed = window.CustomElements.readyTime - wind
ow.HTMLImports.readyTime; |
| 7181 } |
| 7182 document.dispatchEvent(new CustomEvent("WebComponentsReady", { |
| 7183 bubbles: true |
| 7184 })); |
| 7185 }); |
7014 }); | 7186 }); |
7015 } | 7187 } |
7016 if (isIE11OrOlder && typeof window.CustomEvent !== "function") { | |
7017 window.CustomEvent = function(inType, params) { | |
7018 params = params || {}; | |
7019 var e = document.createEvent("CustomEvent"); | |
7020 e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelab
le), params.detail); | |
7021 e.preventDefault = function() { | |
7022 Object.defineProperty(this, "defaultPrevented", { | |
7023 get: function() { | |
7024 return true; | |
7025 } | |
7026 }); | |
7027 }; | |
7028 return e; | |
7029 }; | |
7030 window.CustomEvent.prototype = window.Event.prototype; | |
7031 } | |
7032 if (document.readyState === "complete" || scope.flags.eager) { | 7188 if (document.readyState === "complete" || scope.flags.eager) { |
7033 bootstrap(); | 7189 bootstrap(); |
7034 } else if (document.readyState === "interactive" && !window.attachEvent && (!w
indow.HTMLImports || window.HTMLImports.ready)) { | 7190 } else if (document.readyState === "interactive" && !window.attachEvent && (!w
indow.HTMLImports || window.HTMLImports.ready)) { |
7035 bootstrap(); | 7191 bootstrap(); |
7036 } else { | 7192 } else { |
7037 var loadEvent = window.HTMLImports && !window.HTMLImports.ready ? "HTMLImpor
tsLoaded" : "DOMContentLoaded"; | 7193 var loadEvent = window.HTMLImports && !window.HTMLImports.ready ? "HTMLImpor
tsLoaded" : "DOMContentLoaded"; |
7038 window.addEventListener(loadEvent, bootstrap); | 7194 window.addEventListener(loadEvent, bootstrap); |
7039 } | 7195 } |
7040 scope.isIE11OrOlder = isIE11OrOlder; | |
7041 })(window.CustomElements); | 7196 })(window.CustomElements); |
7042 | 7197 |
7043 (function(scope) { | 7198 (function(scope) { |
7044 if (!Function.prototype.bind) { | 7199 if (!Function.prototype.bind) { |
7045 Function.prototype.bind = function(scope) { | 7200 Function.prototype.bind = function(scope) { |
7046 var self = this; | 7201 var self = this; |
7047 var args = Array.prototype.slice.call(arguments, 1); | 7202 var args = Array.prototype.slice.call(arguments, 1); |
7048 return function() { | 7203 return function() { |
7049 var args2 = args.slice(); | 7204 var args2 = args.slice(); |
7050 args2.push.apply(args2, arguments); | 7205 args2.push.apply(args2, arguments); |
7051 return self.apply(scope, args2); | 7206 return self.apply(scope, args2); |
7052 }; | 7207 }; |
7053 }; | 7208 }; |
7054 } | 7209 } |
7055 })(window.WebComponents); | 7210 })(window.WebComponents); |
7056 | 7211 |
7057 (function(scope) { | 7212 (function(scope) { |
7058 "use strict"; | |
7059 if (!window.performance) { | |
7060 var start = Date.now(); | |
7061 window.performance = { | |
7062 now: function() { | |
7063 return Date.now() - start; | |
7064 } | |
7065 }; | |
7066 } | |
7067 if (!window.requestAnimationFrame) { | |
7068 window.requestAnimationFrame = function() { | |
7069 var nativeRaf = window.webkitRequestAnimationFrame || window.mozRequestAni
mationFrame; | |
7070 return nativeRaf ? function(callback) { | |
7071 return nativeRaf(function() { | |
7072 callback(performance.now()); | |
7073 }); | |
7074 } : function(callback) { | |
7075 return window.setTimeout(callback, 1e3 / 60); | |
7076 }; | |
7077 }(); | |
7078 } | |
7079 if (!window.cancelAnimationFrame) { | |
7080 window.cancelAnimationFrame = function() { | |
7081 return window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame
|| function(id) { | |
7082 clearTimeout(id); | |
7083 }; | |
7084 }(); | |
7085 } | |
7086 var elementDeclarations = []; | |
7087 var polymerStub = function(name, dictionary) { | |
7088 if (typeof name !== "string" && arguments.length === 1) { | |
7089 Array.prototype.push.call(arguments, document._currentScript); | |
7090 } | |
7091 elementDeclarations.push(arguments); | |
7092 }; | |
7093 window.Polymer = polymerStub; | |
7094 scope.consumeDeclarations = function(callback) { | |
7095 scope.consumeDeclarations = function() { | |
7096 throw "Possible attempt to load Polymer twice"; | |
7097 }; | |
7098 if (callback) { | |
7099 callback(elementDeclarations); | |
7100 } | |
7101 elementDeclarations = null; | |
7102 }; | |
7103 function installPolymerWarning() { | |
7104 if (window.Polymer === polymerStub) { | |
7105 window.Polymer = function() { | |
7106 throw new Error("You tried to use polymer without loading it first. To "
+ 'load polymer, <link rel="import" href="' + 'components/polymer/polymer.html"
>'); | |
7107 }; | |
7108 } | |
7109 } | |
7110 if (HTMLImports.useNative) { | |
7111 installPolymerWarning(); | |
7112 } else { | |
7113 window.addEventListener("DOMContentLoaded", installPolymerWarning); | |
7114 } | |
7115 })(window.WebComponents); | |
7116 | |
7117 (function(scope) { | |
7118 var style = document.createElement("style"); | 7213 var style = document.createElement("style"); |
7119 style.textContent = "" + "body {" + "transition: opacity ease-in 0.2s;" + " }
\n" + "body[unresolved] {" + "opacity: 0; display: block; overflow: hidden; posi
tion: relative;" + " } \n"; | 7214 style.textContent = "" + "body {" + "transition: opacity ease-in 0.2s;" + " }
\n" + "body[unresolved] {" + "opacity: 0; display: block; overflow: hidden; posi
tion: relative;" + " } \n"; |
7120 var head = document.querySelector("head"); | 7215 var head = document.querySelector("head"); |
7121 head.insertBefore(style, head.firstChild); | 7216 head.insertBefore(style, head.firstChild); |
7122 })(window.WebComponents); | 7217 })(window.WebComponents); |
7123 | 7218 |
7124 (function(scope) { | 7219 (function(scope) { |
7125 window.Platform = scope; | 7220 window.Platform = scope; |
7126 })(window.WebComponents); | 7221 })(window.WebComponents); |
OLD | NEW |