Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1280)

Unified Diff: third_party/polymer/components/webcomponentsjs/HTMLImports.js

Issue 2113853002: Run bower update (Closed) Base URL: https://github.com/catapult-project/catapult@polymer10-migration
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/components/webcomponentsjs/HTMLImports.js
diff --git a/third_party/polymer/components/webcomponentsjs/HTMLImports.js b/third_party/polymer/components/webcomponentsjs/HTMLImports.js
index cc8ac641d8d4170e0ab8e400a752060aba963814..90613da7d2c734aba838013c0c6143b482aa480d 100644
--- a/third_party/polymer/components/webcomponentsjs/HTMLImports.js
+++ b/third_party/polymer/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.7.22
+// @version 0.6.1
if (typeof WeakMap === "undefined") {
(function() {
var defineProperty = Object.defineProperty;
@@ -45,9 +45,6 @@ if (typeof WeakMap === "undefined") {
}
(function(global) {
- if (global.JsMutationObserver) {
- return;
- }
var registrationsTable = new WeakMap();
var setImmediate;
if (/Trident|Edge/.test(navigator.userAgent)) {
@@ -343,83 +340,8 @@ if (typeof WeakMap === "undefined") {
}
};
global.JsMutationObserver = JsMutationObserver;
- if (!global.MutationObserver) {
- global.MutationObserver = JsMutationObserver;
- JsMutationObserver._isPolyfilled = true;
- }
-})(self);
-
-(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);
+ if (!global.MutationObserver) global.MutationObserver = JsMutationObserver;
+})(this);
window.HTMLImports = window.HTMLImports || {
flags: {}
@@ -430,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 ? window.ShadowDOMPolyfill.wrapIfNeeded(node) : node;
+ return hasShadowDOMPolyfill ? ShadowDOMPolyfill.wrapIfNeeded(node) : node;
};
var rootDocument = wrap(document);
var currentScriptDescriptor = {
get: function() {
- var script = window.HTMLImports.currentScript || document.currentScript || (document.readyState !== "complete" ? document.scripts[document.scripts.length - 1] : null);
+ var script = 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/.test(navigator.userAgent);
+ var isIE = /Trident|Edge/.test(navigator.userAgent);
function whenReady(callback, doc) {
doc = doc || rootDocument;
whenDocumentReady(function() {
@@ -496,7 +418,6 @@ 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 {
@@ -552,8 +473,8 @@ window.HTMLImports = window.HTMLImports || {
})();
}
whenReady(function(detail) {
- window.HTMLImports.ready = true;
- window.HTMLImports.readyTime = new Date().getTime();
+ HTMLImports.ready = true;
+ HTMLImports.readyTime = new Date().getTime();
var evt = rootDocument.createEvent("CustomEvent");
evt.initCustomEvent("HTMLImportsLoaded", true, true, detail);
rootDocument.dispatchEvent(evt);
@@ -563,7 +484,7 @@ window.HTMLImports = window.HTMLImports || {
scope.rootDocument = rootDocument;
scope.whenReady = whenReady;
scope.isIE = isIE;
-})(window.HTMLImports);
+})(HTMLImports);
(function(scope) {
var modules = [];
@@ -577,9 +498,9 @@ window.HTMLImports = window.HTMLImports || {
};
scope.addModule = addModule;
scope.initializeModules = initializeModules;
-})(window.HTMLImports);
+})(HTMLImports);
-window.HTMLImports.addModule(function(scope) {
+HTMLImports.addModule(function(scope) {
var CSS_URL_REGEXP = /(url\()([^)]*)(\))/g;
var CSS_IMPORT_REGEXP = /(@import[\s]+(?!url\())([^;]*)(;)/g;
var path = {
@@ -609,7 +530,7 @@ window.HTMLImports.addModule(function(scope) {
scope.path = path;
});
-window.HTMLImports.addModule(function(scope) {
+HTMLImports.addModule(function(scope) {
var xhr = {
async: true,
ok: function(request) {
@@ -623,14 +544,10 @@ 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;
- try {
- var locationHeader = request.getResponseHeader("Location");
- if (locationHeader) {
- redirectedUrl = locationHeader.substr(0, 1) === "/" ? location.origin + locationHeader : locationHeader;
- }
- } catch (e) {
- console.error(e.message);
+ if (locationHeader) {
+ var redirectedUrl = locationHeader.substr(0, 1) === "/" ? location.origin + locationHeader : locationHeader;
}
next.call(nextContext, !xhr.ok(request) && request, request.response || request.responseText, redirectedUrl);
}
@@ -645,7 +562,7 @@ window.HTMLImports.addModule(function(scope) {
scope.xhr = xhr;
});
-window.HTMLImports.addModule(function(scope) {
+HTMLImports.addModule(function(scope) {
var xhr = scope.xhr;
var flags = scope.flags;
var Loader = function(onLoad, onComplete) {
@@ -738,7 +655,7 @@ window.HTMLImports.addModule(function(scope) {
scope.Loader = Loader;
});
-window.HTMLImports.addModule(function(scope) {
+HTMLImports.addModule(function(scope) {
var Observer = function(addCallback) {
this.addCallback = addCallback;
this.mo = new MutationObserver(this.handler.bind(this));
@@ -771,7 +688,7 @@ window.HTMLImports.addModule(function(scope) {
scope.Observer = Observer;
});
-window.HTMLImports.addModule(function(scope) {
+HTMLImports.addModule(function(scope) {
var path = scope.path;
var rootDocument = scope.rootDocument;
var flags = scope.flags;
@@ -780,7 +697,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]:not([type])", "style:not([type])", "script:not([type])", 'script[type="application/javascript"]', 'script[type="text/javascript"]' ].join(","),
+ importsSelectors: [ IMPORT_SELECTOR, "link[rel=stylesheet]", "style", "script:not([type])", 'script[type="text/javascript"]' ].join(","),
map: {
link: "parseLink",
script: "parseScript",
@@ -831,9 +748,8 @@ window.HTMLImports.addModule(function(scope) {
}
},
parseImport: function(elt) {
- elt.import = elt.__doc;
- if (window.HTMLImports.__importsParsingHook) {
- window.HTMLImports.__importsParsingHook(elt);
+ if (HTMLImports.__importsParsingHook) {
+ HTMLImports.__importsParsingHook(elt);
}
if (elt.import) {
elt.import.__importParsed = true;
@@ -894,8 +810,6 @@ 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);
}
@@ -919,11 +833,9 @@ window.HTMLImports.addModule(function(scope) {
}
}
if (fakeLoad) {
- setTimeout(function() {
- elt.dispatchEvent(new CustomEvent("load", {
- bubbles: false
- }));
- });
+ elt.dispatchEvent(new CustomEvent("load", {
+ bubbles: false
+ }));
}
}
},
@@ -933,9 +845,7 @@ window.HTMLImports.addModule(function(scope) {
script.src = scriptElt.src ? scriptElt.src : generateScriptDataUrl(scriptElt);
scope.currentScript = scriptElt;
this.trackElement(script, function(e) {
- if (script.parentNode) {
- script.parentNode.removeChild(script);
- }
+ script.parentNode.removeChild(script);
scope.currentScript = null;
});
this.addElementToDocument(script);
@@ -948,10 +858,10 @@ window.HTMLImports.addModule(function(scope) {
if (doc && this._mayParse.indexOf(doc) < 0) {
this._mayParse.push(doc);
var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc));
- for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) {
+ 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.__doc, n) : n;
+ return nodeIsImport(n) ? this.nextToParseInDoc(n.import, n) : n;
} else {
return;
}
@@ -974,7 +884,7 @@ window.HTMLImports.addModule(function(scope) {
return this.dynamicElements.indexOf(elt) >= 0;
},
hasResource: function(node) {
- if (nodeIsImport(node) && node.__doc === undefined) {
+ if (nodeIsImport(node) && node.import === undefined) {
return false;
}
return true;
@@ -1008,7 +918,7 @@ window.HTMLImports.addModule(function(scope) {
scope.IMPORT_SELECTOR = IMPORT_SELECTOR;
});
-window.HTMLImports.addModule(function(scope) {
+HTMLImports.addModule(function(scope) {
var flags = scope.flags;
var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE;
var IMPORT_SELECTOR = scope.IMPORT_SELECTOR;
@@ -1048,7 +958,7 @@ window.HTMLImports.addModule(function(scope) {
}
this.documents[url] = doc;
}
- elt.__doc = doc;
+ elt.import = doc;
}
parser.parseNext();
},
@@ -1107,7 +1017,7 @@ window.HTMLImports.addModule(function(scope) {
scope.importLoader = importLoader;
});
-window.HTMLImports.addModule(function(scope) {
+HTMLImports.addModule(function(scope) {
var parser = scope.parser;
var importer = scope.importer;
var dynamic = {
@@ -1144,14 +1054,23 @@ 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);
+ return e;
+ };
+ window.CustomEvent.prototype = window.Event.prototype;
+ }
initializeModules();
var rootDocument = scope.rootDocument;
function bootstrap() {
- window.HTMLImports.importer.bootDocument(rootDocument);
+ HTMLImports.importer.bootDocument(rootDocument);
}
if (document.readyState === "complete" || document.readyState === "interactive" && !window.attachEvent) {
bootstrap();
} else {
document.addEventListener("DOMContentLoaded", bootstrap);
}
-})(window.HTMLImports);
+})(HTMLImports);

Powered by Google App Engine
This is Rietveld 408576698