| 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.7.22 | 10 // @version 0.6.1 |
| 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 17 matching lines...) Expand all Loading... |
| 38 var entry = key[this.name]; | 38 var entry = key[this.name]; |
| 39 if (!entry) return false; | 39 if (!entry) return false; |
| 40 return entry[0] === key; | 40 return entry[0] === key; |
| 41 } | 41 } |
| 42 }; | 42 }; |
| 43 window.WeakMap = WeakMap; | 43 window.WeakMap = WeakMap; |
| 44 })(); | 44 })(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 (function(global) { | 47 (function(global) { |
| 48 if (global.JsMutationObserver) { | |
| 49 return; | |
| 50 } | |
| 51 var registrationsTable = new WeakMap(); | 48 var registrationsTable = new WeakMap(); |
| 52 var setImmediate; | 49 var setImmediate; |
| 53 if (/Trident|Edge/.test(navigator.userAgent)) { | 50 if (/Trident|Edge/.test(navigator.userAgent)) { |
| 54 setImmediate = setTimeout; | 51 setImmediate = setTimeout; |
| 55 } else if (window.setImmediate) { | 52 } else if (window.setImmediate) { |
| 56 setImmediate = window.setImmediate; | 53 setImmediate = window.setImmediate; |
| 57 } else { | 54 } else { |
| 58 var setImmediateQueue = []; | 55 var setImmediateQueue = []; |
| 59 var sentinel = String(Math.random()); | 56 var sentinel = String(Math.random()); |
| 60 window.addEventListener("message", function(e) { | 57 window.addEventListener("message", function(e) { |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 record.nextSibling = nextSibling; | 333 record.nextSibling = nextSibling; |
| 337 forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function(options)
{ | 334 forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function(options)
{ |
| 338 if (!options.childList) return; | 335 if (!options.childList) return; |
| 339 return record; | 336 return record; |
| 340 }); | 337 }); |
| 341 } | 338 } |
| 342 clearRecords(); | 339 clearRecords(); |
| 343 } | 340 } |
| 344 }; | 341 }; |
| 345 global.JsMutationObserver = JsMutationObserver; | 342 global.JsMutationObserver = JsMutationObserver; |
| 346 if (!global.MutationObserver) { | 343 if (!global.MutationObserver) global.MutationObserver = JsMutationObserver; |
| 347 global.MutationObserver = JsMutationObserver; | 344 })(this); |
| 348 JsMutationObserver._isPolyfilled = true; | |
| 349 } | |
| 350 })(self); | |
| 351 | |
| 352 (function(scope) { | |
| 353 "use strict"; | |
| 354 if (!window.performance) { | |
| 355 var start = Date.now(); | |
| 356 window.performance = { | |
| 357 now: function() { | |
| 358 return Date.now() - start; | |
| 359 } | |
| 360 }; | |
| 361 } | |
| 362 if (!window.requestAnimationFrame) { | |
| 363 window.requestAnimationFrame = function() { | |
| 364 var nativeRaf = window.webkitRequestAnimationFrame || window.mozRequestAni
mationFrame; | |
| 365 return nativeRaf ? function(callback) { | |
| 366 return nativeRaf(function() { | |
| 367 callback(performance.now()); | |
| 368 }); | |
| 369 } : function(callback) { | |
| 370 return window.setTimeout(callback, 1e3 / 60); | |
| 371 }; | |
| 372 }(); | |
| 373 } | |
| 374 if (!window.cancelAnimationFrame) { | |
| 375 window.cancelAnimationFrame = function() { | |
| 376 return window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame
|| function(id) { | |
| 377 clearTimeout(id); | |
| 378 }; | |
| 379 }(); | |
| 380 } | |
| 381 var workingDefaultPrevented = function() { | |
| 382 var e = document.createEvent("Event"); | |
| 383 e.initEvent("foo", true, true); | |
| 384 e.preventDefault(); | |
| 385 return e.defaultPrevented; | |
| 386 }(); | |
| 387 if (!workingDefaultPrevented) { | |
| 388 var origPreventDefault = Event.prototype.preventDefault; | |
| 389 Event.prototype.preventDefault = function() { | |
| 390 if (!this.cancelable) { | |
| 391 return; | |
| 392 } | |
| 393 origPreventDefault.call(this); | |
| 394 Object.defineProperty(this, "defaultPrevented", { | |
| 395 get: function() { | |
| 396 return true; | |
| 397 }, | |
| 398 configurable: true | |
| 399 }); | |
| 400 }; | |
| 401 } | |
| 402 var isIE = /Trident/.test(navigator.userAgent); | |
| 403 if (!window.CustomEvent || isIE && typeof window.CustomEvent !== "function") { | |
| 404 window.CustomEvent = function(inType, params) { | |
| 405 params = params || {}; | |
| 406 var e = document.createEvent("CustomEvent"); | |
| 407 e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelab
le), params.detail); | |
| 408 return e; | |
| 409 }; | |
| 410 window.CustomEvent.prototype = window.Event.prototype; | |
| 411 } | |
| 412 if (!window.Event || isIE && typeof window.Event !== "function") { | |
| 413 var origEvent = window.Event; | |
| 414 window.Event = function(inType, params) { | |
| 415 params = params || {}; | |
| 416 var e = document.createEvent("Event"); | |
| 417 e.initEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable)); | |
| 418 return e; | |
| 419 }; | |
| 420 window.Event.prototype = origEvent.prototype; | |
| 421 } | |
| 422 })(window.WebComponents); | |
| 423 | 345 |
| 424 window.HTMLImports = window.HTMLImports || { | 346 window.HTMLImports = window.HTMLImports || { |
| 425 flags: {} | 347 flags: {} |
| 426 }; | 348 }; |
| 427 | 349 |
| 428 (function(scope) { | 350 (function(scope) { |
| 429 var IMPORT_LINK_TYPE = "import"; | 351 var IMPORT_LINK_TYPE = "import"; |
| 430 var useNative = Boolean(IMPORT_LINK_TYPE in document.createElement("link")); | 352 var useNative = Boolean(IMPORT_LINK_TYPE in document.createElement("link")); |
| 431 var hasShadowDOMPolyfill = Boolean(window.ShadowDOMPolyfill); | 353 var hasShadowDOMPolyfill = Boolean(window.ShadowDOMPolyfill); |
| 432 var wrap = function(node) { | 354 var wrap = function(node) { |
| 433 return hasShadowDOMPolyfill ? window.ShadowDOMPolyfill.wrapIfNeeded(node) :
node; | 355 return hasShadowDOMPolyfill ? ShadowDOMPolyfill.wrapIfNeeded(node) : node; |
| 434 }; | 356 }; |
| 435 var rootDocument = wrap(document); | 357 var rootDocument = wrap(document); |
| 436 var currentScriptDescriptor = { | 358 var currentScriptDescriptor = { |
| 437 get: function() { | 359 get: function() { |
| 438 var script = window.HTMLImports.currentScript || document.currentScript ||
(document.readyState !== "complete" ? document.scripts[document.scripts.length
- 1] : null); | 360 var script = HTMLImports.currentScript || document.currentScript || (docum
ent.readyState !== "complete" ? document.scripts[document.scripts.length - 1] :
null); |
| 439 return wrap(script); | 361 return wrap(script); |
| 440 }, | 362 }, |
| 441 configurable: true | 363 configurable: true |
| 442 }; | 364 }; |
| 443 Object.defineProperty(document, "_currentScript", currentScriptDescriptor); | 365 Object.defineProperty(document, "_currentScript", currentScriptDescriptor); |
| 444 Object.defineProperty(rootDocument, "_currentScript", currentScriptDescriptor)
; | 366 Object.defineProperty(rootDocument, "_currentScript", currentScriptDescriptor)
; |
| 445 var isIE = /Trident/.test(navigator.userAgent); | 367 var isIE = /Trident|Edge/.test(navigator.userAgent); |
| 446 function whenReady(callback, doc) { | 368 function whenReady(callback, doc) { |
| 447 doc = doc || rootDocument; | 369 doc = doc || rootDocument; |
| 448 whenDocumentReady(function() { | 370 whenDocumentReady(function() { |
| 449 watchImportsLoad(callback, doc); | 371 watchImportsLoad(callback, doc); |
| 450 }, doc); | 372 }, doc); |
| 451 } | 373 } |
| 452 var requiredReadyState = isIE ? "complete" : "interactive"; | 374 var requiredReadyState = isIE ? "complete" : "interactive"; |
| 453 var READY_EVENT = "readystatechange"; | 375 var READY_EVENT = "readystatechange"; |
| 454 function isDocumentReady(doc) { | 376 function isDocumentReady(doc) { |
| 455 return doc.readyState === "complete" || doc.readyState === requiredReadyStat
e; | 377 return doc.readyState === "complete" || doc.readyState === requiredReadyStat
e; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 checkDone(); | 411 checkDone(); |
| 490 } | 412 } |
| 491 function errorLoadingImport(e) { | 413 function errorLoadingImport(e) { |
| 492 errorImports.push(this); | 414 errorImports.push(this); |
| 493 parsedCount++; | 415 parsedCount++; |
| 494 checkDone(); | 416 checkDone(); |
| 495 } | 417 } |
| 496 if (importCount) { | 418 if (importCount) { |
| 497 for (var i = 0, imp; i < importCount && (imp = imports[i]); i++) { | 419 for (var i = 0, imp; i < importCount && (imp = imports[i]); i++) { |
| 498 if (isImportLoaded(imp)) { | 420 if (isImportLoaded(imp)) { |
| 499 newImports.push(this); | |
| 500 parsedCount++; | 421 parsedCount++; |
| 501 checkDone(); | 422 checkDone(); |
| 502 } else { | 423 } else { |
| 503 imp.addEventListener("load", loadedImport); | 424 imp.addEventListener("load", loadedImport); |
| 504 imp.addEventListener("error", errorLoadingImport); | 425 imp.addEventListener("error", errorLoadingImport); |
| 505 } | 426 } |
| 506 } | 427 } |
| 507 } else { | 428 } else { |
| 508 checkDone(); | 429 checkDone(); |
| 509 } | 430 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 (function() { | 466 (function() { |
| 546 if (document.readyState === "loading") { | 467 if (document.readyState === "loading") { |
| 547 var imports = document.querySelectorAll("link[rel=import]"); | 468 var imports = document.querySelectorAll("link[rel=import]"); |
| 548 for (var i = 0, l = imports.length, imp; i < l && (imp = imports[i]); i+
+) { | 469 for (var i = 0, l = imports.length, imp; i < l && (imp = imports[i]); i+
+) { |
| 549 handleImport(imp); | 470 handleImport(imp); |
| 550 } | 471 } |
| 551 } | 472 } |
| 552 })(); | 473 })(); |
| 553 } | 474 } |
| 554 whenReady(function(detail) { | 475 whenReady(function(detail) { |
| 555 window.HTMLImports.ready = true; | 476 HTMLImports.ready = true; |
| 556 window.HTMLImports.readyTime = new Date().getTime(); | 477 HTMLImports.readyTime = new Date().getTime(); |
| 557 var evt = rootDocument.createEvent("CustomEvent"); | 478 var evt = rootDocument.createEvent("CustomEvent"); |
| 558 evt.initCustomEvent("HTMLImportsLoaded", true, true, detail); | 479 evt.initCustomEvent("HTMLImportsLoaded", true, true, detail); |
| 559 rootDocument.dispatchEvent(evt); | 480 rootDocument.dispatchEvent(evt); |
| 560 }); | 481 }); |
| 561 scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE; | 482 scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE; |
| 562 scope.useNative = useNative; | 483 scope.useNative = useNative; |
| 563 scope.rootDocument = rootDocument; | 484 scope.rootDocument = rootDocument; |
| 564 scope.whenReady = whenReady; | 485 scope.whenReady = whenReady; |
| 565 scope.isIE = isIE; | 486 scope.isIE = isIE; |
| 566 })(window.HTMLImports); | 487 })(HTMLImports); |
| 567 | 488 |
| 568 (function(scope) { | 489 (function(scope) { |
| 569 var modules = []; | 490 var modules = []; |
| 570 var addModule = function(module) { | 491 var addModule = function(module) { |
| 571 modules.push(module); | 492 modules.push(module); |
| 572 }; | 493 }; |
| 573 var initializeModules = function() { | 494 var initializeModules = function() { |
| 574 modules.forEach(function(module) { | 495 modules.forEach(function(module) { |
| 575 module(scope); | 496 module(scope); |
| 576 }); | 497 }); |
| 577 }; | 498 }; |
| 578 scope.addModule = addModule; | 499 scope.addModule = addModule; |
| 579 scope.initializeModules = initializeModules; | 500 scope.initializeModules = initializeModules; |
| 580 })(window.HTMLImports); | 501 })(HTMLImports); |
| 581 | 502 |
| 582 window.HTMLImports.addModule(function(scope) { | 503 HTMLImports.addModule(function(scope) { |
| 583 var CSS_URL_REGEXP = /(url\()([^)]*)(\))/g; | 504 var CSS_URL_REGEXP = /(url\()([^)]*)(\))/g; |
| 584 var CSS_IMPORT_REGEXP = /(@import[\s]+(?!url\())([^;]*)(;)/g; | 505 var CSS_IMPORT_REGEXP = /(@import[\s]+(?!url\())([^;]*)(;)/g; |
| 585 var path = { | 506 var path = { |
| 586 resolveUrlsInStyle: function(style, linkUrl) { | 507 resolveUrlsInStyle: function(style, linkUrl) { |
| 587 var doc = style.ownerDocument; | 508 var doc = style.ownerDocument; |
| 588 var resolver = doc.createElement("a"); | 509 var resolver = doc.createElement("a"); |
| 589 style.textContent = this.resolveUrlsInCssText(style.textContent, linkUrl,
resolver); | 510 style.textContent = this.resolveUrlsInCssText(style.textContent, linkUrl,
resolver); |
| 590 return style; | 511 return style; |
| 591 }, | 512 }, |
| 592 resolveUrlsInCssText: function(cssText, linkUrl, urlObj) { | 513 resolveUrlsInCssText: function(cssText, linkUrl, urlObj) { |
| 593 var r = this.replaceUrls(cssText, urlObj, linkUrl, CSS_URL_REGEXP); | 514 var r = this.replaceUrls(cssText, urlObj, linkUrl, CSS_URL_REGEXP); |
| 594 r = this.replaceUrls(r, urlObj, linkUrl, CSS_IMPORT_REGEXP); | 515 r = this.replaceUrls(r, urlObj, linkUrl, CSS_IMPORT_REGEXP); |
| 595 return r; | 516 return r; |
| 596 }, | 517 }, |
| 597 replaceUrls: function(text, urlObj, linkUrl, regexp) { | 518 replaceUrls: function(text, urlObj, linkUrl, regexp) { |
| 598 return text.replace(regexp, function(m, pre, url, post) { | 519 return text.replace(regexp, function(m, pre, url, post) { |
| 599 var urlPath = url.replace(/["']/g, ""); | 520 var urlPath = url.replace(/["']/g, ""); |
| 600 if (linkUrl) { | 521 if (linkUrl) { |
| 601 urlPath = new URL(urlPath, linkUrl).href; | 522 urlPath = new URL(urlPath, linkUrl).href; |
| 602 } | 523 } |
| 603 urlObj.href = urlPath; | 524 urlObj.href = urlPath; |
| 604 urlPath = urlObj.href; | 525 urlPath = urlObj.href; |
| 605 return pre + "'" + urlPath + "'" + post; | 526 return pre + "'" + urlPath + "'" + post; |
| 606 }); | 527 }); |
| 607 } | 528 } |
| 608 }; | 529 }; |
| 609 scope.path = path; | 530 scope.path = path; |
| 610 }); | 531 }); |
| 611 | 532 |
| 612 window.HTMLImports.addModule(function(scope) { | 533 HTMLImports.addModule(function(scope) { |
| 613 var xhr = { | 534 var xhr = { |
| 614 async: true, | 535 async: true, |
| 615 ok: function(request) { | 536 ok: function(request) { |
| 616 return request.status >= 200 && request.status < 300 || request.status ===
304 || request.status === 0; | 537 return request.status >= 200 && request.status < 300 || request.status ===
304 || request.status === 0; |
| 617 }, | 538 }, |
| 618 load: function(url, next, nextContext) { | 539 load: function(url, next, nextContext) { |
| 619 var request = new XMLHttpRequest(); | 540 var request = new XMLHttpRequest(); |
| 620 if (scope.flags.debug || scope.flags.bust) { | 541 if (scope.flags.debug || scope.flags.bust) { |
| 621 url += "?" + Math.random(); | 542 url += "?" + Math.random(); |
| 622 } | 543 } |
| 623 request.open("GET", url, xhr.async); | 544 request.open("GET", url, xhr.async); |
| 624 request.addEventListener("readystatechange", function(e) { | 545 request.addEventListener("readystatechange", function(e) { |
| 625 if (request.readyState === 4) { | 546 if (request.readyState === 4) { |
| 547 var locationHeader = request.getResponseHeader("Location"); |
| 626 var redirectedUrl = null; | 548 var redirectedUrl = null; |
| 627 try { | 549 if (locationHeader) { |
| 628 var locationHeader = request.getResponseHeader("Location"); | 550 var redirectedUrl = locationHeader.substr(0, 1) === "/" ? location.o
rigin + locationHeader : locationHeader; |
| 629 if (locationHeader) { | |
| 630 redirectedUrl = locationHeader.substr(0, 1) === "/" ? location.ori
gin + locationHeader : locationHeader; | |
| 631 } | |
| 632 } catch (e) { | |
| 633 console.error(e.message); | |
| 634 } | 551 } |
| 635 next.call(nextContext, !xhr.ok(request) && request, request.response |
| request.responseText, redirectedUrl); | 552 next.call(nextContext, !xhr.ok(request) && request, request.response |
| request.responseText, redirectedUrl); |
| 636 } | 553 } |
| 637 }); | 554 }); |
| 638 request.send(); | 555 request.send(); |
| 639 return request; | 556 return request; |
| 640 }, | 557 }, |
| 641 loadDocument: function(url, next, nextContext) { | 558 loadDocument: function(url, next, nextContext) { |
| 642 this.load(url, next, nextContext).responseType = "document"; | 559 this.load(url, next, nextContext).responseType = "document"; |
| 643 } | 560 } |
| 644 }; | 561 }; |
| 645 scope.xhr = xhr; | 562 scope.xhr = xhr; |
| 646 }); | 563 }); |
| 647 | 564 |
| 648 window.HTMLImports.addModule(function(scope) { | 565 HTMLImports.addModule(function(scope) { |
| 649 var xhr = scope.xhr; | 566 var xhr = scope.xhr; |
| 650 var flags = scope.flags; | 567 var flags = scope.flags; |
| 651 var Loader = function(onLoad, onComplete) { | 568 var Loader = function(onLoad, onComplete) { |
| 652 this.cache = {}; | 569 this.cache = {}; |
| 653 this.onload = onLoad; | 570 this.onload = onLoad; |
| 654 this.oncomplete = onComplete; | 571 this.oncomplete = onComplete; |
| 655 this.inflight = 0; | 572 this.inflight = 0; |
| 656 this.pending = {}; | 573 this.pending = {}; |
| 657 }; | 574 }; |
| 658 Loader.prototype = { | 575 Loader.prototype = { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 }, | 648 }, |
| 732 checkDone: function() { | 649 checkDone: function() { |
| 733 if (!this.inflight) { | 650 if (!this.inflight) { |
| 734 this.oncomplete(); | 651 this.oncomplete(); |
| 735 } | 652 } |
| 736 } | 653 } |
| 737 }; | 654 }; |
| 738 scope.Loader = Loader; | 655 scope.Loader = Loader; |
| 739 }); | 656 }); |
| 740 | 657 |
| 741 window.HTMLImports.addModule(function(scope) { | 658 HTMLImports.addModule(function(scope) { |
| 742 var Observer = function(addCallback) { | 659 var Observer = function(addCallback) { |
| 743 this.addCallback = addCallback; | 660 this.addCallback = addCallback; |
| 744 this.mo = new MutationObserver(this.handler.bind(this)); | 661 this.mo = new MutationObserver(this.handler.bind(this)); |
| 745 }; | 662 }; |
| 746 Observer.prototype = { | 663 Observer.prototype = { |
| 747 handler: function(mutations) { | 664 handler: function(mutations) { |
| 748 for (var i = 0, l = mutations.length, m; i < l && (m = mutations[i]); i++)
{ | 665 for (var i = 0, l = mutations.length, m; i < l && (m = mutations[i]); i++)
{ |
| 749 if (m.type === "childList" && m.addedNodes.length) { | 666 if (m.type === "childList" && m.addedNodes.length) { |
| 750 this.addedNodes(m.addedNodes); | 667 this.addedNodes(m.addedNodes); |
| 751 } | 668 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 764 observe: function(root) { | 681 observe: function(root) { |
| 765 this.mo.observe(root, { | 682 this.mo.observe(root, { |
| 766 childList: true, | 683 childList: true, |
| 767 subtree: true | 684 subtree: true |
| 768 }); | 685 }); |
| 769 } | 686 } |
| 770 }; | 687 }; |
| 771 scope.Observer = Observer; | 688 scope.Observer = Observer; |
| 772 }); | 689 }); |
| 773 | 690 |
| 774 window.HTMLImports.addModule(function(scope) { | 691 HTMLImports.addModule(function(scope) { |
| 775 var path = scope.path; | 692 var path = scope.path; |
| 776 var rootDocument = scope.rootDocument; | 693 var rootDocument = scope.rootDocument; |
| 777 var flags = scope.flags; | 694 var flags = scope.flags; |
| 778 var isIE = scope.isIE; | 695 var isIE = scope.isIE; |
| 779 var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE; | 696 var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE; |
| 780 var IMPORT_SELECTOR = "link[rel=" + IMPORT_LINK_TYPE + "]"; | 697 var IMPORT_SELECTOR = "link[rel=" + IMPORT_LINK_TYPE + "]"; |
| 781 var importParser = { | 698 var importParser = { |
| 782 documentSelectors: IMPORT_SELECTOR, | 699 documentSelectors: IMPORT_SELECTOR, |
| 783 importsSelectors: [ IMPORT_SELECTOR, "link[rel=stylesheet]:not([type])", "st
yle:not([type])", "script:not([type])", 'script[type="application/javascript"]',
'script[type="text/javascript"]' ].join(","), | 700 importsSelectors: [ IMPORT_SELECTOR, "link[rel=stylesheet]", "style", "scrip
t:not([type])", 'script[type="text/javascript"]' ].join(","), |
| 784 map: { | 701 map: { |
| 785 link: "parseLink", | 702 link: "parseLink", |
| 786 script: "parseScript", | 703 script: "parseScript", |
| 787 style: "parseStyle" | 704 style: "parseStyle" |
| 788 }, | 705 }, |
| 789 dynamicElements: [], | 706 dynamicElements: [], |
| 790 parseNext: function() { | 707 parseNext: function() { |
| 791 var next = this.nextToParse(); | 708 var next = this.nextToParse(); |
| 792 if (next) { | 709 if (next) { |
| 793 this.parse(next); | 710 this.parse(next); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 824 this.parsingElement = null; | 741 this.parsingElement = null; |
| 825 flags.parse && console.log("completed", elt); | 742 flags.parse && console.log("completed", elt); |
| 826 }, | 743 }, |
| 827 markDynamicParsingComplete: function(elt) { | 744 markDynamicParsingComplete: function(elt) { |
| 828 var i = this.dynamicElements.indexOf(elt); | 745 var i = this.dynamicElements.indexOf(elt); |
| 829 if (i >= 0) { | 746 if (i >= 0) { |
| 830 this.dynamicElements.splice(i, 1); | 747 this.dynamicElements.splice(i, 1); |
| 831 } | 748 } |
| 832 }, | 749 }, |
| 833 parseImport: function(elt) { | 750 parseImport: function(elt) { |
| 834 elt.import = elt.__doc; | 751 if (HTMLImports.__importsParsingHook) { |
| 835 if (window.HTMLImports.__importsParsingHook) { | 752 HTMLImports.__importsParsingHook(elt); |
| 836 window.HTMLImports.__importsParsingHook(elt); | |
| 837 } | 753 } |
| 838 if (elt.import) { | 754 if (elt.import) { |
| 839 elt.import.__importParsed = true; | 755 elt.import.__importParsed = true; |
| 840 } | 756 } |
| 841 this.markParsingComplete(elt); | 757 this.markParsingComplete(elt); |
| 842 if (elt.__resource && !elt.__error) { | 758 if (elt.__resource && !elt.__error) { |
| 843 elt.dispatchEvent(new CustomEvent("load", { | 759 elt.dispatchEvent(new CustomEvent("load", { |
| 844 bubbles: false | 760 bubbles: false |
| 845 })); | 761 })); |
| 846 } else { | 762 } else { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 } | 803 } |
| 888 return n; | 804 return n; |
| 889 }, | 805 }, |
| 890 addElementToDocument: function(elt) { | 806 addElementToDocument: function(elt) { |
| 891 var port = this.rootImportForElement(elt.__importElement || elt); | 807 var port = this.rootImportForElement(elt.__importElement || elt); |
| 892 port.parentNode.insertBefore(elt, port); | 808 port.parentNode.insertBefore(elt, port); |
| 893 }, | 809 }, |
| 894 trackElement: function(elt, callback) { | 810 trackElement: function(elt, callback) { |
| 895 var self = this; | 811 var self = this; |
| 896 var done = function(e) { | 812 var done = function(e) { |
| 897 elt.removeEventListener("load", done); | |
| 898 elt.removeEventListener("error", done); | |
| 899 if (callback) { | 813 if (callback) { |
| 900 callback(e); | 814 callback(e); |
| 901 } | 815 } |
| 902 self.markParsingComplete(elt); | 816 self.markParsingComplete(elt); |
| 903 self.parseNext(); | 817 self.parseNext(); |
| 904 }; | 818 }; |
| 905 elt.addEventListener("load", done); | 819 elt.addEventListener("load", done); |
| 906 elt.addEventListener("error", done); | 820 elt.addEventListener("error", done); |
| 907 if (isIE && elt.localName === "style") { | 821 if (isIE && elt.localName === "style") { |
| 908 var fakeLoad = false; | 822 var fakeLoad = false; |
| 909 if (elt.textContent.indexOf("@import") == -1) { | 823 if (elt.textContent.indexOf("@import") == -1) { |
| 910 fakeLoad = true; | 824 fakeLoad = true; |
| 911 } else if (elt.sheet) { | 825 } else if (elt.sheet) { |
| 912 fakeLoad = true; | 826 fakeLoad = true; |
| 913 var csr = elt.sheet.cssRules; | 827 var csr = elt.sheet.cssRules; |
| 914 var len = csr ? csr.length : 0; | 828 var len = csr ? csr.length : 0; |
| 915 for (var i = 0, r; i < len && (r = csr[i]); i++) { | 829 for (var i = 0, r; i < len && (r = csr[i]); i++) { |
| 916 if (r.type === CSSRule.IMPORT_RULE) { | 830 if (r.type === CSSRule.IMPORT_RULE) { |
| 917 fakeLoad = fakeLoad && Boolean(r.styleSheet); | 831 fakeLoad = fakeLoad && Boolean(r.styleSheet); |
| 918 } | 832 } |
| 919 } | 833 } |
| 920 } | 834 } |
| 921 if (fakeLoad) { | 835 if (fakeLoad) { |
| 922 setTimeout(function() { | 836 elt.dispatchEvent(new CustomEvent("load", { |
| 923 elt.dispatchEvent(new CustomEvent("load", { | 837 bubbles: false |
| 924 bubbles: false | 838 })); |
| 925 })); | |
| 926 }); | |
| 927 } | 839 } |
| 928 } | 840 } |
| 929 }, | 841 }, |
| 930 parseScript: function(scriptElt) { | 842 parseScript: function(scriptElt) { |
| 931 var script = document.createElement("script"); | 843 var script = document.createElement("script"); |
| 932 script.__importElement = scriptElt; | 844 script.__importElement = scriptElt; |
| 933 script.src = scriptElt.src ? scriptElt.src : generateScriptDataUrl(scriptE
lt); | 845 script.src = scriptElt.src ? scriptElt.src : generateScriptDataUrl(scriptE
lt); |
| 934 scope.currentScript = scriptElt; | 846 scope.currentScript = scriptElt; |
| 935 this.trackElement(script, function(e) { | 847 this.trackElement(script, function(e) { |
| 936 if (script.parentNode) { | 848 script.parentNode.removeChild(script); |
| 937 script.parentNode.removeChild(script); | |
| 938 } | |
| 939 scope.currentScript = null; | 849 scope.currentScript = null; |
| 940 }); | 850 }); |
| 941 this.addElementToDocument(script); | 851 this.addElementToDocument(script); |
| 942 }, | 852 }, |
| 943 nextToParse: function() { | 853 nextToParse: function() { |
| 944 this._mayParse = []; | 854 this._mayParse = []; |
| 945 return !this.parsingElement && (this.nextToParseInDoc(rootDocument) || thi
s.nextToParseDynamic()); | 855 return !this.parsingElement && (this.nextToParseInDoc(rootDocument) || thi
s.nextToParseDynamic()); |
| 946 }, | 856 }, |
| 947 nextToParseInDoc: function(doc, link) { | 857 nextToParseInDoc: function(doc, link) { |
| 948 if (doc && this._mayParse.indexOf(doc) < 0) { | 858 if (doc && this._mayParse.indexOf(doc) < 0) { |
| 949 this._mayParse.push(doc); | 859 this._mayParse.push(doc); |
| 950 var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc)); | 860 var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc)); |
| 951 for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) { | 861 for (var i = 0, l = nodes.length, p = 0, n; i < l && (n = nodes[i]); i++
) { |
| 952 if (!this.isParsed(n)) { | 862 if (!this.isParsed(n)) { |
| 953 if (this.hasResource(n)) { | 863 if (this.hasResource(n)) { |
| 954 return nodeIsImport(n) ? this.nextToParseInDoc(n.__doc, n) : n; | 864 return nodeIsImport(n) ? this.nextToParseInDoc(n.import, n) : n; |
| 955 } else { | 865 } else { |
| 956 return; | 866 return; |
| 957 } | 867 } |
| 958 } | 868 } |
| 959 } | 869 } |
| 960 } | 870 } |
| 961 return link; | 871 return link; |
| 962 }, | 872 }, |
| 963 nextToParseDynamic: function() { | 873 nextToParseDynamic: function() { |
| 964 return this.dynamicElements[0]; | 874 return this.dynamicElements[0]; |
| 965 }, | 875 }, |
| 966 parseSelectorsForNode: function(node) { | 876 parseSelectorsForNode: function(node) { |
| 967 var doc = node.ownerDocument || node; | 877 var doc = node.ownerDocument || node; |
| 968 return doc === rootDocument ? this.documentSelectors : this.importsSelecto
rs; | 878 return doc === rootDocument ? this.documentSelectors : this.importsSelecto
rs; |
| 969 }, | 879 }, |
| 970 isParsed: function(node) { | 880 isParsed: function(node) { |
| 971 return node.__importParsed; | 881 return node.__importParsed; |
| 972 }, | 882 }, |
| 973 needsDynamicParsing: function(elt) { | 883 needsDynamicParsing: function(elt) { |
| 974 return this.dynamicElements.indexOf(elt) >= 0; | 884 return this.dynamicElements.indexOf(elt) >= 0; |
| 975 }, | 885 }, |
| 976 hasResource: function(node) { | 886 hasResource: function(node) { |
| 977 if (nodeIsImport(node) && node.__doc === undefined) { | 887 if (nodeIsImport(node) && node.import === undefined) { |
| 978 return false; | 888 return false; |
| 979 } | 889 } |
| 980 return true; | 890 return true; |
| 981 } | 891 } |
| 982 }; | 892 }; |
| 983 function nodeIsImport(elt) { | 893 function nodeIsImport(elt) { |
| 984 return elt.localName === "link" && elt.rel === IMPORT_LINK_TYPE; | 894 return elt.localName === "link" && elt.rel === IMPORT_LINK_TYPE; |
| 985 } | 895 } |
| 986 function generateScriptDataUrl(script) { | 896 function generateScriptDataUrl(script) { |
| 987 var scriptContent = generateScriptContent(script); | 897 var scriptContent = generateScriptContent(script); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1001 function cloneStyle(style) { | 911 function cloneStyle(style) { |
| 1002 var clone = style.ownerDocument.createElement("style"); | 912 var clone = style.ownerDocument.createElement("style"); |
| 1003 clone.textContent = style.textContent; | 913 clone.textContent = style.textContent; |
| 1004 path.resolveUrlsInStyle(clone); | 914 path.resolveUrlsInStyle(clone); |
| 1005 return clone; | 915 return clone; |
| 1006 } | 916 } |
| 1007 scope.parser = importParser; | 917 scope.parser = importParser; |
| 1008 scope.IMPORT_SELECTOR = IMPORT_SELECTOR; | 918 scope.IMPORT_SELECTOR = IMPORT_SELECTOR; |
| 1009 }); | 919 }); |
| 1010 | 920 |
| 1011 window.HTMLImports.addModule(function(scope) { | 921 HTMLImports.addModule(function(scope) { |
| 1012 var flags = scope.flags; | 922 var flags = scope.flags; |
| 1013 var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE; | 923 var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE; |
| 1014 var IMPORT_SELECTOR = scope.IMPORT_SELECTOR; | 924 var IMPORT_SELECTOR = scope.IMPORT_SELECTOR; |
| 1015 var rootDocument = scope.rootDocument; | 925 var rootDocument = scope.rootDocument; |
| 1016 var Loader = scope.Loader; | 926 var Loader = scope.Loader; |
| 1017 var Observer = scope.Observer; | 927 var Observer = scope.Observer; |
| 1018 var parser = scope.parser; | 928 var parser = scope.parser; |
| 1019 var importer = { | 929 var importer = { |
| 1020 documents: {}, | 930 documents: {}, |
| 1021 documentPreloadSelectors: IMPORT_SELECTOR, | 931 documentPreloadSelectors: IMPORT_SELECTOR, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1041 if (isImportLink(elt)) { | 951 if (isImportLink(elt)) { |
| 1042 var doc = this.documents[url]; | 952 var doc = this.documents[url]; |
| 1043 if (doc === undefined) { | 953 if (doc === undefined) { |
| 1044 doc = err ? null : makeDocument(resource, redirectedUrl || url); | 954 doc = err ? null : makeDocument(resource, redirectedUrl || url); |
| 1045 if (doc) { | 955 if (doc) { |
| 1046 doc.__importLink = elt; | 956 doc.__importLink = elt; |
| 1047 this.bootDocument(doc); | 957 this.bootDocument(doc); |
| 1048 } | 958 } |
| 1049 this.documents[url] = doc; | 959 this.documents[url] = doc; |
| 1050 } | 960 } |
| 1051 elt.__doc = doc; | 961 elt.import = doc; |
| 1052 } | 962 } |
| 1053 parser.parseNext(); | 963 parser.parseNext(); |
| 1054 }, | 964 }, |
| 1055 bootDocument: function(doc) { | 965 bootDocument: function(doc) { |
| 1056 this.loadSubtree(doc); | 966 this.loadSubtree(doc); |
| 1057 this.observer.observe(doc); | 967 this.observer.observe(doc); |
| 1058 parser.parseNext(); | 968 parser.parseNext(); |
| 1059 }, | 969 }, |
| 1060 loadedAll: function() { | 970 loadedAll: function() { |
| 1061 parser.parseNext(); | 971 parser.parseNext(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 }, | 1010 }, |
| 1101 configurable: true | 1011 configurable: true |
| 1102 }; | 1012 }; |
| 1103 Object.defineProperty(document, "baseURI", baseURIDescriptor); | 1013 Object.defineProperty(document, "baseURI", baseURIDescriptor); |
| 1104 Object.defineProperty(rootDocument, "baseURI", baseURIDescriptor); | 1014 Object.defineProperty(rootDocument, "baseURI", baseURIDescriptor); |
| 1105 } | 1015 } |
| 1106 scope.importer = importer; | 1016 scope.importer = importer; |
| 1107 scope.importLoader = importLoader; | 1017 scope.importLoader = importLoader; |
| 1108 }); | 1018 }); |
| 1109 | 1019 |
| 1110 window.HTMLImports.addModule(function(scope) { | 1020 HTMLImports.addModule(function(scope) { |
| 1111 var parser = scope.parser; | 1021 var parser = scope.parser; |
| 1112 var importer = scope.importer; | 1022 var importer = scope.importer; |
| 1113 var dynamic = { | 1023 var dynamic = { |
| 1114 added: function(nodes) { | 1024 added: function(nodes) { |
| 1115 var owner, parsed, loading; | 1025 var owner, parsed, loading; |
| 1116 for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) { | 1026 for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) { |
| 1117 if (!owner) { | 1027 if (!owner) { |
| 1118 owner = n.ownerDocument; | 1028 owner = n.ownerDocument; |
| 1119 parsed = parser.isParsed(owner); | 1029 parsed = parser.isParsed(owner); |
| 1120 } | 1030 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1137 importer.observer.addCallback = dynamic.added.bind(dynamic); | 1047 importer.observer.addCallback = dynamic.added.bind(dynamic); |
| 1138 var matches = HTMLElement.prototype.matches || HTMLElement.prototype.matchesSe
lector || HTMLElement.prototype.webkitMatchesSelector || HTMLElement.prototype.m
ozMatchesSelector || HTMLElement.prototype.msMatchesSelector; | 1048 var matches = HTMLElement.prototype.matches || HTMLElement.prototype.matchesSe
lector || HTMLElement.prototype.webkitMatchesSelector || HTMLElement.prototype.m
ozMatchesSelector || HTMLElement.prototype.msMatchesSelector; |
| 1139 }); | 1049 }); |
| 1140 | 1050 |
| 1141 (function(scope) { | 1051 (function(scope) { |
| 1142 var initializeModules = scope.initializeModules; | 1052 var initializeModules = scope.initializeModules; |
| 1143 var isIE = scope.isIE; | 1053 var isIE = scope.isIE; |
| 1144 if (scope.useNative) { | 1054 if (scope.useNative) { |
| 1145 return; | 1055 return; |
| 1146 } | 1056 } |
| 1057 if (isIE && typeof window.CustomEvent !== "function") { |
| 1058 window.CustomEvent = function(inType, params) { |
| 1059 params = params || {}; |
| 1060 var e = document.createEvent("CustomEvent"); |
| 1061 e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelab
le), params.detail); |
| 1062 return e; |
| 1063 }; |
| 1064 window.CustomEvent.prototype = window.Event.prototype; |
| 1065 } |
| 1147 initializeModules(); | 1066 initializeModules(); |
| 1148 var rootDocument = scope.rootDocument; | 1067 var rootDocument = scope.rootDocument; |
| 1149 function bootstrap() { | 1068 function bootstrap() { |
| 1150 window.HTMLImports.importer.bootDocument(rootDocument); | 1069 HTMLImports.importer.bootDocument(rootDocument); |
| 1151 } | 1070 } |
| 1152 if (document.readyState === "complete" || document.readyState === "interactive
" && !window.attachEvent) { | 1071 if (document.readyState === "complete" || document.readyState === "interactive
" && !window.attachEvent) { |
| 1153 bootstrap(); | 1072 bootstrap(); |
| 1154 } else { | 1073 } else { |
| 1155 document.addEventListener("DOMContentLoaded", bootstrap); | 1074 document.addEventListener("DOMContentLoaded", bootstrap); |
| 1156 } | 1075 } |
| 1157 })(window.HTMLImports); | 1076 })(HTMLImports); |
| OLD | NEW |