Index: polymer_1.2.3/bower_components/webcomponentsjs/webcomponents-lite.js |
diff --git a/polymer_1.0.4/bower_components/webcomponentsjs/webcomponents-lite.js b/polymer_1.2.3/bower_components/webcomponentsjs/webcomponents-lite.js |
similarity index 89% |
copy from polymer_1.0.4/bower_components/webcomponentsjs/webcomponents-lite.js |
copy to polymer_1.2.3/bower_components/webcomponentsjs/webcomponents-lite.js |
index 47a7d9ded8a66429e1e3072ff91b59388b1fb80b..3a133a136b9d23c29fbd76140323e74fe9f79c70 100644 |
--- a/polymer_1.0.4/bower_components/webcomponentsjs/webcomponents-lite.js |
+++ b/polymer_1.2.3/bower_components/webcomponentsjs/webcomponents-lite.js |
@@ -7,13 +7,14 @@ |
* Code distributed by Google as part of the polymer project is also |
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt |
*/ |
-// @version 0.7.5 |
-window.WebComponents = window.WebComponents || {}; |
- |
-(function(scope) { |
- var flags = scope.flags || {}; |
+// @version 0.7.20 |
+(function() { |
+ window.WebComponents = window.WebComponents || { |
+ flags: {} |
+ }; |
var file = "webcomponents-lite.js"; |
var script = document.querySelector('script[src*="' + file + '"]'); |
+ var flags = {}; |
if (!flags.noOpts) { |
location.search.slice(1).split("&").forEach(function(option) { |
var parts = option.split("="); |
@@ -29,7 +30,7 @@ window.WebComponents = window.WebComponents || {}; |
} |
} |
} |
- if (flags.log) { |
+ if (flags.log && flags.log.split) { |
var parts = flags.log.split(","); |
flags.log = {}; |
parts.forEach(function(f) { |
@@ -39,20 +40,14 @@ window.WebComponents = window.WebComponents || {}; |
flags.log = {}; |
} |
} |
- flags.shadow = flags.shadow || flags.shadowdom || flags.polyfill; |
- if (flags.shadow === "native") { |
- flags.shadow = false; |
- } else { |
- flags.shadow = flags.shadow || !HTMLElement.prototype.createShadowRoot; |
- } |
if (flags.register) { |
window.CustomElements = window.CustomElements || { |
flags: {} |
}; |
window.CustomElements.flags.register = flags.register; |
} |
- scope.flags = flags; |
-})(window.WebComponents); |
+ WebComponents.flags = flags; |
+})(); |
(function(scope) { |
"use strict"; |
@@ -574,7 +569,7 @@ window.WebComponents = window.WebComponents || {}; |
}; |
} |
scope.URL = jURL; |
-})(this); |
+})(self); |
if (typeof WeakMap === "undefined") { |
(function() { |
@@ -613,6 +608,9 @@ if (typeof WeakMap === "undefined") { |
} |
(function(global) { |
+ if (global.JsMutationObserver) { |
+ return; |
+ } |
var registrationsTable = new WeakMap(); |
var setImmediate; |
if (/Trident|Edge/.test(navigator.userAgent)) { |
@@ -908,8 +906,167 @@ if (typeof WeakMap === "undefined") { |
} |
}; |
global.JsMutationObserver = JsMutationObserver; |
- if (!global.MutationObserver) global.MutationObserver = JsMutationObserver; |
-})(this); |
+ if (!global.MutationObserver) { |
+ global.MutationObserver = JsMutationObserver; |
+ JsMutationObserver._isPolyfilled = true; |
+ } |
+})(self); |
+ |
+if (typeof HTMLTemplateElement === "undefined") { |
+ (function() { |
+ var TEMPLATE_TAG = "template"; |
+ var contentDoc = document.implementation.createHTMLDocument("template"); |
+ var canDecorate = true; |
+ HTMLTemplateElement = function() {}; |
+ HTMLTemplateElement.prototype = Object.create(HTMLElement.prototype); |
+ HTMLTemplateElement.decorate = function(template) { |
+ if (template.content) { |
+ return; |
+ } |
+ template.content = contentDoc.createDocumentFragment(); |
+ var child; |
+ while (child = template.firstChild) { |
+ template.content.appendChild(child); |
+ } |
+ if (canDecorate) { |
+ try { |
+ Object.defineProperty(template, "innerHTML", { |
+ get: function() { |
+ var o = ""; |
+ for (var e = this.content.firstChild; e; e = e.nextSibling) { |
+ o += e.outerHTML || escapeData(e.data); |
+ } |
+ return o; |
+ }, |
+ set: function(text) { |
+ contentDoc.body.innerHTML = text; |
+ HTMLTemplateElement.bootstrap(contentDoc); |
+ while (this.content.firstChild) { |
+ this.content.removeChild(this.content.firstChild); |
+ } |
+ while (contentDoc.body.firstChild) { |
+ this.content.appendChild(contentDoc.body.firstChild); |
+ } |
+ }, |
+ configurable: true |
+ }); |
+ } catch (err) { |
+ canDecorate = false; |
+ } |
+ } |
+ HTMLTemplateElement.bootstrap(template.content); |
+ }; |
+ HTMLTemplateElement.bootstrap = function(doc) { |
+ var templates = doc.querySelectorAll(TEMPLATE_TAG); |
+ for (var i = 0, l = templates.length, t; i < l && (t = templates[i]); i++) { |
+ HTMLTemplateElement.decorate(t); |
+ } |
+ }; |
+ document.addEventListener("DOMContentLoaded", function() { |
+ HTMLTemplateElement.bootstrap(document); |
+ }); |
+ var createElement = document.createElement; |
+ document.createElement = function() { |
+ "use strict"; |
+ var el = createElement.apply(document, arguments); |
+ if (el.localName == "template") { |
+ HTMLTemplateElement.decorate(el); |
+ } |
+ return el; |
+ }; |
+ var escapeDataRegExp = /[&\u00A0<>]/g; |
+ function escapeReplace(c) { |
+ switch (c) { |
+ case "&": |
+ return "&"; |
+ |
+ case "<": |
+ return "<"; |
+ |
+ case ">": |
+ return ">"; |
+ |
+ case "Â ": |
+ return " "; |
+ } |
+ } |
+ function escapeData(s) { |
+ return s.replace(escapeDataRegExp, escapeReplace); |
+ } |
+ })(); |
+} |
+ |
+(function(scope) { |
+ "use strict"; |
+ if (!window.performance) { |
+ var start = Date.now(); |
+ window.performance = { |
+ now: function() { |
+ return Date.now() - start; |
+ } |
+ }; |
+ } |
+ if (!window.requestAnimationFrame) { |
+ window.requestAnimationFrame = function() { |
+ var nativeRaf = window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame; |
+ return nativeRaf ? function(callback) { |
+ return nativeRaf(function() { |
+ callback(performance.now()); |
+ }); |
+ } : function(callback) { |
+ return window.setTimeout(callback, 1e3 / 60); |
+ }; |
+ }(); |
+ } |
+ if (!window.cancelAnimationFrame) { |
+ window.cancelAnimationFrame = function() { |
+ return window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || function(id) { |
+ clearTimeout(id); |
+ }; |
+ }(); |
+ } |
+ var workingDefaultPrevented = function() { |
+ var e = document.createEvent("Event"); |
+ e.initEvent("foo", true, true); |
+ e.preventDefault(); |
+ return e.defaultPrevented; |
+ }(); |
+ if (!workingDefaultPrevented) { |
+ var origPreventDefault = Event.prototype.preventDefault; |
+ Event.prototype.preventDefault = function() { |
+ if (!this.cancelable) { |
+ return; |
+ } |
+ origPreventDefault.call(this); |
+ Object.defineProperty(this, "defaultPrevented", { |
+ get: function() { |
+ return true; |
+ }, |
+ configurable: true |
+ }); |
+ }; |
+ } |
+ var isIE = /Trident/.test(navigator.userAgent); |
+ if (!window.CustomEvent || isIE && typeof window.CustomEvent !== "function") { |
+ window.CustomEvent = function(inType, params) { |
+ params = params || {}; |
+ var e = document.createEvent("CustomEvent"); |
+ e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable), params.detail); |
+ return e; |
+ }; |
+ window.CustomEvent.prototype = window.Event.prototype; |
+ } |
+ if (!window.Event || isIE && typeof window.Event !== "function") { |
+ var origEvent = window.Event; |
+ window.Event = function(inType, params) { |
+ params = params || {}; |
+ var e = document.createEvent("Event"); |
+ e.initEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable)); |
+ return e; |
+ }; |
+ window.Event.prototype = origEvent.prototype; |
+ } |
+})(window.WebComponents); |
window.HTMLImports = window.HTMLImports || { |
flags: {} |
@@ -986,6 +1143,7 @@ window.HTMLImports = window.HTMLImports || { |
if (importCount) { |
for (var i = 0, imp; i < importCount && (imp = imports[i]); i++) { |
if (isImportLoaded(imp)) { |
+ newImports.push(this); |
parsedCount++; |
checkDone(); |
} else { |
@@ -1112,10 +1270,14 @@ window.HTMLImports.addModule(function(scope) { |
request.open("GET", url, xhr.async); |
request.addEventListener("readystatechange", function(e) { |
if (request.readyState === 4) { |
- var locationHeader = request.getResponseHeader("Location"); |
var redirectedUrl = null; |
- if (locationHeader) { |
- var redirectedUrl = locationHeader.substr(0, 1) === "/" ? location.origin + locationHeader : locationHeader; |
+ try { |
+ var locationHeader = request.getResponseHeader("Location"); |
+ if (locationHeader) { |
+ redirectedUrl = locationHeader.substr(0, 1) === "/" ? location.origin + locationHeader : locationHeader; |
+ } |
+ } catch (e) { |
+ console.error(e.message); |
} |
next.call(nextContext, !xhr.ok(request) && request, request.response || request.responseText, redirectedUrl); |
} |
@@ -1265,7 +1427,7 @@ window.HTMLImports.addModule(function(scope) { |
var IMPORT_SELECTOR = "link[rel=" + IMPORT_LINK_TYPE + "]"; |
var importParser = { |
documentSelectors: IMPORT_SELECTOR, |
- importsSelectors: [ IMPORT_SELECTOR, "link[rel=stylesheet]", "style", "script:not([type])", 'script[type="application/javascript"]', 'script[type="text/javascript"]' ].join(","), |
+ importsSelectors: [ IMPORT_SELECTOR, "link[rel=stylesheet]:not([type])", "style:not([type])", "script:not([type])", 'script[type="application/javascript"]', 'script[type="text/javascript"]' ].join(","), |
map: { |
link: "parseLink", |
script: "parseScript", |
@@ -1316,6 +1478,7 @@ window.HTMLImports.addModule(function(scope) { |
} |
}, |
parseImport: function(elt) { |
+ elt.import = elt.__doc; |
if (window.HTMLImports.__importsParsingHook) { |
window.HTMLImports.__importsParsingHook(elt); |
} |
@@ -1378,6 +1541,8 @@ window.HTMLImports.addModule(function(scope) { |
trackElement: function(elt, callback) { |
var self = this; |
var done = function(e) { |
+ elt.removeEventListener("load", done); |
+ elt.removeEventListener("error", done); |
if (callback) { |
callback(e); |
} |
@@ -1415,7 +1580,9 @@ window.HTMLImports.addModule(function(scope) { |
script.src = scriptElt.src ? scriptElt.src : generateScriptDataUrl(scriptElt); |
scope.currentScript = scriptElt; |
this.trackElement(script, function(e) { |
- script.parentNode.removeChild(script); |
+ if (script.parentNode) { |
+ script.parentNode.removeChild(script); |
+ } |
scope.currentScript = null; |
}); |
this.addElementToDocument(script); |
@@ -1431,7 +1598,7 @@ window.HTMLImports.addModule(function(scope) { |
for (var i = 0, l = nodes.length, p = 0, n; i < l && (n = nodes[i]); i++) { |
if (!this.isParsed(n)) { |
if (this.hasResource(n)) { |
- return nodeIsImport(n) ? this.nextToParseInDoc(n.import, n) : n; |
+ return nodeIsImport(n) ? this.nextToParseInDoc(n.__doc, n) : n; |
} else { |
return; |
} |
@@ -1454,7 +1621,7 @@ window.HTMLImports.addModule(function(scope) { |
return this.dynamicElements.indexOf(elt) >= 0; |
}, |
hasResource: function(node) { |
- if (nodeIsImport(node) && node.import === undefined) { |
+ if (nodeIsImport(node) && node.__doc === undefined) { |
return false; |
} |
return true; |
@@ -1528,7 +1695,7 @@ window.HTMLImports.addModule(function(scope) { |
} |
this.documents[url] = doc; |
} |
- elt.import = doc; |
+ elt.__doc = doc; |
} |
parser.parseNext(); |
}, |
@@ -1624,22 +1791,6 @@ window.HTMLImports.addModule(function(scope) { |
if (scope.useNative) { |
return; |
} |
- if (isIE && typeof window.CustomEvent !== "function") { |
- window.CustomEvent = function(inType, params) { |
- params = params || {}; |
- var e = document.createEvent("CustomEvent"); |
- e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable), params.detail); |
- e.preventDefault = function() { |
- Object.defineProperty(this, "defaultPrevented", { |
- get: function() { |
- return true; |
- } |
- }); |
- }; |
- return e; |
- }; |
- window.CustomEvent.prototype = window.Event.prototype; |
- } |
initializeModules(); |
var rootDocument = scope.rootDocument; |
function bootstrap() { |
@@ -1670,6 +1821,7 @@ window.CustomElements = window.CustomElements || { |
scope.addModule = addModule; |
scope.initializeModules = initializeModules; |
scope.hasNative = Boolean(document.registerElement); |
+ scope.isIE = /Trident/.test(navigator.userAgent); |
scope.useNative = !flags.register && scope.hasNative && !window.ShadowDOMPolyfill && (!window.HTMLImports || window.HTMLImports.useNative); |
})(window.CustomElements); |
@@ -1732,32 +1884,27 @@ window.CustomElements.addModule(function(scope) { |
var flags = scope.flags; |
var forSubtree = scope.forSubtree; |
var forDocumentTree = scope.forDocumentTree; |
- function addedNode(node) { |
- return added(node) || addedSubtree(node); |
+ function addedNode(node, isAttached) { |
+ return added(node, isAttached) || addedSubtree(node, isAttached); |
} |
- function added(node) { |
- if (scope.upgrade(node)) { |
+ function added(node, isAttached) { |
+ if (scope.upgrade(node, isAttached)) { |
return true; |
} |
- attached(node); |
+ if (isAttached) { |
+ attached(node); |
+ } |
} |
- function addedSubtree(node) { |
+ function addedSubtree(node, isAttached) { |
forSubtree(node, function(e) { |
- if (added(e)) { |
+ if (added(e, isAttached)) { |
return true; |
} |
}); |
} |
- function attachedNode(node) { |
- attached(node); |
- if (inDocument(node)) { |
- forSubtree(node, function(e) { |
- attached(e); |
- }); |
- } |
- } |
- var hasPolyfillMutations = !window.MutationObserver || window.MutationObserver === window.JsMutationObserver; |
- scope.hasPolyfillMutations = hasPolyfillMutations; |
+ var hasThrottledAttached = window.MutationObserver._isPolyfilled && flags["throttle-attached"]; |
+ scope.hasPolyfillMutations = hasThrottledAttached; |
+ scope.hasThrottledAttached = hasThrottledAttached; |
var isPendingMutations = false; |
var pendingMutations = []; |
function deferMutation(fn) { |
@@ -1776,7 +1923,7 @@ window.CustomElements.addModule(function(scope) { |
pendingMutations = []; |
} |
function attached(element) { |
- if (hasPolyfillMutations) { |
+ if (hasThrottledAttached) { |
deferMutation(function() { |
_attached(element); |
}); |
@@ -1785,12 +1932,10 @@ window.CustomElements.addModule(function(scope) { |
} |
} |
function _attached(element) { |
- if (element.__upgraded__ && (element.attachedCallback || element.detachedCallback)) { |
- if (!element.__attached && inDocument(element)) { |
- element.__attached = true; |
- if (element.attachedCallback) { |
- element.attachedCallback(); |
- } |
+ if (element.__upgraded__ && !element.__attached) { |
+ element.__attached = true; |
+ if (element.attachedCallback) { |
+ element.attachedCallback(); |
} |
} |
} |
@@ -1801,7 +1946,7 @@ window.CustomElements.addModule(function(scope) { |
}); |
} |
function detached(element) { |
- if (hasPolyfillMutations) { |
+ if (hasThrottledAttached) { |
deferMutation(function() { |
_detached(element); |
}); |
@@ -1810,18 +1955,16 @@ window.CustomElements.addModule(function(scope) { |
} |
} |
function _detached(element) { |
- if (element.__upgraded__ && (element.attachedCallback || element.detachedCallback)) { |
- if (element.__attached && !inDocument(element)) { |
- element.__attached = false; |
- if (element.detachedCallback) { |
- element.detachedCallback(); |
- } |
+ if (element.__upgraded__ && element.__attached) { |
+ element.__attached = false; |
+ if (element.detachedCallback) { |
+ element.detachedCallback(); |
} |
} |
} |
function inDocument(element) { |
var p = element; |
- var doc = wrap(document); |
+ var doc = window.wrap(document); |
while (p) { |
if (p == doc) { |
return true; |
@@ -1839,7 +1982,7 @@ window.CustomElements.addModule(function(scope) { |
} |
} |
} |
- function handler(mutations) { |
+ function handler(root, mutations) { |
if (flags.dom) { |
var mx = mutations[0]; |
if (mx && mx.type === "childList" && mx.addedNodes) { |
@@ -1854,13 +1997,14 @@ window.CustomElements.addModule(function(scope) { |
} |
console.group("mutations (%d) [%s]", mutations.length, u || ""); |
} |
+ var isAttached = inDocument(root); |
mutations.forEach(function(mx) { |
if (mx.type === "childList") { |
forEach(mx.addedNodes, function(n) { |
if (!n.localName) { |
return; |
} |
- addedNode(n); |
+ addedNode(n, isAttached); |
}); |
forEach(mx.removedNodes, function(n) { |
if (!n.localName) { |
@@ -1882,7 +2026,7 @@ window.CustomElements.addModule(function(scope) { |
} |
var observer = node.__observer; |
if (observer) { |
- handler(observer.takeRecords()); |
+ handler(node, observer.takeRecords()); |
takeMutations(); |
} |
} |
@@ -1891,7 +2035,7 @@ window.CustomElements.addModule(function(scope) { |
if (inRoot.__observer) { |
return; |
} |
- var observer = new MutationObserver(handler); |
+ var observer = new MutationObserver(handler.bind(this, inRoot)); |
observer.observe(inRoot, { |
childList: true, |
subtree: true |
@@ -1901,7 +2045,8 @@ window.CustomElements.addModule(function(scope) { |
function upgradeDocument(doc) { |
doc = window.wrap(doc); |
flags.dom && console.group("upgradeDocument: ", doc.baseURI.split("/").pop()); |
- addedNode(doc); |
+ var isMainDocument = doc === window.wrap(document); |
+ addedNode(doc, isMainDocument); |
observe(doc); |
flags.dom && console.groupEnd(); |
} |
@@ -1918,28 +2063,32 @@ window.CustomElements.addModule(function(scope) { |
} |
scope.watchShadow = watchShadow; |
scope.upgradeDocumentTree = upgradeDocumentTree; |
+ scope.upgradeDocument = upgradeDocument; |
scope.upgradeSubtree = addedSubtree; |
scope.upgradeAll = addedNode; |
- scope.attachedNode = attachedNode; |
+ scope.attached = attached; |
scope.takeRecords = takeRecords; |
}); |
window.CustomElements.addModule(function(scope) { |
var flags = scope.flags; |
- function upgrade(node) { |
+ function upgrade(node, isAttached) { |
+ if (node.localName === "template") { |
+ if (window.HTMLTemplateElement && HTMLTemplateElement.decorate) { |
+ HTMLTemplateElement.decorate(node); |
+ } |
+ } |
if (!node.__upgraded__ && node.nodeType === Node.ELEMENT_NODE) { |
var is = node.getAttribute("is"); |
- var definition = scope.getRegisteredDefinition(is || node.localName); |
+ var definition = scope.getRegisteredDefinition(node.localName) || scope.getRegisteredDefinition(is); |
if (definition) { |
- if (is && definition.tag == node.localName) { |
- return upgradeWithDefinition(node, definition); |
- } else if (!is && !definition.extends) { |
- return upgradeWithDefinition(node, definition); |
+ if (is && definition.tag == node.localName || !is && !definition.extends) { |
+ return upgradeWithDefinition(node, definition, isAttached); |
} |
} |
} |
} |
- function upgradeWithDefinition(element, definition) { |
+ function upgradeWithDefinition(element, definition, isAttached) { |
flags.upgrade && console.group("upgrade:", element.localName); |
if (definition.is) { |
element.setAttribute("is", definition.is); |
@@ -1947,8 +2096,10 @@ window.CustomElements.addModule(function(scope) { |
implementPrototype(element, definition); |
element.__upgraded__ = true; |
created(element); |
- scope.attachedNode(element); |
- scope.upgradeSubtree(element); |
+ if (isAttached) { |
+ scope.attached(element); |
+ } |
+ scope.upgradeSubtree(element, isAttached); |
flags.upgrade && console.groupEnd(); |
return element; |
} |
@@ -1985,7 +2136,7 @@ window.CustomElements.addModule(function(scope) { |
}); |
window.CustomElements.addModule(function(scope) { |
- var isIE11OrOlder = scope.isIE11OrOlder; |
+ var isIE = scope.isIE; |
var upgradeDocumentTree = scope.upgradeDocumentTree; |
var upgradeAll = scope.upgradeAll; |
var upgradeWithDefinition = scope.upgradeWithDefinition; |
@@ -2076,17 +2227,23 @@ window.CustomElements.addModule(function(scope) { |
var nativePrototype = HTMLElement.prototype; |
if (definition.is) { |
var inst = document.createElement(definition.tag); |
- var expectedPrototype = Object.getPrototypeOf(inst); |
- if (expectedPrototype === definition.prototype) { |
- nativePrototype = expectedPrototype; |
- } |
+ nativePrototype = Object.getPrototypeOf(inst); |
} |
var proto = definition.prototype, ancestor; |
- while (proto && proto !== nativePrototype) { |
+ var foundPrototype = false; |
+ while (proto) { |
+ if (proto == nativePrototype) { |
+ foundPrototype = true; |
+ } |
ancestor = Object.getPrototypeOf(proto); |
- proto.__proto__ = ancestor; |
+ if (ancestor) { |
+ proto.__proto__ = ancestor; |
+ } |
proto = ancestor; |
} |
+ if (!foundPrototype) { |
+ console.warn(definition.tag + " prototype not found in prototype chain for " + definition.is); |
+ } |
definition.native = nativePrototype; |
} |
} |
@@ -2148,6 +2305,9 @@ window.CustomElements.addModule(function(scope) { |
var isInstance; |
if (!Object.__proto__ && !useNative) { |
isInstance = function(obj, ctor) { |
+ if (obj instanceof ctor) { |
+ return true; |
+ } |
var p = obj; |
while (p) { |
if (p === ctor.prototype) { |
@@ -2172,7 +2332,7 @@ window.CustomElements.addModule(function(scope) { |
} |
wrapDomMethodToForceUpgrade(Node.prototype, "cloneNode"); |
wrapDomMethodToForceUpgrade(document, "importNode"); |
- if (isIE11OrOlder) { |
+ if (isIE) { |
(function() { |
var importNode = document.importNode; |
document.importNode = function() { |
@@ -2200,7 +2360,7 @@ window.CustomElements.addModule(function(scope) { |
(function(scope) { |
var useNative = scope.useNative; |
var initializeModules = scope.initializeModules; |
- var isIE11OrOlder = /Trident/.test(navigator.userAgent); |
+ var isIE = scope.isIE; |
if (useNative) { |
var nop = function() {}; |
scope.watchShadow = nop; |
@@ -2216,6 +2376,7 @@ window.CustomElements.addModule(function(scope) { |
initializeModules(); |
} |
var upgradeDocumentTree = scope.upgradeDocumentTree; |
+ var upgradeDocument = scope.upgradeDocument; |
if (!window.wrap) { |
if (window.ShadowDOMPolyfill) { |
window.wrap = window.ShadowDOMPolyfill.wrapIfNeeded; |
@@ -2226,39 +2387,30 @@ window.CustomElements.addModule(function(scope) { |
}; |
} |
} |
+ if (window.HTMLImports) { |
+ window.HTMLImports.__importsParsingHook = function(elt) { |
+ if (elt.import) { |
+ upgradeDocument(wrap(elt.import)); |
+ } |
+ }; |
+ } |
function bootstrap() { |
upgradeDocumentTree(window.wrap(document)); |
- if (window.HTMLImports) { |
- window.HTMLImports.__importsParsingHook = function(elt) { |
- upgradeDocumentTree(wrap(elt.import)); |
- }; |
- } |
window.CustomElements.ready = true; |
- setTimeout(function() { |
- window.CustomElements.readyTime = Date.now(); |
- if (window.HTMLImports) { |
- window.CustomElements.elapsed = window.CustomElements.readyTime - window.HTMLImports.readyTime; |
- } |
- document.dispatchEvent(new CustomEvent("WebComponentsReady", { |
- bubbles: true |
- })); |
- }); |
- } |
- if (isIE11OrOlder && typeof window.CustomEvent !== "function") { |
- window.CustomEvent = function(inType, params) { |
- params = params || {}; |
- var e = document.createEvent("CustomEvent"); |
- e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable), params.detail); |
- e.preventDefault = function() { |
- Object.defineProperty(this, "defaultPrevented", { |
- get: function() { |
- return true; |
- } |
- }); |
- }; |
- return e; |
+ var requestAnimationFrame = window.requestAnimationFrame || function(f) { |
+ setTimeout(f, 16); |
}; |
- window.CustomEvent.prototype = window.Event.prototype; |
+ requestAnimationFrame(function() { |
+ setTimeout(function() { |
+ window.CustomElements.readyTime = Date.now(); |
+ if (window.HTMLImports) { |
+ window.CustomElements.elapsed = window.CustomElements.readyTime - window.HTMLImports.readyTime; |
+ } |
+ document.dispatchEvent(new CustomEvent("WebComponentsReady", { |
+ bubbles: true |
+ })); |
+ }); |
+ }); |
} |
if (document.readyState === "complete" || scope.flags.eager) { |
bootstrap(); |
@@ -2268,44 +2420,8 @@ window.CustomElements.addModule(function(scope) { |
var loadEvent = window.HTMLImports && !window.HTMLImports.ready ? "HTMLImportsLoaded" : "DOMContentLoaded"; |
window.addEventListener(loadEvent, bootstrap); |
} |
- scope.isIE11OrOlder = isIE11OrOlder; |
})(window.CustomElements); |
-if (typeof HTMLTemplateElement === "undefined") { |
- (function() { |
- var TEMPLATE_TAG = "template"; |
- HTMLTemplateElement = function() {}; |
- HTMLTemplateElement.prototype = Object.create(HTMLElement.prototype); |
- HTMLTemplateElement.decorate = function(template) { |
- if (!template.content) { |
- template.content = template.ownerDocument.createDocumentFragment(); |
- } |
- var child; |
- while (child = template.firstChild) { |
- template.content.appendChild(child); |
- } |
- }; |
- HTMLTemplateElement.bootstrap = function(doc) { |
- var templates = doc.querySelectorAll(TEMPLATE_TAG); |
- for (var i = 0, l = templates.length, t; i < l && (t = templates[i]); i++) { |
- HTMLTemplateElement.decorate(t); |
- } |
- }; |
- window.addEventListener("DOMContentLoaded", function() { |
- HTMLTemplateElement.bootstrap(document); |
- }); |
- var createElement = document.createElement; |
- document.createElement = function() { |
- "use strict"; |
- var el = createElement.apply(document, arguments); |
- if (el.localName == "template") { |
- HTMLTemplateElement.decorate(el); |
- } |
- return el; |
- }; |
- })(); |
-} |
- |
(function(scope) { |
var style = document.createElement("style"); |
style.textContent = "" + "body {" + "transition: opacity ease-in 0.2s;" + " } \n" + "body[unresolved] {" + "opacity: 0; display: block; overflow: hidden; position: relative;" + " } \n"; |