Index: polymer_1.0.4/bower_components/webcomponentsjs/HTMLImports.js |
diff --git a/polymer_0.5.4/bower_components/webcomponentsjs/HTMLImports.js b/polymer_1.0.4/bower_components/webcomponentsjs/HTMLImports.js |
similarity index 91% |
copy from polymer_0.5.4/bower_components/webcomponentsjs/HTMLImports.js |
copy to polymer_1.0.4/bower_components/webcomponentsjs/HTMLImports.js |
index d8ad479610cf6e015eb660ec012e46a6875a4b52..e9f03ecf81873552c6d8ad81c86950c317999743 100644 |
--- a/polymer_0.5.4/bower_components/webcomponentsjs/HTMLImports.js |
+++ b/polymer_1.0.4/bower_components/webcomponentsjs/HTMLImports.js |
@@ -7,7 +7,7 @@ |
* 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 |
if (typeof WeakMap === "undefined") { |
(function() { |
var defineProperty = Object.defineProperty; |
@@ -315,7 +315,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") { |
@@ -327,12 +326,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; |
}); |
@@ -353,19 +352,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() { |
@@ -395,26 +394,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(); |
+ } |
+ function errorLoadingImport(e) { |
+ errorImports.push(this); |
+ parsedCount++; |
checkDone(); |
} |
- if (l) { |
- for (var i = 0, imp; i < l && (imp = imports[i]); i++) { |
+ 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 { |
@@ -464,11 +472,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; |
@@ -476,7 +484,7 @@ window.HTMLImports = window.HTMLImports || { |
scope.rootDocument = rootDocument; |
scope.whenReady = whenReady; |
scope.isIE = isIE; |
-})(HTMLImports); |
+})(window.HTMLImports); |
(function(scope) { |
var modules = []; |
@@ -490,26 +498,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; |
@@ -519,7 +530,7 @@ HTMLImports.addModule(function(scope) { |
scope.path = path; |
}); |
-HTMLImports.addModule(function(scope) { |
+window.HTMLImports.addModule(function(scope) { |
var xhr = { |
async: true, |
ok: function(request) { |
@@ -551,7 +562,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) { |
@@ -644,7 +655,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)); |
@@ -677,7 +688,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; |
@@ -686,7 +697,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", |
@@ -737,8 +748,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; |
@@ -777,6 +788,7 @@ HTMLImports.addModule(function(scope) { |
parseStyle: function(elt) { |
var src = elt; |
elt = cloneStyle(elt); |
+ src.__appliedElement = elt; |
elt.__importElement = src; |
this.parseGeneric(elt); |
}, |
@@ -821,9 +833,11 @@ HTMLImports.addModule(function(scope) { |
} |
} |
if (fakeLoad) { |
- elt.dispatchEvent(new CustomEvent("load", { |
- bubbles: false |
- })); |
+ setTimeout(function() { |
+ elt.dispatchEvent(new CustomEvent("load", { |
+ bubbles: false |
+ })); |
+ }); |
} |
} |
}, |
@@ -906,7 +920,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; |
@@ -967,12 +981,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 |
}); |
@@ -1002,7 +1019,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 = { |
@@ -1044,6 +1061,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; |
@@ -1051,11 +1075,11 @@ 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); |