| OLD | NEW |
| 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 if (typeof WeakMap === "undefined") { | 11 if (typeof WeakMap === "undefined") { |
| 12 (function() { | 12 (function() { |
| 13 var defineProperty = Object.defineProperty; | 13 var defineProperty = Object.defineProperty; |
| 14 var counter = Date.now() % 1e9; | 14 var counter = Date.now() % 1e9; |
| 15 var WeakMap = function() { | 15 var WeakMap = function() { |
| 16 this.name = "__st" + (Math.random() * 1e9 >>> 0) + (counter++ + "__"); | 16 this.name = "__st" + (Math.random() * 1e9 >>> 0) + (counter++ + "__"); |
| 17 }; | 17 }; |
| 18 WeakMap.prototype = { | 18 WeakMap.prototype = { |
| 19 set: function(key, value) { | 19 set: function(key, value) { |
| 20 var entry = key[this.name]; | 20 var entry = key[this.name]; |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 var imports = document.querySelectorAll("link[rel=import]"); | 460 var imports = document.querySelectorAll("link[rel=import]"); |
| 461 for (var i = 0, l = imports.length, imp; i < l && (imp = imports[i]); i+
+) { | 461 for (var i = 0, l = imports.length, imp; i < l && (imp = imports[i]); i+
+) { |
| 462 handleImport(imp); | 462 handleImport(imp); |
| 463 } | 463 } |
| 464 } | 464 } |
| 465 })(); | 465 })(); |
| 466 } | 466 } |
| 467 whenReady(function() { | 467 whenReady(function() { |
| 468 HTMLImports.ready = true; | 468 HTMLImports.ready = true; |
| 469 HTMLImports.readyTime = new Date().getTime(); | 469 HTMLImports.readyTime = new Date().getTime(); |
| 470 rootDocument.dispatchEvent(new CustomEvent("HTMLImportsLoaded", { | 470 var evt = rootDocument.createEvent("CustomEvent"); |
| 471 bubbles: true | 471 evt.initCustomEvent("HTMLImportsLoaded", true, true, {}); |
| 472 })); | 472 rootDocument.dispatchEvent(evt); |
| 473 }); | 473 }); |
| 474 scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE; | 474 scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE; |
| 475 scope.useNative = useNative; | 475 scope.useNative = useNative; |
| 476 scope.rootDocument = rootDocument; | 476 scope.rootDocument = rootDocument; |
| 477 scope.whenReady = whenReady; | 477 scope.whenReady = whenReady; |
| 478 scope.isIE = isIE; | 478 scope.isIE = isIE; |
| 479 })(HTMLImports); | 479 })(HTMLImports); |
| 480 | 480 |
| 481 (function(scope) { | 481 (function(scope) { |
| 482 var modules = []; | 482 var modules = []; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 513 urlObj.href = urlPath; | 513 urlObj.href = urlPath; |
| 514 urlPath = urlObj.href; | 514 urlPath = urlObj.href; |
| 515 return pre + "'" + urlPath + "'" + post; | 515 return pre + "'" + urlPath + "'" + post; |
| 516 }); | 516 }); |
| 517 } | 517 } |
| 518 }; | 518 }; |
| 519 scope.path = path; | 519 scope.path = path; |
| 520 }); | 520 }); |
| 521 | 521 |
| 522 HTMLImports.addModule(function(scope) { | 522 HTMLImports.addModule(function(scope) { |
| 523 xhr = { | 523 var xhr = { |
| 524 async: true, | 524 async: true, |
| 525 ok: function(request) { | 525 ok: function(request) { |
| 526 return request.status >= 200 && request.status < 300 || request.status ===
304 || request.status === 0; | 526 return request.status >= 200 && request.status < 300 || request.status ===
304 || request.status === 0; |
| 527 }, | 527 }, |
| 528 load: function(url, next, nextContext) { | 528 load: function(url, next, nextContext) { |
| 529 var request = new XMLHttpRequest(); | 529 var request = new XMLHttpRequest(); |
| 530 if (scope.flags.debug || scope.flags.bust) { | 530 if (scope.flags.debug || scope.flags.bust) { |
| 531 url += "?" + Math.random(); | 531 url += "?" + Math.random(); |
| 532 } | 532 } |
| 533 request.open("GET", url, xhr.async); | 533 request.open("GET", url, xhr.async); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 if (this.cache[url]) { | 590 if (this.cache[url]) { |
| 591 this.onload(url, elt, this.cache[url]); | 591 this.onload(url, elt, this.cache[url]); |
| 592 this.tail(); | 592 this.tail(); |
| 593 return true; | 593 return true; |
| 594 } | 594 } |
| 595 this.pending[url] = [ elt ]; | 595 this.pending[url] = [ elt ]; |
| 596 return false; | 596 return false; |
| 597 }, | 597 }, |
| 598 fetch: function(url, elt) { | 598 fetch: function(url, elt) { |
| 599 flags.load && console.log("fetch", url, elt); | 599 flags.load && console.log("fetch", url, elt); |
| 600 if (url.match(/^data:/)) { | 600 if (!url) { |
| 601 setTimeout(function() { |
| 602 this.receive(url, elt, { |
| 603 error: "href must be specified" |
| 604 }, null); |
| 605 }.bind(this), 0); |
| 606 } else if (url.match(/^data:/)) { |
| 601 var pieces = url.split(","); | 607 var pieces = url.split(","); |
| 602 var header = pieces[0]; | 608 var header = pieces[0]; |
| 603 var body = pieces[1]; | 609 var body = pieces[1]; |
| 604 if (header.indexOf(";base64") > -1) { | 610 if (header.indexOf(";base64") > -1) { |
| 605 body = atob(body); | 611 body = atob(body); |
| 606 } else { | 612 } else { |
| 607 body = decodeURIComponent(body); | 613 body = decodeURIComponent(body); |
| 608 } | 614 } |
| 609 setTimeout(function() { | 615 setTimeout(function() { |
| 610 this.receive(url, elt, null, body); | 616 this.receive(url, elt, null, body); |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 } | 1000 } |
| 995 scope.importer = importer; | 1001 scope.importer = importer; |
| 996 scope.importLoader = importLoader; | 1002 scope.importLoader = importLoader; |
| 997 }); | 1003 }); |
| 998 | 1004 |
| 999 HTMLImports.addModule(function(scope) { | 1005 HTMLImports.addModule(function(scope) { |
| 1000 var parser = scope.parser; | 1006 var parser = scope.parser; |
| 1001 var importer = scope.importer; | 1007 var importer = scope.importer; |
| 1002 var dynamic = { | 1008 var dynamic = { |
| 1003 added: function(nodes) { | 1009 added: function(nodes) { |
| 1004 var owner, parsed; | 1010 var owner, parsed, loading; |
| 1005 for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) { | 1011 for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) { |
| 1006 if (!owner) { | 1012 if (!owner) { |
| 1007 owner = n.ownerDocument; | 1013 owner = n.ownerDocument; |
| 1008 parsed = parser.isParsed(owner); | 1014 parsed = parser.isParsed(owner); |
| 1009 } | 1015 } |
| 1010 loading = this.shouldLoadNode(n); | 1016 loading = this.shouldLoadNode(n); |
| 1011 if (loading) { | 1017 if (loading) { |
| 1012 importer.loadNode(n); | 1018 importer.loadNode(n); |
| 1013 } | 1019 } |
| 1014 if (this.shouldParseNode(n) && parsed) { | 1020 if (this.shouldParseNode(n) && parsed) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 var rootDocument = scope.rootDocument; | 1052 var rootDocument = scope.rootDocument; |
| 1047 function bootstrap() { | 1053 function bootstrap() { |
| 1048 HTMLImports.importer.bootDocument(rootDocument); | 1054 HTMLImports.importer.bootDocument(rootDocument); |
| 1049 } | 1055 } |
| 1050 if (document.readyState === "complete" || document.readyState === "interactive
" && !window.attachEvent) { | 1056 if (document.readyState === "complete" || document.readyState === "interactive
" && !window.attachEvent) { |
| 1051 bootstrap(); | 1057 bootstrap(); |
| 1052 } else { | 1058 } else { |
| 1053 document.addEventListener("DOMContentLoaded", bootstrap); | 1059 document.addEventListener("DOMContentLoaded", bootstrap); |
| 1054 } | 1060 } |
| 1055 })(HTMLImports); | 1061 })(HTMLImports); |
| OLD | NEW |