Index: polymer_1.0.4/bower_components/webcomponentsjs/webcomponents-lite.js |
diff --git a/polymer_0.5.4/bower_components/webcomponentsjs/webcomponents-lite.js b/polymer_1.0.4/bower_components/webcomponentsjs/webcomponents-lite.js |
similarity index 69% |
copy from polymer_0.5.4/bower_components/webcomponentsjs/webcomponents-lite.js |
copy to polymer_1.0.4/bower_components/webcomponentsjs/webcomponents-lite.js |
index fb2c8f75902a04b485bb23e700e5a9ee7d025d5b..47a7d9ded8a66429e1e3072ff91b59388b1fb80b 100644 |
--- a/polymer_0.5.4/bower_components/webcomponentsjs/webcomponents-lite.js |
+++ b/polymer_1.0.4/bower_components/webcomponentsjs/webcomponents-lite.js |
@@ -7,17 +7,20 @@ |
* 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.5.4 |
+// @version 0.7.5 |
window.WebComponents = window.WebComponents || {}; |
(function(scope) { |
var flags = scope.flags || {}; |
- var file = "webcomponents.js"; |
+ var file = "webcomponents-lite.js"; |
var script = document.querySelector('script[src*="' + file + '"]'); |
if (!flags.noOpts) { |
- location.search.slice(1).split("&").forEach(function(o) { |
- o = o.split("="); |
- o[0] && (flags[o[0]] = o[1] || true); |
+ location.search.slice(1).split("&").forEach(function(option) { |
+ var parts = option.split("="); |
+ var match; |
+ if (parts[0] && (match = parts[0].match(/wc-(.+)/))) { |
+ flags[match[1]] = parts[1] || true; |
+ } |
}); |
if (script) { |
for (var i = 0, a; a = script.attributes[i]; i++) { |
@@ -49,7 +52,529 @@ window.WebComponents = window.WebComponents || {}; |
window.CustomElements.flags.register = flags.register; |
} |
scope.flags = flags; |
-})(WebComponents); |
+})(window.WebComponents); |
+ |
+(function(scope) { |
+ "use strict"; |
+ var hasWorkingUrl = false; |
+ if (!scope.forceJURL) { |
+ try { |
+ var u = new URL("b", "http://a"); |
+ u.pathname = "c%20d"; |
+ hasWorkingUrl = u.href === "http://a/c%20d"; |
+ } catch (e) {} |
+ } |
+ if (hasWorkingUrl) return; |
+ var relative = Object.create(null); |
+ relative["ftp"] = 21; |
+ relative["file"] = 0; |
+ relative["gopher"] = 70; |
+ relative["http"] = 80; |
+ relative["https"] = 443; |
+ relative["ws"] = 80; |
+ relative["wss"] = 443; |
+ var relativePathDotMapping = Object.create(null); |
+ relativePathDotMapping["%2e"] = "."; |
+ relativePathDotMapping[".%2e"] = ".."; |
+ relativePathDotMapping["%2e."] = ".."; |
+ relativePathDotMapping["%2e%2e"] = ".."; |
+ function isRelativeScheme(scheme) { |
+ return relative[scheme] !== undefined; |
+ } |
+ function invalid() { |
+ clear.call(this); |
+ this._isInvalid = true; |
+ } |
+ function IDNAToASCII(h) { |
+ if ("" == h) { |
+ invalid.call(this); |
+ } |
+ return h.toLowerCase(); |
+ } |
+ function percentEscape(c) { |
+ var unicode = c.charCodeAt(0); |
+ if (unicode > 32 && unicode < 127 && [ 34, 35, 60, 62, 63, 96 ].indexOf(unicode) == -1) { |
+ return c; |
+ } |
+ return encodeURIComponent(c); |
+ } |
+ function percentEscapeQuery(c) { |
+ var unicode = c.charCodeAt(0); |
+ if (unicode > 32 && unicode < 127 && [ 34, 35, 60, 62, 96 ].indexOf(unicode) == -1) { |
+ return c; |
+ } |
+ return encodeURIComponent(c); |
+ } |
+ var EOF = undefined, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/; |
+ function parse(input, stateOverride, base) { |
+ function err(message) { |
+ errors.push(message); |
+ } |
+ var state = stateOverride || "scheme start", cursor = 0, buffer = "", seenAt = false, seenBracket = false, errors = []; |
+ loop: while ((input[cursor - 1] != EOF || cursor == 0) && !this._isInvalid) { |
+ var c = input[cursor]; |
+ switch (state) { |
+ case "scheme start": |
+ if (c && ALPHA.test(c)) { |
+ buffer += c.toLowerCase(); |
+ state = "scheme"; |
+ } else if (!stateOverride) { |
+ buffer = ""; |
+ state = "no scheme"; |
+ continue; |
+ } else { |
+ err("Invalid scheme."); |
+ break loop; |
+ } |
+ break; |
+ |
+ case "scheme": |
+ if (c && ALPHANUMERIC.test(c)) { |
+ buffer += c.toLowerCase(); |
+ } else if (":" == c) { |
+ this._scheme = buffer; |
+ buffer = ""; |
+ if (stateOverride) { |
+ break loop; |
+ } |
+ if (isRelativeScheme(this._scheme)) { |
+ this._isRelative = true; |
+ } |
+ if ("file" == this._scheme) { |
+ state = "relative"; |
+ } else if (this._isRelative && base && base._scheme == this._scheme) { |
+ state = "relative or authority"; |
+ } else if (this._isRelative) { |
+ state = "authority first slash"; |
+ } else { |
+ state = "scheme data"; |
+ } |
+ } else if (!stateOverride) { |
+ buffer = ""; |
+ cursor = 0; |
+ state = "no scheme"; |
+ continue; |
+ } else if (EOF == c) { |
+ break loop; |
+ } else { |
+ err("Code point not allowed in scheme: " + c); |
+ break loop; |
+ } |
+ break; |
+ |
+ case "scheme data": |
+ if ("?" == c) { |
+ this._query = "?"; |
+ state = "query"; |
+ } else if ("#" == c) { |
+ this._fragment = "#"; |
+ state = "fragment"; |
+ } else { |
+ if (EOF != c && " " != c && "\n" != c && "\r" != c) { |
+ this._schemeData += percentEscape(c); |
+ } |
+ } |
+ break; |
+ |
+ case "no scheme": |
+ if (!base || !isRelativeScheme(base._scheme)) { |
+ err("Missing scheme."); |
+ invalid.call(this); |
+ } else { |
+ state = "relative"; |
+ continue; |
+ } |
+ break; |
+ |
+ case "relative or authority": |
+ if ("/" == c && "/" == input[cursor + 1]) { |
+ state = "authority ignore slashes"; |
+ } else { |
+ err("Expected /, got: " + c); |
+ state = "relative"; |
+ continue; |
+ } |
+ break; |
+ |
+ case "relative": |
+ this._isRelative = true; |
+ if ("file" != this._scheme) this._scheme = base._scheme; |
+ if (EOF == c) { |
+ this._host = base._host; |
+ this._port = base._port; |
+ this._path = base._path.slice(); |
+ this._query = base._query; |
+ this._username = base._username; |
+ this._password = base._password; |
+ break loop; |
+ } else if ("/" == c || "\\" == c) { |
+ if ("\\" == c) err("\\ is an invalid code point."); |
+ state = "relative slash"; |
+ } else if ("?" == c) { |
+ this._host = base._host; |
+ this._port = base._port; |
+ this._path = base._path.slice(); |
+ this._query = "?"; |
+ this._username = base._username; |
+ this._password = base._password; |
+ state = "query"; |
+ } else if ("#" == c) { |
+ this._host = base._host; |
+ this._port = base._port; |
+ this._path = base._path.slice(); |
+ this._query = base._query; |
+ this._fragment = "#"; |
+ this._username = base._username; |
+ this._password = base._password; |
+ state = "fragment"; |
+ } else { |
+ var nextC = input[cursor + 1]; |
+ var nextNextC = input[cursor + 2]; |
+ if ("file" != this._scheme || !ALPHA.test(c) || nextC != ":" && nextC != "|" || EOF != nextNextC && "/" != nextNextC && "\\" != nextNextC && "?" != nextNextC && "#" != nextNextC) { |
+ this._host = base._host; |
+ this._port = base._port; |
+ this._username = base._username; |
+ this._password = base._password; |
+ this._path = base._path.slice(); |
+ this._path.pop(); |
+ } |
+ state = "relative path"; |
+ continue; |
+ } |
+ break; |
+ |
+ case "relative slash": |
+ if ("/" == c || "\\" == c) { |
+ if ("\\" == c) { |
+ err("\\ is an invalid code point."); |
+ } |
+ if ("file" == this._scheme) { |
+ state = "file host"; |
+ } else { |
+ state = "authority ignore slashes"; |
+ } |
+ } else { |
+ if ("file" != this._scheme) { |
+ this._host = base._host; |
+ this._port = base._port; |
+ this._username = base._username; |
+ this._password = base._password; |
+ } |
+ state = "relative path"; |
+ continue; |
+ } |
+ break; |
+ |
+ case "authority first slash": |
+ if ("/" == c) { |
+ state = "authority second slash"; |
+ } else { |
+ err("Expected '/', got: " + c); |
+ state = "authority ignore slashes"; |
+ continue; |
+ } |
+ break; |
+ |
+ case "authority second slash": |
+ state = "authority ignore slashes"; |
+ if ("/" != c) { |
+ err("Expected '/', got: " + c); |
+ continue; |
+ } |
+ break; |
+ |
+ case "authority ignore slashes": |
+ if ("/" != c && "\\" != c) { |
+ state = "authority"; |
+ continue; |
+ } else { |
+ err("Expected authority, got: " + c); |
+ } |
+ break; |
+ |
+ case "authority": |
+ if ("@" == c) { |
+ if (seenAt) { |
+ err("@ already seen."); |
+ buffer += "%40"; |
+ } |
+ seenAt = true; |
+ for (var i = 0; i < buffer.length; i++) { |
+ var cp = buffer[i]; |
+ if (" " == cp || "\n" == cp || "\r" == cp) { |
+ err("Invalid whitespace in authority."); |
+ continue; |
+ } |
+ if (":" == cp && null === this._password) { |
+ this._password = ""; |
+ continue; |
+ } |
+ var tempC = percentEscape(cp); |
+ null !== this._password ? this._password += tempC : this._username += tempC; |
+ } |
+ buffer = ""; |
+ } else if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c) { |
+ cursor -= buffer.length; |
+ buffer = ""; |
+ state = "host"; |
+ continue; |
+ } else { |
+ buffer += c; |
+ } |
+ break; |
+ |
+ case "file host": |
+ if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c) { |
+ if (buffer.length == 2 && ALPHA.test(buffer[0]) && (buffer[1] == ":" || buffer[1] == "|")) { |
+ state = "relative path"; |
+ } else if (buffer.length == 0) { |
+ state = "relative path start"; |
+ } else { |
+ this._host = IDNAToASCII.call(this, buffer); |
+ buffer = ""; |
+ state = "relative path start"; |
+ } |
+ continue; |
+ } else if (" " == c || "\n" == c || "\r" == c) { |
+ err("Invalid whitespace in file host."); |
+ } else { |
+ buffer += c; |
+ } |
+ break; |
+ |
+ case "host": |
+ case "hostname": |
+ if (":" == c && !seenBracket) { |
+ this._host = IDNAToASCII.call(this, buffer); |
+ buffer = ""; |
+ state = "port"; |
+ if ("hostname" == stateOverride) { |
+ break loop; |
+ } |
+ } else if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c) { |
+ this._host = IDNAToASCII.call(this, buffer); |
+ buffer = ""; |
+ state = "relative path start"; |
+ if (stateOverride) { |
+ break loop; |
+ } |
+ continue; |
+ } else if (" " != c && "\n" != c && "\r" != c) { |
+ if ("[" == c) { |
+ seenBracket = true; |
+ } else if ("]" == c) { |
+ seenBracket = false; |
+ } |
+ buffer += c; |
+ } else { |
+ err("Invalid code point in host/hostname: " + c); |
+ } |
+ break; |
+ |
+ case "port": |
+ if (/[0-9]/.test(c)) { |
+ buffer += c; |
+ } else if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c || stateOverride) { |
+ if ("" != buffer) { |
+ var temp = parseInt(buffer, 10); |
+ if (temp != relative[this._scheme]) { |
+ this._port = temp + ""; |
+ } |
+ buffer = ""; |
+ } |
+ if (stateOverride) { |
+ break loop; |
+ } |
+ state = "relative path start"; |
+ continue; |
+ } else if (" " == c || "\n" == c || "\r" == c) { |
+ err("Invalid code point in port: " + c); |
+ } else { |
+ invalid.call(this); |
+ } |
+ break; |
+ |
+ case "relative path start": |
+ if ("\\" == c) err("'\\' not allowed in path."); |
+ state = "relative path"; |
+ if ("/" != c && "\\" != c) { |
+ continue; |
+ } |
+ break; |
+ |
+ case "relative path": |
+ if (EOF == c || "/" == c || "\\" == c || !stateOverride && ("?" == c || "#" == c)) { |
+ if ("\\" == c) { |
+ err("\\ not allowed in relative path."); |
+ } |
+ var tmp; |
+ if (tmp = relativePathDotMapping[buffer.toLowerCase()]) { |
+ buffer = tmp; |
+ } |
+ if (".." == buffer) { |
+ this._path.pop(); |
+ if ("/" != c && "\\" != c) { |
+ this._path.push(""); |
+ } |
+ } else if ("." == buffer && "/" != c && "\\" != c) { |
+ this._path.push(""); |
+ } else if ("." != buffer) { |
+ if ("file" == this._scheme && this._path.length == 0 && buffer.length == 2 && ALPHA.test(buffer[0]) && buffer[1] == "|") { |
+ buffer = buffer[0] + ":"; |
+ } |
+ this._path.push(buffer); |
+ } |
+ buffer = ""; |
+ if ("?" == c) { |
+ this._query = "?"; |
+ state = "query"; |
+ } else if ("#" == c) { |
+ this._fragment = "#"; |
+ state = "fragment"; |
+ } |
+ } else if (" " != c && "\n" != c && "\r" != c) { |
+ buffer += percentEscape(c); |
+ } |
+ break; |
+ |
+ case "query": |
+ if (!stateOverride && "#" == c) { |
+ this._fragment = "#"; |
+ state = "fragment"; |
+ } else if (EOF != c && " " != c && "\n" != c && "\r" != c) { |
+ this._query += percentEscapeQuery(c); |
+ } |
+ break; |
+ |
+ case "fragment": |
+ if (EOF != c && " " != c && "\n" != c && "\r" != c) { |
+ this._fragment += c; |
+ } |
+ break; |
+ } |
+ cursor++; |
+ } |
+ } |
+ function clear() { |
+ this._scheme = ""; |
+ this._schemeData = ""; |
+ this._username = ""; |
+ this._password = null; |
+ this._host = ""; |
+ this._port = ""; |
+ this._path = []; |
+ this._query = ""; |
+ this._fragment = ""; |
+ this._isInvalid = false; |
+ this._isRelative = false; |
+ } |
+ function jURL(url, base) { |
+ if (base !== undefined && !(base instanceof jURL)) base = new jURL(String(base)); |
+ this._url = url; |
+ clear.call(this); |
+ var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, ""); |
+ parse.call(this, input, null, base); |
+ } |
+ jURL.prototype = { |
+ toString: function() { |
+ return this.href; |
+ }, |
+ get href() { |
+ if (this._isInvalid) return this._url; |
+ var authority = ""; |
+ if ("" != this._username || null != this._password) { |
+ authority = this._username + (null != this._password ? ":" + this._password : "") + "@"; |
+ } |
+ return this.protocol + (this._isRelative ? "//" + authority + this.host : "") + this.pathname + this._query + this._fragment; |
+ }, |
+ set href(href) { |
+ clear.call(this); |
+ parse.call(this, href); |
+ }, |
+ get protocol() { |
+ return this._scheme + ":"; |
+ }, |
+ set protocol(protocol) { |
+ if (this._isInvalid) return; |
+ parse.call(this, protocol + ":", "scheme start"); |
+ }, |
+ get host() { |
+ return this._isInvalid ? "" : this._port ? this._host + ":" + this._port : this._host; |
+ }, |
+ set host(host) { |
+ if (this._isInvalid || !this._isRelative) return; |
+ parse.call(this, host, "host"); |
+ }, |
+ get hostname() { |
+ return this._host; |
+ }, |
+ set hostname(hostname) { |
+ if (this._isInvalid || !this._isRelative) return; |
+ parse.call(this, hostname, "hostname"); |
+ }, |
+ get port() { |
+ return this._port; |
+ }, |
+ set port(port) { |
+ if (this._isInvalid || !this._isRelative) return; |
+ parse.call(this, port, "port"); |
+ }, |
+ get pathname() { |
+ return this._isInvalid ? "" : this._isRelative ? "/" + this._path.join("/") : this._schemeData; |
+ }, |
+ set pathname(pathname) { |
+ if (this._isInvalid || !this._isRelative) return; |
+ this._path = []; |
+ parse.call(this, pathname, "relative path start"); |
+ }, |
+ get search() { |
+ return this._isInvalid || !this._query || "?" == this._query ? "" : this._query; |
+ }, |
+ set search(search) { |
+ if (this._isInvalid || !this._isRelative) return; |
+ this._query = "?"; |
+ if ("?" == search[0]) search = search.slice(1); |
+ parse.call(this, search, "query"); |
+ }, |
+ get hash() { |
+ return this._isInvalid || !this._fragment || "#" == this._fragment ? "" : this._fragment; |
+ }, |
+ set hash(hash) { |
+ if (this._isInvalid) return; |
+ this._fragment = "#"; |
+ if ("#" == hash[0]) hash = hash.slice(1); |
+ parse.call(this, hash, "fragment"); |
+ }, |
+ get origin() { |
+ var host; |
+ if (this._isInvalid || !this._scheme) { |
+ return ""; |
+ } |
+ switch (this._scheme) { |
+ case "data": |
+ case "file": |
+ case "javascript": |
+ case "mailto": |
+ return "null"; |
+ } |
+ host = this.host; |
+ if (!host) { |
+ return ""; |
+ } |
+ return this._scheme + "://" + host; |
+ } |
+ }; |
+ var OriginalURL = scope.URL; |
+ if (OriginalURL) { |
+ jURL.createObjectURL = function(blob) { |
+ return OriginalURL.createObjectURL.apply(OriginalURL, arguments); |
+ }; |
+ jURL.revokeObjectURL = function(url) { |
+ OriginalURL.revokeObjectURL(url); |
+ }; |
+ } |
+ scope.URL = jURL; |
+})(this); |
if (typeof WeakMap === "undefined") { |
(function() { |
@@ -358,7 +883,6 @@ if (typeof WeakMap === "undefined") { |
this.addTransientObserver(e.target); |
case "DOMNodeInserted": |
- var target = e.relatedNode; |
var changedNode = e.target; |
var addedNodes, removedNodes; |
if (e.type === "DOMNodeInserted") { |
@@ -370,12 +894,12 @@ if (typeof WeakMap === "undefined") { |
} |
var previousSibling = changedNode.previousSibling; |
var nextSibling = changedNode.nextSibling; |
- var record = getRecord("childList", target); |
+ var record = getRecord("childList", e.target.parentNode); |
record.addedNodes = addedNodes; |
record.removedNodes = removedNodes; |
record.previousSibling = previousSibling; |
record.nextSibling = nextSibling; |
- forEachAncestorAndObserverEnqueueRecord(target, function(options) { |
+ forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function(options) { |
if (!options.childList) return; |
return record; |
}); |
@@ -396,19 +920,19 @@ window.HTMLImports = window.HTMLImports || { |
var useNative = Boolean(IMPORT_LINK_TYPE in document.createElement("link")); |
var hasShadowDOMPolyfill = Boolean(window.ShadowDOMPolyfill); |
var wrap = function(node) { |
- return hasShadowDOMPolyfill ? ShadowDOMPolyfill.wrapIfNeeded(node) : node; |
+ return hasShadowDOMPolyfill ? window.ShadowDOMPolyfill.wrapIfNeeded(node) : node; |
}; |
var rootDocument = wrap(document); |
var currentScriptDescriptor = { |
get: function() { |
- var script = HTMLImports.currentScript || document.currentScript || (document.readyState !== "complete" ? document.scripts[document.scripts.length - 1] : null); |
+ var script = window.HTMLImports.currentScript || document.currentScript || (document.readyState !== "complete" ? document.scripts[document.scripts.length - 1] : null); |
return wrap(script); |
}, |
configurable: true |
}; |
Object.defineProperty(document, "_currentScript", currentScriptDescriptor); |
Object.defineProperty(rootDocument, "_currentScript", currentScriptDescriptor); |
- var isIE = /Trident|Edge/.test(navigator.userAgent); |
+ var isIE = /Trident/.test(navigator.userAgent); |
function whenReady(callback, doc) { |
doc = doc || rootDocument; |
whenDocumentReady(function() { |
@@ -438,26 +962,35 @@ window.HTMLImports = window.HTMLImports || { |
} |
function watchImportsLoad(callback, doc) { |
var imports = doc.querySelectorAll("link[rel=import]"); |
- var loaded = 0, l = imports.length; |
- function checkDone(d) { |
- if (loaded == l && callback) { |
- callback(); |
+ var parsedCount = 0, importCount = imports.length, newImports = [], errorImports = []; |
+ function checkDone() { |
+ if (parsedCount == importCount && callback) { |
+ callback({ |
+ allImports: imports, |
+ loadedImports: newImports, |
+ errorImports: errorImports |
+ }); |
} |
} |
function loadedImport(e) { |
markTargetLoaded(e); |
- loaded++; |
+ newImports.push(this); |
+ parsedCount++; |
checkDone(); |
} |
- if (l) { |
- for (var i = 0, imp; i < l && (imp = imports[i]); i++) { |
+ function errorLoadingImport(e) { |
+ errorImports.push(this); |
+ parsedCount++; |
+ checkDone(); |
+ } |
+ if (importCount) { |
+ for (var i = 0, imp; i < importCount && (imp = imports[i]); i++) { |
if (isImportLoaded(imp)) { |
- loadedImport.call(imp, { |
- target: imp |
- }); |
+ parsedCount++; |
+ checkDone(); |
} else { |
imp.addEventListener("load", loadedImport); |
- imp.addEventListener("error", loadedImport); |
+ imp.addEventListener("error", errorLoadingImport); |
} |
} |
} else { |
@@ -507,11 +1040,11 @@ window.HTMLImports = window.HTMLImports || { |
} |
})(); |
} |
- whenReady(function() { |
- HTMLImports.ready = true; |
- HTMLImports.readyTime = new Date().getTime(); |
+ whenReady(function(detail) { |
+ window.HTMLImports.ready = true; |
+ window.HTMLImports.readyTime = new Date().getTime(); |
var evt = rootDocument.createEvent("CustomEvent"); |
- evt.initCustomEvent("HTMLImportsLoaded", true, true, {}); |
+ evt.initCustomEvent("HTMLImportsLoaded", true, true, detail); |
rootDocument.dispatchEvent(evt); |
}); |
scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE; |
@@ -519,7 +1052,7 @@ window.HTMLImports = window.HTMLImports || { |
scope.rootDocument = rootDocument; |
scope.whenReady = whenReady; |
scope.isIE = isIE; |
-})(HTMLImports); |
+})(window.HTMLImports); |
(function(scope) { |
var modules = []; |
@@ -533,26 +1066,29 @@ window.HTMLImports = window.HTMLImports || { |
}; |
scope.addModule = addModule; |
scope.initializeModules = initializeModules; |
-})(HTMLImports); |
+})(window.HTMLImports); |
-HTMLImports.addModule(function(scope) { |
+window.HTMLImports.addModule(function(scope) { |
var CSS_URL_REGEXP = /(url\()([^)]*)(\))/g; |
var CSS_IMPORT_REGEXP = /(@import[\s]+(?!url\())([^;]*)(;)/g; |
var path = { |
- resolveUrlsInStyle: function(style) { |
+ resolveUrlsInStyle: function(style, linkUrl) { |
var doc = style.ownerDocument; |
var resolver = doc.createElement("a"); |
- style.textContent = this.resolveUrlsInCssText(style.textContent, resolver); |
+ style.textContent = this.resolveUrlsInCssText(style.textContent, linkUrl, resolver); |
return style; |
}, |
- resolveUrlsInCssText: function(cssText, urlObj) { |
- var r = this.replaceUrls(cssText, urlObj, CSS_URL_REGEXP); |
- r = this.replaceUrls(r, urlObj, CSS_IMPORT_REGEXP); |
+ resolveUrlsInCssText: function(cssText, linkUrl, urlObj) { |
+ var r = this.replaceUrls(cssText, urlObj, linkUrl, CSS_URL_REGEXP); |
+ r = this.replaceUrls(r, urlObj, linkUrl, CSS_IMPORT_REGEXP); |
return r; |
}, |
- replaceUrls: function(text, urlObj, regexp) { |
+ replaceUrls: function(text, urlObj, linkUrl, regexp) { |
return text.replace(regexp, function(m, pre, url, post) { |
var urlPath = url.replace(/["']/g, ""); |
+ if (linkUrl) { |
+ urlPath = new URL(urlPath, linkUrl).href; |
+ } |
urlObj.href = urlPath; |
urlPath = urlObj.href; |
return pre + "'" + urlPath + "'" + post; |
@@ -562,7 +1098,7 @@ HTMLImports.addModule(function(scope) { |
scope.path = path; |
}); |
-HTMLImports.addModule(function(scope) { |
+window.HTMLImports.addModule(function(scope) { |
var xhr = { |
async: true, |
ok: function(request) { |
@@ -594,7 +1130,7 @@ HTMLImports.addModule(function(scope) { |
scope.xhr = xhr; |
}); |
-HTMLImports.addModule(function(scope) { |
+window.HTMLImports.addModule(function(scope) { |
var xhr = scope.xhr; |
var flags = scope.flags; |
var Loader = function(onLoad, onComplete) { |
@@ -687,7 +1223,7 @@ HTMLImports.addModule(function(scope) { |
scope.Loader = Loader; |
}); |
-HTMLImports.addModule(function(scope) { |
+window.HTMLImports.addModule(function(scope) { |
var Observer = function(addCallback) { |
this.addCallback = addCallback; |
this.mo = new MutationObserver(this.handler.bind(this)); |
@@ -720,7 +1256,7 @@ HTMLImports.addModule(function(scope) { |
scope.Observer = Observer; |
}); |
-HTMLImports.addModule(function(scope) { |
+window.HTMLImports.addModule(function(scope) { |
var path = scope.path; |
var rootDocument = scope.rootDocument; |
var flags = scope.flags; |
@@ -729,7 +1265,7 @@ 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="text/javascript"]' ].join(","), |
+ importsSelectors: [ IMPORT_SELECTOR, "link[rel=stylesheet]", "style", "script:not([type])", 'script[type="application/javascript"]', 'script[type="text/javascript"]' ].join(","), |
map: { |
link: "parseLink", |
script: "parseScript", |
@@ -780,8 +1316,8 @@ HTMLImports.addModule(function(scope) { |
} |
}, |
parseImport: function(elt) { |
- if (HTMLImports.__importsParsingHook) { |
- HTMLImports.__importsParsingHook(elt); |
+ if (window.HTMLImports.__importsParsingHook) { |
+ window.HTMLImports.__importsParsingHook(elt); |
} |
if (elt.import) { |
elt.import.__importParsed = true; |
@@ -820,6 +1356,7 @@ HTMLImports.addModule(function(scope) { |
parseStyle: function(elt) { |
var src = elt; |
elt = cloneStyle(elt); |
+ src.__appliedElement = elt; |
elt.__importElement = src; |
this.parseGeneric(elt); |
}, |
@@ -864,9 +1401,11 @@ HTMLImports.addModule(function(scope) { |
} |
} |
if (fakeLoad) { |
- elt.dispatchEvent(new CustomEvent("load", { |
- bubbles: false |
- })); |
+ setTimeout(function() { |
+ elt.dispatchEvent(new CustomEvent("load", { |
+ bubbles: false |
+ })); |
+ }); |
} |
} |
}, |
@@ -949,7 +1488,7 @@ HTMLImports.addModule(function(scope) { |
scope.IMPORT_SELECTOR = IMPORT_SELECTOR; |
}); |
-HTMLImports.addModule(function(scope) { |
+window.HTMLImports.addModule(function(scope) { |
var flags = scope.flags; |
var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE; |
var IMPORT_SELECTOR = scope.IMPORT_SELECTOR; |
@@ -1010,12 +1549,15 @@ HTMLImports.addModule(function(scope) { |
function isLinkRel(elt, rel) { |
return elt.localName === "link" && elt.getAttribute("rel") === rel; |
} |
+ function hasBaseURIAccessor(doc) { |
+ return !!Object.getOwnPropertyDescriptor(doc, "baseURI"); |
+ } |
function makeDocument(resource, url) { |
var doc = document.implementation.createHTMLDocument(IMPORT_LINK_TYPE); |
doc._URL = url; |
var base = doc.createElement("base"); |
base.setAttribute("href", url); |
- if (!doc.baseURI) { |
+ if (!doc.baseURI && !hasBaseURIAccessor(doc)) { |
Object.defineProperty(doc, "baseURI", { |
value: url |
}); |
@@ -1045,7 +1587,7 @@ HTMLImports.addModule(function(scope) { |
scope.importLoader = importLoader; |
}); |
-HTMLImports.addModule(function(scope) { |
+window.HTMLImports.addModule(function(scope) { |
var parser = scope.parser; |
var importer = scope.importer; |
var dynamic = { |
@@ -1087,6 +1629,13 @@ HTMLImports.addModule(function(scope) { |
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; |
@@ -1094,14 +1643,14 @@ HTMLImports.addModule(function(scope) { |
initializeModules(); |
var rootDocument = scope.rootDocument; |
function bootstrap() { |
- HTMLImports.importer.bootDocument(rootDocument); |
+ window.HTMLImports.importer.bootDocument(rootDocument); |
} |
if (document.readyState === "complete" || document.readyState === "interactive" && !window.attachEvent) { |
bootstrap(); |
} else { |
document.addEventListener("DOMContentLoaded", bootstrap); |
} |
-})(HTMLImports); |
+})(window.HTMLImports); |
window.CustomElements = window.CustomElements || { |
flags: {} |
@@ -1121,11 +1670,11 @@ window.CustomElements = window.CustomElements || { |
scope.addModule = addModule; |
scope.initializeModules = initializeModules; |
scope.hasNative = Boolean(document.registerElement); |
- scope.useNative = !flags.register && scope.hasNative && !window.ShadowDOMPolyfill && (!window.HTMLImports || HTMLImports.useNative); |
-})(CustomElements); |
+ scope.useNative = !flags.register && scope.hasNative && !window.ShadowDOMPolyfill && (!window.HTMLImports || window.HTMLImports.useNative); |
+})(window.CustomElements); |
-CustomElements.addModule(function(scope) { |
- var IMPORT_LINK_TYPE = window.HTMLImports ? HTMLImports.IMPORT_LINK_TYPE : "none"; |
+window.CustomElements.addModule(function(scope) { |
+ var IMPORT_LINK_TYPE = window.HTMLImports ? window.HTMLImports.IMPORT_LINK_TYPE : "none"; |
function forSubtree(node, cb) { |
findAllElements(node, function(e) { |
if (cb(e)) { |
@@ -1158,14 +1707,11 @@ CustomElements.addModule(function(scope) { |
root = root.olderShadowRoot; |
} |
} |
- var processingDocuments; |
function forDocumentTree(doc, cb) { |
- processingDocuments = []; |
- _forDocumentTree(doc, cb); |
- processingDocuments = null; |
+ _forDocumentTree(doc, cb, []); |
} |
- function _forDocumentTree(doc, cb) { |
- doc = wrap(doc); |
+ function _forDocumentTree(doc, cb, processingDocuments) { |
+ doc = window.wrap(doc); |
if (processingDocuments.indexOf(doc) >= 0) { |
return; |
} |
@@ -1173,7 +1719,7 @@ CustomElements.addModule(function(scope) { |
var imports = doc.querySelectorAll("link[rel=" + IMPORT_LINK_TYPE + "]"); |
for (var i = 0, l = imports.length, n; i < l && (n = imports[i]); i++) { |
if (n.import) { |
- _forDocumentTree(n.import, cb); |
+ _forDocumentTree(n.import, cb, processingDocuments); |
} |
} |
cb(doc); |
@@ -1182,7 +1728,7 @@ CustomElements.addModule(function(scope) { |
scope.forSubtree = forSubtree; |
}); |
-CustomElements.addModule(function(scope) { |
+window.CustomElements.addModule(function(scope) { |
var flags = scope.flags; |
var forSubtree = scope.forSubtree; |
var forDocumentTree = scope.forDocumentTree; |
@@ -1280,7 +1826,7 @@ CustomElements.addModule(function(scope) { |
if (p == doc) { |
return true; |
} |
- p = p.parentNode || p.host; |
+ p = p.parentNode || p.nodeType === Node.DOCUMENT_FRAGMENT_NODE && p.host; |
} |
} |
function watchShadow(node) { |
@@ -1327,9 +1873,9 @@ CustomElements.addModule(function(scope) { |
flags.dom && console.groupEnd(); |
} |
function takeRecords(node) { |
- node = wrap(node); |
+ node = window.wrap(node); |
if (!node) { |
- node = wrap(document); |
+ node = window.wrap(document); |
} |
while (node.parentNode) { |
node = node.parentNode; |
@@ -1353,7 +1899,7 @@ CustomElements.addModule(function(scope) { |
inRoot.__observer = observer; |
} |
function upgradeDocument(doc) { |
- doc = wrap(doc); |
+ doc = window.wrap(doc); |
flags.dom && console.group("upgradeDocument: ", doc.baseURI.split("/").pop()); |
addedNode(doc); |
observe(doc); |
@@ -1363,11 +1909,13 @@ CustomElements.addModule(function(scope) { |
forDocumentTree(doc, upgradeDocument); |
} |
var originalCreateShadowRoot = Element.prototype.createShadowRoot; |
- Element.prototype.createShadowRoot = function() { |
- var root = originalCreateShadowRoot.call(this); |
- CustomElements.watchShadow(this); |
- return root; |
- }; |
+ if (originalCreateShadowRoot) { |
+ Element.prototype.createShadowRoot = function() { |
+ var root = originalCreateShadowRoot.call(this); |
+ window.CustomElements.watchShadow(this); |
+ return root; |
+ }; |
+ } |
scope.watchShadow = watchShadow; |
scope.upgradeDocumentTree = upgradeDocumentTree; |
scope.upgradeSubtree = addedSubtree; |
@@ -1376,7 +1924,7 @@ CustomElements.addModule(function(scope) { |
scope.takeRecords = takeRecords; |
}); |
-CustomElements.addModule(function(scope) { |
+window.CustomElements.addModule(function(scope) { |
var flags = scope.flags; |
function upgrade(node) { |
if (!node.__upgraded__ && node.nodeType === Node.ELEMENT_NODE) { |
@@ -1436,9 +1984,10 @@ CustomElements.addModule(function(scope) { |
scope.implementPrototype = implementPrototype; |
}); |
-CustomElements.addModule(function(scope) { |
+window.CustomElements.addModule(function(scope) { |
+ var isIE11OrOlder = scope.isIE11OrOlder; |
var upgradeDocumentTree = scope.upgradeDocumentTree; |
- var upgrade = scope.upgrade; |
+ var upgradeAll = scope.upgradeAll; |
var upgradeWithDefinition = scope.upgradeWithDefinition; |
var implementPrototype = scope.implementPrototype; |
var useNative = scope.useNative; |
@@ -1567,6 +2116,12 @@ CustomElements.addModule(function(scope) { |
} |
} |
function createElement(tag, typeExtension) { |
+ if (tag) { |
+ tag = tag.toLowerCase(); |
+ } |
+ if (typeExtension) { |
+ typeExtension = typeExtension.toLowerCase(); |
+ } |
var definition = getRegisteredDefinition(typeExtension || tag); |
if (definition) { |
if (tag == definition.tag && typeExtension == definition.is) { |
@@ -1588,14 +2143,8 @@ CustomElements.addModule(function(scope) { |
} |
return element; |
} |
- function cloneNode(deep) { |
- var n = domCloneNode.call(this, deep); |
- upgrade(n); |
- return n; |
- } |
var domCreateElement = document.createElement.bind(document); |
var domCreateElementNS = document.createElementNS.bind(document); |
- var domCloneNode = Node.prototype.cloneNode; |
var isInstance; |
if (!Object.__proto__ && !useNative) { |
isInstance = function(obj, ctor) { |
@@ -1613,10 +2162,34 @@ CustomElements.addModule(function(scope) { |
return obj instanceof base; |
}; |
} |
+ function wrapDomMethodToForceUpgrade(obj, methodName) { |
+ var orig = obj[methodName]; |
+ obj[methodName] = function() { |
+ var n = orig.apply(this, arguments); |
+ upgradeAll(n); |
+ return n; |
+ }; |
+ } |
+ wrapDomMethodToForceUpgrade(Node.prototype, "cloneNode"); |
+ wrapDomMethodToForceUpgrade(document, "importNode"); |
+ if (isIE11OrOlder) { |
+ (function() { |
+ var importNode = document.importNode; |
+ document.importNode = function() { |
+ var n = importNode.apply(document, arguments); |
+ if (n.nodeType == n.DOCUMENT_FRAGMENT_NODE) { |
+ var f = document.createDocumentFragment(); |
+ f.appendChild(n); |
+ return f; |
+ } else { |
+ return n; |
+ } |
+ }; |
+ })(); |
+ } |
document.registerElement = register; |
document.createElement = createElement; |
document.createElementNS = createElementNS; |
- Node.prototype.cloneNode = cloneNode; |
scope.registry = registry; |
scope.instanceof = isInstance; |
scope.reservedTagList = reservedTagList; |
@@ -1645,8 +2218,8 @@ CustomElements.addModule(function(scope) { |
var upgradeDocumentTree = scope.upgradeDocumentTree; |
if (!window.wrap) { |
if (window.ShadowDOMPolyfill) { |
- window.wrap = ShadowDOMPolyfill.wrapIfNeeded; |
- window.unwrap = ShadowDOMPolyfill.unwrapIfNeeded; |
+ window.wrap = window.ShadowDOMPolyfill.wrapIfNeeded; |
+ window.unwrap = window.ShadowDOMPolyfill.unwrapIfNeeded; |
} else { |
window.wrap = window.unwrap = function(node) { |
return node; |
@@ -1654,17 +2227,17 @@ CustomElements.addModule(function(scope) { |
} |
} |
function bootstrap() { |
- upgradeDocumentTree(wrap(document)); |
+ upgradeDocumentTree(window.wrap(document)); |
if (window.HTMLImports) { |
- HTMLImports.__importsParsingHook = function(elt) { |
+ window.HTMLImports.__importsParsingHook = function(elt) { |
upgradeDocumentTree(wrap(elt.import)); |
}; |
} |
- CustomElements.ready = true; |
+ window.CustomElements.ready = true; |
setTimeout(function() { |
- CustomElements.readyTime = Date.now(); |
+ window.CustomElements.readyTime = Date.now(); |
if (window.HTMLImports) { |
- CustomElements.elapsed = CustomElements.readyTime - HTMLImports.readyTime; |
+ window.CustomElements.elapsed = window.CustomElements.readyTime - window.HTMLImports.readyTime; |
} |
document.dispatchEvent(new CustomEvent("WebComponentsReady", { |
bubbles: true |
@@ -1676,6 +2249,13 @@ CustomElements.addModule(function(scope) { |
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; |
@@ -1685,9 +2265,10 @@ CustomElements.addModule(function(scope) { |
} else if (document.readyState === "interactive" && !window.attachEvent && (!window.HTMLImports || window.HTMLImports.ready)) { |
bootstrap(); |
} else { |
- var loadEvent = window.HTMLImports && !HTMLImports.ready ? "HTMLImportsLoaded" : "DOMContentLoaded"; |
+ var loadEvent = window.HTMLImports && !window.HTMLImports.ready ? "HTMLImportsLoaded" : "DOMContentLoaded"; |
window.addEventListener(loadEvent, bootstrap); |
} |
+ scope.isIE11OrOlder = isIE11OrOlder; |
})(window.CustomElements); |
if (typeof HTMLTemplateElement === "undefined") { |
@@ -1698,10 +2279,10 @@ if (typeof HTMLTemplateElement === "undefined") { |
HTMLTemplateElement.decorate = function(template) { |
if (!template.content) { |
template.content = template.ownerDocument.createDocumentFragment(); |
- var child; |
- while (child = template.firstChild) { |
- template.content.appendChild(child); |
- } |
+ } |
+ var child; |
+ while (child = template.firstChild) { |
+ template.content.appendChild(child); |
} |
}; |
HTMLTemplateElement.bootstrap = function(doc) { |
@@ -1710,9 +2291,18 @@ if (typeof HTMLTemplateElement === "undefined") { |
HTMLTemplateElement.decorate(t); |
} |
}; |
- addEventListener("DOMContentLoaded", function() { |
+ 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; |
+ }; |
})(); |
} |