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

Side by Side Diff: polymer_0.5.4/bower_components/webcomponentsjs/webcomponents.js

Issue 895523005: Added Polymer 0.5.4 (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
OLDNEW
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.5.1-1 10 // @version 0.5.4
11 window.WebComponents = window.WebComponents || {}; 11 window.WebComponents = window.WebComponents || {};
12 12
13 (function(scope) { 13 (function(scope) {
14 var flags = scope.flags || {}; 14 var flags = scope.flags || {};
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 = {};
18 if (!flags.noOpts) { 17 if (!flags.noOpts) {
19 location.search.slice(1).split("&").forEach(function(o) { 18 location.search.slice(1).split("&").forEach(function(o) {
20 o = o.split("="); 19 o = o.split("=");
21 o[0] && (flags[o[0]] = o[1] || true); 20 o[0] && (flags[o[0]] = o[1] || true);
22 }); 21 });
23 if (script) { 22 if (script) {
24 for (var i = 0, a; a = script.attributes[i]; i++) { 23 for (var i = 0, a; a = script.attributes[i]; i++) {
25 if (a.name !== "src") { 24 if (a.name !== "src") {
26 flags[a.name] = a.value || true; 25 flags[a.name] = a.value || true;
27 } 26 }
(...skipping 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 return originalCompareDocumentPosition.call(unsafeUnwrap(this), unwrapIf Needed(otherNode)); 1985 return originalCompareDocumentPosition.call(unsafeUnwrap(this), unwrapIf Needed(otherNode));
1987 }, 1986 },
1988 normalize: function() { 1987 normalize: function() {
1989 var nodes = snapshotNodeList(this.childNodes); 1988 var nodes = snapshotNodeList(this.childNodes);
1990 var remNodes = []; 1989 var remNodes = [];
1991 var s = ""; 1990 var s = "";
1992 var modNode; 1991 var modNode;
1993 for (var i = 0, n; i < nodes.length; i++) { 1992 for (var i = 0, n; i < nodes.length; i++) {
1994 n = nodes[i]; 1993 n = nodes[i];
1995 if (n.nodeType === Node.TEXT_NODE) { 1994 if (n.nodeType === Node.TEXT_NODE) {
1996 if (!modNode && !n.data.length) this.removeNode(n); else if (!modNod e) modNode = n; else { 1995 if (!modNode && !n.data.length) this.removeChild(n); else if (!modNo de) modNode = n; else {
1997 s += n.data; 1996 s += n.data;
1998 remNodes.push(n); 1997 remNodes.push(n);
1999 } 1998 }
2000 } else { 1999 } else {
2001 if (modNode && remNodes.length) { 2000 if (modNode && remNodes.length) {
2002 modNode.data += s; 2001 modNode.data += s;
2003 cleanupNodes(remNodes); 2002 cleanupNodes(remNodes);
2004 } 2003 }
2005 remNodes = []; 2004 remNodes = [];
2006 s = ""; 2005 s = "";
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
2321 var newTextNode = this.ownerDocument.createTextNode(tail); 2320 var newTextNode = this.ownerDocument.createTextNode(tail);
2322 if (this.parentNode) this.parentNode.insertBefore(newTextNode, this.next Sibling); 2321 if (this.parentNode) this.parentNode.insertBefore(newTextNode, this.next Sibling);
2323 return newTextNode; 2322 return newTextNode;
2324 } 2323 }
2325 }); 2324 });
2326 registerWrapper(OriginalText, Text, document.createTextNode("")); 2325 registerWrapper(OriginalText, Text, document.createTextNode(""));
2327 scope.wrappers.Text = Text; 2326 scope.wrappers.Text = Text;
2328 })(window.ShadowDOMPolyfill); 2327 })(window.ShadowDOMPolyfill);
2329 (function(scope) { 2328 (function(scope) {
2330 "use strict"; 2329 "use strict";
2331 var setWrapper = scope.setWrapper;
2332 var unsafeUnwrap = scope.unsafeUnwrap; 2330 var unsafeUnwrap = scope.unsafeUnwrap;
2331 var enqueueMutation = scope.enqueueMutation;
2332 function getClass(el) {
2333 return unsafeUnwrap(el).getAttribute("class");
2334 }
2335 function enqueueClassAttributeChange(el, oldValue) {
2336 enqueueMutation(el, "attributes", {
2337 name: "class",
2338 namespace: null,
2339 oldValue: oldValue
2340 });
2341 }
2333 function invalidateClass(el) { 2342 function invalidateClass(el) {
2334 scope.invalidateRendererBasedOnAttribute(el, "class"); 2343 scope.invalidateRendererBasedOnAttribute(el, "class");
2335 } 2344 }
2336 function DOMTokenList(impl, ownerElement) { 2345 function changeClass(tokenList, method, args) {
2337 setWrapper(impl, this); 2346 var ownerElement = tokenList.ownerElement_;
2338 this.ownerElement_ = ownerElement; 2347 if (ownerElement == null) {
2348 return method.apply(tokenList, args);
2349 }
2350 var oldValue = getClass(ownerElement);
2351 var retv = method.apply(tokenList, args);
2352 if (getClass(ownerElement) !== oldValue) {
2353 enqueueClassAttributeChange(ownerElement, oldValue);
2354 invalidateClass(ownerElement);
2355 }
2356 return retv;
2339 } 2357 }
2340 DOMTokenList.prototype = { 2358 var oldAdd = DOMTokenList.prototype.add;
2341 constructor: DOMTokenList, 2359 DOMTokenList.prototype.add = function() {
2342 get length() { 2360 changeClass(this, oldAdd, arguments);
2343 return unsafeUnwrap(this).length;
2344 },
2345 item: function(index) {
2346 return unsafeUnwrap(this).item(index);
2347 },
2348 contains: function(token) {
2349 return unsafeUnwrap(this).contains(token);
2350 },
2351 add: function() {
2352 unsafeUnwrap(this).add.apply(unsafeUnwrap(this), arguments);
2353 invalidateClass(this.ownerElement_);
2354 },
2355 remove: function() {
2356 unsafeUnwrap(this).remove.apply(unsafeUnwrap(this), arguments);
2357 invalidateClass(this.ownerElement_);
2358 },
2359 toggle: function(token) {
2360 var rv = unsafeUnwrap(this).toggle.apply(unsafeUnwrap(this), arguments);
2361 invalidateClass(this.ownerElement_);
2362 return rv;
2363 },
2364 toString: function() {
2365 return unsafeUnwrap(this).toString();
2366 }
2367 }; 2361 };
2368 scope.wrappers.DOMTokenList = DOMTokenList; 2362 var oldRemove = DOMTokenList.prototype.remove;
2363 DOMTokenList.prototype.remove = function() {
2364 changeClass(this, oldRemove, arguments);
2365 };
2366 var oldToggle = DOMTokenList.prototype.toggle;
2367 DOMTokenList.prototype.toggle = function() {
2368 return changeClass(this, oldToggle, arguments);
2369 };
2369 })(window.ShadowDOMPolyfill); 2370 })(window.ShadowDOMPolyfill);
2370 (function(scope) { 2371 (function(scope) {
2371 "use strict"; 2372 "use strict";
2372 var ChildNodeInterface = scope.ChildNodeInterface; 2373 var ChildNodeInterface = scope.ChildNodeInterface;
2373 var GetElementsByInterface = scope.GetElementsByInterface; 2374 var GetElementsByInterface = scope.GetElementsByInterface;
2374 var Node = scope.wrappers.Node; 2375 var Node = scope.wrappers.Node;
2375 var DOMTokenList = scope.wrappers.DOMTokenList;
2376 var ParentNodeInterface = scope.ParentNodeInterface; 2376 var ParentNodeInterface = scope.ParentNodeInterface;
2377 var SelectorsInterface = scope.SelectorsInterface; 2377 var SelectorsInterface = scope.SelectorsInterface;
2378 var addWrapNodeListMethod = scope.addWrapNodeListMethod; 2378 var addWrapNodeListMethod = scope.addWrapNodeListMethod;
2379 var enqueueMutation = scope.enqueueMutation; 2379 var enqueueMutation = scope.enqueueMutation;
2380 var mixin = scope.mixin; 2380 var mixin = scope.mixin;
2381 var oneOf = scope.oneOf; 2381 var oneOf = scope.oneOf;
2382 var registerWrapper = scope.registerWrapper; 2382 var registerWrapper = scope.registerWrapper;
2383 var unsafeUnwrap = scope.unsafeUnwrap; 2383 var unsafeUnwrap = scope.unsafeUnwrap;
2384 var wrappers = scope.wrappers; 2384 var wrappers = scope.wrappers;
2385 var OriginalElement = window.Element; 2385 var OriginalElement = window.Element;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2428 unsafeUnwrap(this).removeAttribute(name); 2428 unsafeUnwrap(this).removeAttribute(name);
2429 enqueAttributeChange(this, name, oldValue); 2429 enqueAttributeChange(this, name, oldValue);
2430 invalidateRendererBasedOnAttribute(this, name); 2430 invalidateRendererBasedOnAttribute(this, name);
2431 }, 2431 },
2432 matches: function(selector) { 2432 matches: function(selector) {
2433 return originalMatches.call(unsafeUnwrap(this), selector); 2433 return originalMatches.call(unsafeUnwrap(this), selector);
2434 }, 2434 },
2435 get classList() { 2435 get classList() {
2436 var list = classListTable.get(this); 2436 var list = classListTable.get(this);
2437 if (!list) { 2437 if (!list) {
2438 classListTable.set(this, list = new DOMTokenList(unsafeUnwrap(this).cl assList, this)); 2438 list = unsafeUnwrap(this).classList;
2439 list.ownerElement_ = this;
2440 classListTable.set(this, list);
2439 } 2441 }
2440 return list; 2442 return list;
2441 }, 2443 },
2442 get className() { 2444 get className() {
2443 return unsafeUnwrap(this).className; 2445 return unsafeUnwrap(this).className;
2444 }, 2446 },
2445 set className(v) { 2447 set className(v) {
2446 this.setAttribute("class", v); 2448 this.setAttribute("class", v);
2447 }, 2449 },
2448 get id() { 2450 get id() {
(...skipping 1556 matching lines...) Expand 10 before | Expand all | Expand 10 after
4005 } 4007 }
4006 CustomElementConstructor.prototype = prototype; 4008 CustomElementConstructor.prototype = prototype;
4007 CustomElementConstructor.prototype.constructor = CustomElementConstructo r; 4009 CustomElementConstructor.prototype.constructor = CustomElementConstructo r;
4008 scope.constructorTable.set(newPrototype, CustomElementConstructor); 4010 scope.constructorTable.set(newPrototype, CustomElementConstructor);
4009 scope.nativePrototypeTable.set(prototype, newPrototype); 4011 scope.nativePrototypeTable.set(prototype, newPrototype);
4010 var nativeConstructor = originalRegisterElement.call(unwrap(this), tagNa me, p); 4012 var nativeConstructor = originalRegisterElement.call(unwrap(this), tagNa me, p);
4011 return CustomElementConstructor; 4013 return CustomElementConstructor;
4012 }; 4014 };
4013 forwardMethodsToWrapper([ window.HTMLDocument || window.Document ], [ "reg isterElement" ]); 4015 forwardMethodsToWrapper([ window.HTMLDocument || window.Document ], [ "reg isterElement" ]);
4014 } 4016 }
4015 forwardMethodsToWrapper([ window.HTMLBodyElement, window.HTMLDocument || win dow.Document, window.HTMLHeadElement, window.HTMLHtmlElement ], [ "appendChild", "compareDocumentPosition", "contains", "getElementsByClassName", "getElementsBy TagName", "getElementsByTagNameNS", "insertBefore", "querySelector", "querySelec torAll", "removeChild", "replaceChild" ].concat(matchesNames)); 4017 forwardMethodsToWrapper([ window.HTMLBodyElement, window.HTMLDocument || win dow.Document, window.HTMLHeadElement, window.HTMLHtmlElement ], [ "appendChild", "compareDocumentPosition", "contains", "getElementsByClassName", "getElementsBy TagName", "getElementsByTagNameNS", "insertBefore", "querySelector", "querySelec torAll", "removeChild", "replaceChild" ]);
4018 forwardMethodsToWrapper([ window.HTMLBodyElement, window.HTMLHeadElement, wi ndow.HTMLHtmlElement ], matchesNames);
4016 forwardMethodsToWrapper([ window.HTMLDocument || window.Document ], [ "adopt Node", "importNode", "contains", "createComment", "createDocumentFragment", "cre ateElement", "createElementNS", "createEvent", "createEventNS", "createRange", " createTextNode", "elementFromPoint", "getElementById", "getElementsByName", "get Selection" ]); 4019 forwardMethodsToWrapper([ window.HTMLDocument || window.Document ], [ "adopt Node", "importNode", "contains", "createComment", "createDocumentFragment", "cre ateElement", "createElementNS", "createEvent", "createEventNS", "createRange", " createTextNode", "elementFromPoint", "getElementById", "getElementsByName", "get Selection" ]);
4017 mixin(Document.prototype, GetElementsByInterface); 4020 mixin(Document.prototype, GetElementsByInterface);
4018 mixin(Document.prototype, ParentNodeInterface); 4021 mixin(Document.prototype, ParentNodeInterface);
4019 mixin(Document.prototype, SelectorsInterface); 4022 mixin(Document.prototype, SelectorsInterface);
4020 mixin(Document.prototype, { 4023 mixin(Document.prototype, {
4021 get implementation() { 4024 get implementation() {
4022 var implementation = implementationTable.get(this); 4025 var implementation = implementationTable.get(this);
4023 if (implementation) return implementation; 4026 if (implementation) return implementation;
4024 implementation = new DOMImplementation(unwrap(this).implementation); 4027 implementation = new DOMImplementation(unwrap(this).implementation);
4025 implementationTable.set(this, implementation); 4028 implementationTable.set(this, implementation);
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
5108 var imports = document.querySelectorAll("link[rel=import]"); 5111 var imports = document.querySelectorAll("link[rel=import]");
5109 for (var i = 0, l = imports.length, imp; i < l && (imp = imports[i]); i+ +) { 5112 for (var i = 0, l = imports.length, imp; i < l && (imp = imports[i]); i+ +) {
5110 handleImport(imp); 5113 handleImport(imp);
5111 } 5114 }
5112 } 5115 }
5113 })(); 5116 })();
5114 } 5117 }
5115 whenReady(function() { 5118 whenReady(function() {
5116 HTMLImports.ready = true; 5119 HTMLImports.ready = true;
5117 HTMLImports.readyTime = new Date().getTime(); 5120 HTMLImports.readyTime = new Date().getTime();
5118 rootDocument.dispatchEvent(new CustomEvent("HTMLImportsLoaded", { 5121 var evt = rootDocument.createEvent("CustomEvent");
5119 bubbles: true 5122 evt.initCustomEvent("HTMLImportsLoaded", true, true, {});
5120 })); 5123 rootDocument.dispatchEvent(evt);
5121 }); 5124 });
5122 scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE; 5125 scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE;
5123 scope.useNative = useNative; 5126 scope.useNative = useNative;
5124 scope.rootDocument = rootDocument; 5127 scope.rootDocument = rootDocument;
5125 scope.whenReady = whenReady; 5128 scope.whenReady = whenReady;
5126 scope.isIE = isIE; 5129 scope.isIE = isIE;
5127 })(HTMLImports); 5130 })(HTMLImports);
5128 5131
5129 (function(scope) { 5132 (function(scope) {
5130 var modules = []; 5133 var modules = [];
(...skipping 30 matching lines...) Expand all
5161 urlObj.href = urlPath; 5164 urlObj.href = urlPath;
5162 urlPath = urlObj.href; 5165 urlPath = urlObj.href;
5163 return pre + "'" + urlPath + "'" + post; 5166 return pre + "'" + urlPath + "'" + post;
5164 }); 5167 });
5165 } 5168 }
5166 }; 5169 };
5167 scope.path = path; 5170 scope.path = path;
5168 }); 5171 });
5169 5172
5170 HTMLImports.addModule(function(scope) { 5173 HTMLImports.addModule(function(scope) {
5171 xhr = { 5174 var xhr = {
5172 async: true, 5175 async: true,
5173 ok: function(request) { 5176 ok: function(request) {
5174 return request.status >= 200 && request.status < 300 || request.status === 304 || request.status === 0; 5177 return request.status >= 200 && request.status < 300 || request.status === 304 || request.status === 0;
5175 }, 5178 },
5176 load: function(url, next, nextContext) { 5179 load: function(url, next, nextContext) {
5177 var request = new XMLHttpRequest(); 5180 var request = new XMLHttpRequest();
5178 if (scope.flags.debug || scope.flags.bust) { 5181 if (scope.flags.debug || scope.flags.bust) {
5179 url += "?" + Math.random(); 5182 url += "?" + Math.random();
5180 } 5183 }
5181 request.open("GET", url, xhr.async); 5184 request.open("GET", url, xhr.async);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
5238 if (this.cache[url]) { 5241 if (this.cache[url]) {
5239 this.onload(url, elt, this.cache[url]); 5242 this.onload(url, elt, this.cache[url]);
5240 this.tail(); 5243 this.tail();
5241 return true; 5244 return true;
5242 } 5245 }
5243 this.pending[url] = [ elt ]; 5246 this.pending[url] = [ elt ];
5244 return false; 5247 return false;
5245 }, 5248 },
5246 fetch: function(url, elt) { 5249 fetch: function(url, elt) {
5247 flags.load && console.log("fetch", url, elt); 5250 flags.load && console.log("fetch", url, elt);
5248 if (url.match(/^data:/)) { 5251 if (!url) {
5252 setTimeout(function() {
5253 this.receive(url, elt, {
5254 error: "href must be specified"
5255 }, null);
5256 }.bind(this), 0);
5257 } else if (url.match(/^data:/)) {
5249 var pieces = url.split(","); 5258 var pieces = url.split(",");
5250 var header = pieces[0]; 5259 var header = pieces[0];
5251 var body = pieces[1]; 5260 var body = pieces[1];
5252 if (header.indexOf(";base64") > -1) { 5261 if (header.indexOf(";base64") > -1) {
5253 body = atob(body); 5262 body = atob(body);
5254 } else { 5263 } else {
5255 body = decodeURIComponent(body); 5264 body = decodeURIComponent(body);
5256 } 5265 }
5257 setTimeout(function() { 5266 setTimeout(function() {
5258 this.receive(url, elt, null, body); 5267 this.receive(url, elt, null, body);
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
5642 } 5651 }
5643 scope.importer = importer; 5652 scope.importer = importer;
5644 scope.importLoader = importLoader; 5653 scope.importLoader = importLoader;
5645 }); 5654 });
5646 5655
5647 HTMLImports.addModule(function(scope) { 5656 HTMLImports.addModule(function(scope) {
5648 var parser = scope.parser; 5657 var parser = scope.parser;
5649 var importer = scope.importer; 5658 var importer = scope.importer;
5650 var dynamic = { 5659 var dynamic = {
5651 added: function(nodes) { 5660 added: function(nodes) {
5652 var owner, parsed; 5661 var owner, parsed, loading;
5653 for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) { 5662 for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) {
5654 if (!owner) { 5663 if (!owner) {
5655 owner = n.ownerDocument; 5664 owner = n.ownerDocument;
5656 parsed = parser.isParsed(owner); 5665 parsed = parser.isParsed(owner);
5657 } 5666 }
5658 loading = this.shouldLoadNode(n); 5667 loading = this.shouldLoadNode(n);
5659 if (loading) { 5668 if (loading) {
5660 importer.loadNode(n); 5669 importer.loadNode(n);
5661 } 5670 }
5662 if (this.shouldParseNode(n) && parsed) { 5671 if (this.shouldParseNode(n) && parsed) {
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
6366 (function(scope) { 6375 (function(scope) {
6367 var style = document.createElement("style"); 6376 var style = document.createElement("style");
6368 style.textContent = "" + "body {" + "transition: opacity ease-in 0.2s;" + " } \n" + "body[unresolved] {" + "opacity: 0; display: block; overflow: hidden; posi tion: relative;" + " } \n"; 6377 style.textContent = "" + "body {" + "transition: opacity ease-in 0.2s;" + " } \n" + "body[unresolved] {" + "opacity: 0; display: block; overflow: hidden; posi tion: relative;" + " } \n";
6369 var head = document.querySelector("head"); 6378 var head = document.querySelector("head");
6370 head.insertBefore(style, head.firstChild); 6379 head.insertBefore(style, head.firstChild);
6371 })(window.WebComponents); 6380 })(window.WebComponents);
6372 6381
6373 (function(scope) { 6382 (function(scope) {
6374 window.Platform = scope; 6383 window.Platform = scope;
6375 })(window.WebComponents); 6384 })(window.WebComponents);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698