vendor: 23,897 bytes, lines 1-836
1/** 2 * @license 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://polymer.github.io/LICENSE.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/CONTRIBUTORS.txt 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/PATENTS.txt 9 */ 10// @version 0.7.24 11(function() { 12 window.WebComponents = window.WebComponents || { 13 flags: {} 14 }; 15 var file = "webcomponents-lite.js"; 16 var script = document.querySelector('script[src*="' + file + '"]'); 17 var flags = {}; 18 if (!flags.noOpts) { 19 location.search.slice(1).split("&").forEach(function(option) { 20 var parts = option.split("="); 21 var match; 22 if (parts[0] && (match = parts[0].match(/wc-(.+)/))) { 23 flags[match[1]] = parts[1] || true; 24 } 25 }); 26 if (script) { 27 for (var i = 0, a; a = script.attributes[i]; i++) { 28 if (a.name !== "src") { 29 flags[a.name] = a.value || true; 30 } 31 } 32 } 33 if (flags.log && flags.log.split) { 34 var parts = flags.log.split(","); 35 flags.log = {}; 36 parts.forEach(function(f) { 37 flags.log[f] = true; 38 }); 39 } else { 40 flags.log = {}; 41 } 42 } 43 if (flags.register) { 44 window.CustomElements = window.CustomElements || { 45 flags: {} 46 }; 47 window.CustomElements.flags.register = flags.register; 48 } 49 WebComponents.flags = flags; 50 })(); 51 52 (function(scope) { 53 "use strict"; 54 var hasWorkingUrl = false; 55 if (!scope.forceJURL) { 56 try { 57 var u = new URL("b", "http://a"); 58 u.pathname = "c%20d"; 59 hasWorkingUrl = u.href === "http://a/c%20d"; 60 } catch (e) {} 61 } 62 if (hasWorkingUrl) return; 63 var relative = Object.create(null); 64 relative["ftp"] = 21; 65 relative["file"] = 0; 66 relative["gopher"] = 70; 67 relative["http"] = 80; 68 relative["https"] = 443; 69 relative["ws"] = 80; 70 relative["wss"] = 443; 71 var relativePathDotMapping = Object.create(null); 72 relativePathDotMapping["%2e"] = "."; 73 relativePathDotMapping[".%2e"] = ".."; 74 relativePathDotMapping["%2e."] = ".."; 75 relativePathDotMapping["%2e%2e"] = ".."; 76 function isRelativeScheme(scheme) { 77 return relative[scheme] !== undefined; 78 } 79 function invalid() { 80 clear.call(this); 81 this._isInvalid = true; 82 } 83 function IDNAToASCII(h) { 84 if ("" == h) { 85 invalid.call(this); 86 } 87 return h.toLowerCase(); 88 } 89 function percentEscape(c) { 90 var unicode = c.charCodeAt(0); 91 if (unicode > 32 && unicode < 127 && [ 34, 35, 60, 62, 63, 96 ].indexOf(unicode) == -1) { 92 return c; 93 } 94 return encodeURIComponent(c); 95 } 96 function percentEscapeQuery(c) { 97 var unicode = c.charCodeAt(0); 98 if (unicode > 32 && unicode < 127 && [ 34, 35, 60, 62, 96 ].indexOf(unicode) == -1) { 99 return c; 100 } 101 return encodeURIComponent(c); 102 } 103 var EOF = undefined, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/; 104 function parse(input, stateOverride, base) { 105 function err(message) { 106 errors.push(message); 107 } 108 var state = stateOverride || "scheme start", cursor = 0, buffer = "", seenAt = false, seenBracket = false, errors = []; 109 loop: while ((input[cursor - 1] != EOF || cursor == 0) && !this._isInvalid) { 110 var c = input[cursor]; 111 switch (state) { 112 case "scheme start": 113 if (c && ALPHA.test(c)) { 114 buffer += c.toLowerCase(); 115 state = "scheme"; 116 } else if (!stateOverride) { 117 buffer = ""; 118 state = "no scheme"; 119 continue; 120 } else { 121 err("Invalid scheme."); 122 break loop; 123 } 124 break; 125 126 case "scheme": 127 if (c && ALPHANUMERIC.test(c)) { 128 buffer += c.toLowerCase(); 129 } else if (":" == c) { 130 this._scheme = buffer; 131 buffer = ""; 132 if (stateOverride) { 133 break loop; 134 } 135 if (isRelativeScheme(this._scheme)) { 136 this._isRelative = true; 137 } 138 if ("file" == this._scheme) { 139 state = "relative"; 140 } else if (this._isRelative && base && base._scheme == this._scheme) { 141 state = "relative or authority"; 142 } else if (this._isRelative) { 143 state = "authority first slash"; 144 } else { 145 state = "scheme data"; 146 } 147 } else if (!stateOverride) { 148 buffer = ""; 149 cursor = 0; 150 state = "no scheme"; 151 continue; 152 } else if (EOF == c) { 153 break loop; 154 } else { 155 err("Code point not allowed in scheme: " + c); 156 break loop; 157 } 158 break; 159 160 case "scheme data": 161 if ("?" == c) { 162 this._query = "?"; 163 state = "query"; 164 } else if ("#" == c) { 165 this._fragment = "#"; 166 state = "fragment"; 167 } else { 168 if (EOF != c && "\t" != c && "\n" != c && "\r" != c) { 169 this._schemeData += percentEscape(c); 170 } 171 } 172 break; 173 174 case "no scheme": 175 if (!base || !isRelativeScheme(base._scheme)) { 176 err("Missing scheme."); 177 invalid.call(this); 178 } else { 179 state = "relative"; 180 continue; 181 } 182 break; 183 184 case "relative or authority": 185 if ("/" == c && "/" == input[cursor + 1]) { 186 state = "authority ignore slashes"; 187 } else { 188 err("Expected /, got: " + c); 189 state = "relative"; 190 continue; 191 } 192 break; 193 194 case "relative": 195 this._isRelative = true; 196 if ("file" != this._scheme) this._scheme = base._scheme; 197 if (EOF == c) { 198 this._host = base._host; 199 this._port = base._port; 200 this._path = base._path.slice(); 201 this._query = base._query; 202 this._username = base._username; 203 this._password = base._password; 204 break loop; 205 } else if ("/" == c || "\\" == c) { 206 if ("\\" == c) err("\\ is an invalid code point."); 207 state = "relative slash"; 208 } else if ("?" == c) { 209 this._host = base._host; 210 this._port = base._port; 211 this._path = base._path.slice(); 212 this._query = "?"; 213 this._username = base._username; 214 this._password = base._password; 215 state = "query"; 216 } else if ("#" == c) { 217 this._host = base._host; 218 this._port = base._port; 219 this._path = base._path.slice(); 220 this._query = base._query; 221 this._fragment = "#"; 222 this._username = base._username; 223 this._password = base._password; 224 state = "fragment"; 225 } else { 226 var nextC = input[cursor + 1]; 227 var nextNextC = input[cursor + 2]; 228 if ("file" != this._scheme || !ALPHA.test(c) || nextC != ":" && nextC != "|" || EOF != nextNextC && "/" != nextNextC && "\\" != nextNextC && "?" != nextNextC && "#" != nextNextC) { 229 this._host = base._host; 230 this._port = base._port; 231 this._username = base._username; 232 this._password = base._password; 233 this._path = base._path.slice(); 234 this._path.pop(); 235 } 236 state = "relative path"; 237 continue; 238 } 239 break; 240 241 case "relative slash": 242 if ("/" == c || "\\" == c) { 243 if ("\\" == c) { 244 err("\\ is an invalid code point."); 245 } 246 if ("file" == this._scheme) { 247 state = "file host"; 248 } else { 249 state = "authority ignore slashes"; 250 } 251 } else { 252 if ("file" != this._scheme) { 253 this._host = base._host; 254 this._port = base._port; 255 this._username = base._username; 256 this._password = base._password; 257 } 258 state = "relative path"; 259 continue; 260 } 261 break; 262 263 case "authority first slash": 264 if ("/" == c) { 265 state = "authority second slash"; 266 } else { 267 err("Expected '/', got: " + c); 268 state = "authority ignore slashes"; 269 continue; 270 } 271 break; 272 273 case "authority second slash": 274 state = "authority ignore slashes"; 275 if ("/" != c) { 276 err("Expected '/', got: " + c); 277 continue; 278 } 279 break; 280 281 case "authority ignore slashes": 282 if ("/" != c && "\\" != c) { 283 state = "authority"; 284 continue; 285 } else { 286 err("Expected authority, got: " + c); 287 } 288 break; 289 290 case "authority": 291 if ("@" == c) { 292 if (seenAt) { 293 err("@ already seen."); 294 buffer += "%40"; 295 } 296 seenAt = true; 297 for (var i = 0; i < buffer.length; i++) { 298 var cp = buffer[i]; 299 if ("\t" == cp || "\n" == cp || "\r" == cp) { 300 err("Invalid whitespace in authority."); 301 continue; 302 } 303 if (":" == cp && null === this._password) { 304 this._password = ""; 305 continue; 306 } 307 var tempC = percentEscape(cp); 308 null !== this._password ? this._password += tempC : this._username += tempC; 309 } 310 buffer = ""; 311 } else if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c) { 312 cursor -= buffer.length; 313 buffer = ""; 314 state = "host"; 315 continue; 316 } else { 317 buffer += c; 318 } 319 break; 320 321 case "file host": 322 if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c) { 323 if (buffer.length == 2 && ALPHA.test(buffer[0]) && (buffer[1] == ":" || buffer[1] == "|")) { 324 state = "relative path"; 325 } else if (buffer.length == 0) { 326 state = "relative path start"; 327 } else { 328 this._host = IDNAToASCII.call(this, buffer); 329 buffer = ""; 330 state = "relative path start"; 331 } 332 continue; 333 } else if ("\t" == c || "\n" == c || "\r" == c) { 334 err("Invalid whitespace in file host."); 335 } else { 336 buffer += c; 337 } 338 break; 339 340 case "host": 341 case "hostname": 342 if (":" == c && !seenBracket) { 343 this._host = IDNAToASCII.call(this, buffer); 344 buffer = ""; 345 state = "port"; 346 if ("hostname" == stateOverride) { 347 break loop; 348 } 349 } else if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c) { 350 this._host = IDNAToASCII.call(this, buffer); 351 buffer = ""; 352 state = "relative path start"; 353 if (stateOverride) { 354 break loop; 355 } 356 continue; 357 } else if ("\t" != c && "\n" != c && "\r" != c) { 358 if ("[" == c) { 359 seenBracket = true; 360 } else if ("]" == c) { 361 seenBracket = false; 362 } 363 buffer += c; 364 } else { 365 err("Invalid code point in host/hostname: " + c); 366 } 367 break; 368 369 case "port": 370 if (/[0-9]/.test(c)) { 371 buffer += c; 372 } else if (EOF == c || "/" == c || "\\" == c || "?" == c || "#" == c || stateOverride) { 373 if ("" != buffer) { 374 var temp = parseInt(buffer, 10); 375 if (temp != relative[this._scheme]) { 376 this._port = temp + ""; 377 } 378 buffer = ""; 379 } 380 if (stateOverride) { 381 break loop; 382 } 383 state = "relative path start"; 384 continue; 385 } else if ("\t" == c || "\n" == c || "\r" == c) { 386 err("Invalid code point in port: " + c); 387 } else { 388 invalid.call(this); 389 } 390 break; 391 392 case "relative path start": 393 if ("\\" == c) err("'\\' not allowed in path."); 394 state = "relative path"; 395 if ("/" != c && "\\" != c) { 396 continue; 397 } 398 break; 399 400 case "relative path": 401 if (EOF == c || "/" == c || "\\" == c || !stateOverride && ("?" == c || "#" == c)) { 402 if ("\\" == c) { 403 err("\\ not allowed in relative path."); 404 } 405 var tmp; 406 if (tmp = relativePathDotMapping[buffer.toLowerCase()]) { 407 buffer = tmp; 408 } 409 if (".." == buffer) { 410 this._path.pop(); 411 if ("/" != c && "\\" != c) { 412 this._path.push(""); 413 } 414 } else if ("." == buffer && "/" != c && "\\" != c) { 415 this._path.push(""); 416 } else if ("." != buffer) { 417 if ("file" == this._scheme && this._path.length == 0 && buffer.length == 2 && ALPHA.test(buffer[0]) && buffer[1] == "|") { 418 buffer = buffer[0] + ":"; 419 } 420 this._path.push(buffer); 421 } 422 buffer = ""; 423 if ("?" == c) { 424 this._query = "?"; 425 state = "query"; 426 } else if ("#" == c) { 427 this._fragment = "#"; 428 state = "fragment"; 429 } 430 } else if ("\t" != c && "\n" != c && "\r" != c) { 431 buffer += percentEscape(c); 432 } 433 break; 434 435 case "query": 436 if (!stateOverride && "#" == c) { 437 this._fragment = "#"; 438 state = "fragment"; 439 } else if (EOF != c && "\t" != c && "\n" != c && "\r" != c) { 440 this._query += percentEscapeQuery(c); 441 } 442 break; 443 444 case "fragment": 445 if (EOF != c && "\t" != c && "\n" != c && "\r" != c) { 446 this._fragment += c; 447 } 448 break; 449 } 450 cursor++; 451 } 452 } 453 function clear() { 454 this._scheme = ""; 455 this._schemeData = ""; 456 this._username = ""; 457 this._password = null; 458 this._host = ""; 459 this._port = ""; 460 this._path = []; 461 this._query = ""; 462 this._fragment = ""; 463 this._isInvalid = false; 464 this._isRelative = false; 465 } 466 function jURL(url, base) { 467 if (base !== undefined && !(base instanceof jURL)) base = new jURL(String(base)); 468 this._url = url; 469 clear.call(this); 470 var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, ""); 471 parse.call(this, input, null, base); 472 } 473 jURL.prototype = { 474 toString: function() { 475 return this.href; 476 }, 477 get href() { 478 if (this._isInvalid) return this._url; 479 var authority = ""; 480 if ("" != this._username || null != this._password) { 481 authority = this._username + (null != this._password ? ":" + this._password : "") + "@"; 482 } 483 return this.protocol + (this._isRelative ? "//" + authority + this.host : "") + this.pathname + this._query + this._fragment; 484 }, 485 set href(href) { 486 clear.call(this); 487 parse.call(this, href); 488 }, 489 get protocol() { 490 return this._scheme + ":"; 491 }, 492 set protocol(protocol) { 493 if (this._isInvalid) return; 494 parse.call(this, protocol + ":", "scheme start"); 495 }, 496 get host() { 497 return this._isInvalid ? "" : this._port ? this._host + ":" + this._port : this._host; 498 }, 499 set host(host) { 500 if (this._isInvalid || !this._isRelative) return; 501 parse.call(this, host, "host"); 502 }, 503 get hostname() { 504 return this._host; 505 }, 506 set hostname(hostname) { 507 if (this._isInvalid || !this._isRelative) return; 508 parse.call(this, hostname, "hostname"); 509 }, 510 get port() { 511 return this._port; 512 }, 513 set port(port) { 514 if (this._isInvalid || !this._isRelative) return; 515 parse.call(this, port, "port"); 516 }, 517 get pathname() { 518 return this._isInvalid ? "" : this._isRelative ? "/" + this._path.join("/") : this._schemeData; 519 }, 520 set pathname(pathname) { 521 if (this._isInvalid || !this._isRelative) return; 522 this._path = []; 523 parse.call(this, pathname, "relative path start"); 524 }, 525 get search() { 526 return this._isInvalid || !this._query || "?" == this._query ? "" : this._query; 527 }, 528 set search(search) { 529 if (this._isInvalid || !this._isRelative) return; 530 this._query = "?"; 531 if ("?" == search[0]) search = search.slice(1); 532 parse.call(this, search, "query"); 533 }, 534 get hash() { 535 return this._isInvalid || !this._fragment || "#" == this._fragment ? "" : this._fragment; 536 }, 537 set hash(hash) { 538 if (this._isInvalid) return; 539 this._fragment = "#"; 540 if ("#" == hash[0]) hash = hash.slice(1); 541 parse.call(this, hash, "fragment"); 542 }, 543 get origin() { 544 var host; 545 if (this._isInvalid || !this._scheme) { 546 return ""; 547 } 548 switch (this._scheme) { 549 case "data": 550 case "file": 551 case "javascript": 552 case "mailto": 553 return "null"; 554 } 555 host = this.host; 556 if (!host) { 557 return ""; 558 } 559 return this._scheme + "://" + host; 560 } 561 }; 562 var OriginalURL = scope.URL; 563 if (OriginalURL) { 564 jURL.createObjectURL = function(blob) { 565 return OriginalURL.createObjectURL.apply(OriginalURL, arguments); 566 }; 567 jURL.revokeObjectURL = function(url) { 568 OriginalURL.revokeObjectURL(url); 569 }; 570 } 571 scope.URL = jURL; 572 })(self); 573 574 if (typeof WeakMap === "undefined") { 575 (function() { 576 var defineProperty = Object.defineProperty; 577 var counter = Date.now() % 1e9; 578 var WeakMap = function() { 579 this.name = "__st" + (Math.random() * 1e9 >>> 0) + (counter++ + "__"); 580 }; 581 WeakMap.prototype = { 582 set: function(key, value) { 583 var entry = key[this.name]; 584 if (entry && entry[0] === key) entry[1] = value; else defineProperty(key, this.name, { 585 value: [ key, value ], 586 writable: true 587 }); 588 return this; 589 }, 590 get: function(key) { 591 var entry; 592 return (entry = key[this.name]) && entry[0] === key ? entry[1] : undefined; 593 }, 594 "delete": function(key) { 595 var entry = key[this.name]; 596 if (!entry || entry[0] !== key) return false; 597 entry[0] = entry[1] = undefined; 598 return true; 599 }, 600 has: function(key) { 601 var entry = key[this.name]; 602 if (!entry) return false; 603 return entry[0] === key; 604 } 605 }; 606 window.WeakMap = WeakMap; 607 })(); 608 } 609 610 (function(global) { 611 if (global.JsMutationObserver) { 612 return; 613 } 614 var registrationsTable = new WeakMap(); 615 var setImmediate; 616 if (/Trident|Edge/.test(navigator.userAgent)) { 617 setImmediate = setTimeout; 618 } else if (window.setImmediate) { 619 setImmediate = window.setImmediate; 620 } else { 621 var setImmediateQueue = []; 622 var sentinel = String(Math.random()); 623 window.addEventListener("message", function(e) { 624 if (e.data === sentinel) { 625 var queue = setImmediateQueue; 626 setImmediateQueue = []; 627 queue.forEach(function(func) { 628 func(); 629 }); 630 } 631 }); 632 setImmediate = function(func) { 633 setImmediateQueue.push(func); 634 window.postMessage(sentinel, "*"); 635 }; 636 } 637 var isScheduled = false; 638 var scheduledObservers = []; 639 function scheduleCallback(observer) { 640 scheduledObservers.push(observer); 641 if (!isScheduled) { 642 isScheduled = true; 643 setImmediate(dispatchCallbacks); 644 } 645 } 646 function wrapIfNeeded(node) { 647 return window.ShadowDOMPolyfill && window.ShadowDOMPolyfill.wrapIfNeeded(node) || node; 648 } 649 function dispatchCallbacks() { 650 isScheduled = false; 651 var observers = scheduledObservers; 652 scheduledObservers = []; 653 observers.sort(function(o1, o2) { 654 return o1.uid_ - o2.uid_; 655 }); 656 var anyNonEmpty = false; 657 observers.forEach(function(observer) { 658 var queue = observer.takeRecords(); 659 removeTransientObserversFor(observer); 660 if (queue.length) { 661 observer.callback_(queue, observer); 662 anyNonEmpty = true; 663 } 664 }); 665 if (anyNonEmpty) dispatchCallbacks(); 666 } 667 function removeTransientObserversFor(observer) { 668 observer.nodes_.forEach(function(node) { 669 var registrations = registrationsTable.get(node); 670 if (!registrations) return; 671 registrations.forEach(function(registration) { 672 if (registration.observer === observer) registration.removeTransientObservers(); 673 }); 674 }); 675 } 676 function forEachAncestorAndObserverEnqueueRecord(target, callback) { 677 for (var node = target; node; node = node.parentNode) { 678 var registrations = registrationsTable.get(node); 679 if (registrations) { 680 for (var j = 0; j < registrations.length; j++) { 681 var registration = registrations[j]; 682 var options = registration.options; 683 if (node !== target && !options.subtree) continue; 684 var record = callback(options); 685 if (record) registration.enqueue(record); 686 } 687 } 688 } 689 } 690 var uidCounter = 0; 691 function JsMutationObserver(callback) { 692 this.callback_ = callback; 693 this.nodes_ = []; 694 this.records_ = []; 695 this.uid_ = ++uidCounter; 696 } 697 JsMutationObserver.prototype = { 698 observe: function(target, options) { 699 target = wrapIfNeeded(target); 700 if (!options.childList && !options.attributes && !options.characterData || options.attributeOldValue && !options.attributes || options.attributeFilter && options.attributeFilter.length && !options.attributes || options.characterDataOldValue && !options.characterData) { 701 throw new SyntaxError(); 702 } 703 var registrations = registrationsTable.get(target); 704 if (!registrations) registrationsTable.set(target, registrations = []); 705 var registration; 706 for (var i = 0; i < registrations.length; i++) { 707 if (registrations[i].observer === this) { 708 registration = registrations[i]; 709 registration.removeListeners(); 710 registration.options = options; 711 break; 712 } 713 } 714 if (!registration) { 715 registration = new Registration(this, target, options); 716 registrations.push(registration); 717 this.nodes_.push(target); 718 } 719 registration.addListeners(); 720 }, 721 disconnect: function() { 722 this.nodes_.forEach(function(node) { 723 var registrations = registrationsTable.get(node); 724 for (var i = 0; i < registrations.length; i++) { 725 var registration = registrations[i]; 726 if (registration.observer === this) { 727 registration.removeListeners(); 728 registrations.splice(i, 1); 729 break; 730 } 731 } 732 }, this); 733 this.records_ = []; 734 }, 735 takeRecords: function() { 736 var copyOfRecords = this.records_; 737 this.records_ = []; 738 return copyOfRecords; 739 } 740 }; 741 function MutationRecord(type, target) { 742 this.type = type; 743 this.target = target; 744 this.addedNodes = []; 745 this.removedNodes = []; 746 this.previousSibling = null; 747 this.nextSibling = null; 748 this.attributeName = null; 749 this.attributeNamespace = null; 750 this.oldValue = null; 751 } 752 function copyMutationRecord(original) { 753 var record = new MutationRecord(original.type, original.target); 754 record.addedNodes = original.addedNodes.slice(); 755 record.removedNodes = original.removedNodes.slice(); 756 record.previousSibling = original.previousSibling; 757 record.nextSibling = original.nextSibling; 758 record.attributeName = original.attributeName; 759 record.attributeNamespace = original.attributeNamespace; 760 record.oldValue = original.oldValue; 761 return record; 762 } 763 var currentRecord, recordWithOldValue; 764 function getRecord(type, target) { 765 return currentRecord = new MutationRecord(type, target); 766 } 767 function getRecordWithOldValue(oldValue) { 768 if (recordWithOldValue) return recordWithOldValue; 769 recordWithOldValue = copyMutationRecord(currentRecord); 770 recordWithOldValue.oldValue = oldValue; 771 return recordWithOldValue; 772 } 773 function clearRecords() { 774 currentRecord = recordWithOldValue = undefined; 775 } 776 function recordRepresentsCurrentMutation(record) { 777 return record === recordWithOldValue || record === currentRecord; 778 } 779 function selectRecord(lastRecord, newRecord) { 780 if (lastRecord === newRecord) return lastRecord; 781 if (recordWithOldValue && recordRepresentsCurrentMutation(lastRecord)) return recordWithOldValue; 782 return null; 783 } 784 function Registration(observer, target, options) { 785 this.observer = observer; 786 this.target = target; 787 this.options = options; 788 this.transientObservedNodes = []; 789 } 790 Registration.prototype = { 791 enqueue: function(record) { 792 var records = this.observer.records_; 793 var length = records.length; 794 if (records.length > 0) { 795 var lastRecord = records[length - 1]; 796 var recordToReplaceLast = selectRecord(lastRecord, record); 797 if (recordToReplaceLast) { 798 records[length - 1] = recordToReplaceLast; 799 return; 800 } 801 } else { 802 scheduleCallback(this.observer); 803 } 804 records[length] = record; 805 }, 806 addListeners: function() { 807 this.addListeners_(this.target); 808 }, 809 addListeners_: function(node) { 810 var options = this.options; 811 if (options.attributes) node.addEventListener("DOMAttrModified", this, true); 812 if (options.characterData) node.addEventListener("DOMCharacterDataModified", this, true); 813 if (options.childList) node.addEventListener("DOMNodeInserted", this, true); 814 if (options.childList || options.subtree) node.addEventListener("DOMNodeRemoved", this, true); 815 }, 816 removeListeners: function() { 817 this.removeListeners_(this.target); 818 }, 819 removeListeners_: function(node) { 820 var options = this.options; 821 if (options.attributes) node.removeEventListener("DOMAttrModified", this, true); 822 if (options.characterData) node.removeEventListener("DOMCharacterDataModified", this, true); 823 if (options.childList) node.removeEventListener("DOMNodeInserted", this, true); 824 if (options.childList || options.subtree) node.removeEventListener("DOMNodeRemoved", this, true); 825 }, 826 addTransientObserver: function(node) { 827 if (node === this.target) return; 828 this.addListeners_(node); 829 this.transientObservedNodes.push(node); 830 var registrations = registrationsTable.get(node); 831 if (!registrations) registrationsTable.set(node, registrations = []); 832 registrations.push(this); 833 }, 834 removeTransientObservers: function() { 835 var transientObservedNodes = this.transientObservedNodes; 836 this.transientObservedNodes = [];
837 transientObservedNodes.forEach(function(node) { 838 this.removeListeners_(node); 839 var registrations = registrationsTable.get(node); 840 for (var i = 0; i < registrations.length; i++) { 841 if (registrations[i] === this) { 842 registrations.splice(i, 1); 843 break; 844 } 845 } 846 }, this); 847 }, 848 handleEvent: function(e) { 849 e.stopImmediatePropagation(); 850 switch (e.type) { 851 case "DOMAttrModified": 852 var name = e.attrName; 853 var namespace = e.relatedNode.namespaceURI; 854 var target = e.target; 855 var record = new getRecord("attributes", target); 856 record.attributeName = name; 857 record.attributeNamespace = namespace; 858 var oldValue = e.attrChange === MutationEvent.ADDITION ? null : e.prevValue; 859 forEachAncestorAndObserverEnqueueRecord(target, function(options) { 860 if (!options.attributes) return; 861 if (options.attributeFilter && options.attributeFilter.length && options.attributeFilter.indexOf(name) === -1 && options.attributeFilter.indexOf(namespace) === -1) { 862 return; 863 } 864 if (options.attributeOldValue) return getRecordWithOldValue(oldValue); 865 return record; 866 }); 867 break; 868 869 case "DOMCharacterDataModified": 870 var target = e.target; 871 var record = getRecord("characterData", target); 872 var oldValue = e.prevValue; 873 forEachAncestorAndObserverEnqueueRecord(target, function(options) { 874 if (!options.characterData) return; 875 if (options.characterDataOldValue) return getRecordWithOldValue(oldValue); 876 return record; 877 }); 878 break; 879 880 case "DOMNodeRemoved": 881 this.addTransientObserver(e.target); 882 883 case "DOMNodeInserted": 884 var changedNode = e.target; 885 var addedNodes, removedNodes; 886 if (e.type === "DOMNodeInserted") { 887 addedNodes = [ changedNode ]; 888 removedNodes = []; 889 } else { 890 addedNodes = []; 891 removedNodes = [ changedNode ]; 892 } 893 var previousSibling = changedNode.previousSibling; 894 var nextSibling = changedNode.nextSibling; 895 var record = getRecord("childList", e.target.parentNode); 896 record.addedNodes = addedNodes; 897 record.removedNodes = removedNodes; 898 record.previousSibling = previousSibling; 899 record.nextSibling = nextSibling; 900 forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function(options) { 901 if (!options.childList) return; 902 return record; 903 }); 904 } 905 clearRecords(); 906 } 907 }; 908 global.JsMutationObserver = JsMutationObserver; 909 if (!global.MutationObserver) { 910 global.MutationObserver = JsMutationObserver; 911 JsMutationObserver._isPolyfilled = true; 912 } 913 })(self); 914 915 (function(self, undefined) {function Call(t,l){var n=arguments.length>2?arguments[2]:[];if(!1===IsCallable(t))throw new TypeError(Object.prototype.toString.call(t)+"is not a function.");return t.apply(l,n)}function CreateMethodProperty(e,r,t){var a={value:t,writable:!0,enumerable:!1,configurable:!0};Object.defineProperty(e,r,a)}function Get(n,t){return n[t]}function HasOwnProperty(r,t){return Object.prototype.hasOwnProperty.call(r,t)}function IsCallable(n){return"function"==typeof n}function SameValueNonNumber(e,n){return e===n}function ToInteger(n){var i=Number(n);return isNaN(i)?0:1/i===Infinity||1/i==-Infinity||i===Infinity||i===-Infinity?i:(i<0?-1:1)*Math.floor(Math.abs(i))}function ToLength(n){var t=ToInteger(n);return t<=0?0:Math.min(t,Math.pow(2,53)-1)}function ToObject(e){if(null===e||e===undefined)throw TypeError();return Object(e)}function GetV(t,e){return ToObject(t)[e]}function GetMethod(e,n){var r=GetV(e,n);if(null===r||r===undefined)return undefined;if(!1===IsCallable(r))throw new TypeError("Method not callable: "+n);return r}function Type(e){switch(typeof e){case"undefined":return"undefined";case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"symbol":return"symbol";default:return null===e?"null":"Symbol"in self&&(e instanceof self.Symbol||e.constructor===self.Symbol)?"symbol":"object"}}function OrdinaryToPrimitive(r,t){if("string"===t)var e=["toString","valueOf"];else e=["valueOf","toString"];for(var i=0;i<e.length;++i){var n=e[i],a=Get(r,n);if(IsCallable(a)){var o=Call(a,r);if("object"!==Type(o))return o}}throw new TypeError("Cannot convert to primitive.")}function SameValueZero(n,e){return Type(n)===Type(e)&&("number"===Type(n)?!(!isNaN(n)||!isNaN(e))||(1/n===Infinity&&1/e==-Infinity||(1/n==-Infinity&&1/e===Infinity||n===e)):SameValueNonNumber(n,e))}function ToPrimitive(e){var t=arguments.length>1?arguments[1]:undefined;if("object"===Type(e)){if(arguments.length<2)var i="default";else t===String?i="string":t===Number&&(i="number");var r="function"==typeof self.Symbol&&"symbol"==typeof self.Symbol.toPrimitive?GetMethod(e,self.Symbol.toPrimitive):undefined;if(r!==undefined){var n=Call(r,e,[i]);if("object"!==Type(n))return n;throw new TypeError("Cannot convert exotic object to primitive.")}return"default"===i&&(i="number"),OrdinaryToPrimitive(e,i)}return e}function ToString(t){switch(Type(t)){case"symbol":throw new TypeError("Cannot convert a Symbol value to a string");case"object":return ToString(ToPrimitive(t,String));default:return String(t)}}function ToPropertyKey(r){var i=ToPrimitive(r,String);return"symbol"===Type(i)?i:ToString(i)}CreateMethodProperty(Array.prototype,"includes",function e(r){"use strict";var t=ToObject(this),o=ToLength(Get(t,"length"));if(0===o)return!1;var n=ToInteger(arguments[1]);if(n>=0)var a=n;else(a=o+n)<0&&(a=0);for(;a<o;){var i=Get(t,ToString(a));if(SameValueZero(r,i))return!0;a+=1}return!1});!function(){function e(e,t){if(!e)throw new Error("Not enough arguments");var n;if("createEvent"in document){n=document.createEvent("Event");var o=!(!t||t.bubbles===undefined)&&t.bubbles,i=!(!t||t.cancelable===undefined)&&t.cancelable;return n.initEvent(e,o,i),n}return n=document.createEventObject(),n.type=e,n.bubbles=!(!t||t.bubbles===undefined)&&t.bubbles,n.cancelable=!(!t||t.cancelable===undefined)&&t.cancelable,n}
915var t={click:1,dblclick:1,keyup:1,keypress:1,keydown:1,mousedown:1,mouseup:1,mousemove:1,mouseover:1,mouseenter:1,mouseleave:1,mouseout:1,storage:1,storagecommit:1,textinput:1};if("undefined"!=typeof document&&"undefined"!=typeof window){var n=window.Event&&window.Event.prototype||null;e.NONE=0,e.CAPTURING_PHASE=1,e.AT_TARGET=2,e.BUBBLING_PHASE=3,window.Event=Window.prototype.Event=e,n&&Object.defineProperty(window.Event,"prototype",{configurable:!1,enumerable:!1,writable:!0,value:n}),"createEvent"in document||(window.addEventListener=Window.prototype.addEventListener=Document.prototype.addEventListener=Element.prototype.addEventListener=function o(){var e=this,n=arguments[0],o=arguments[1];if(e===window&&n in t)throw new Error("In IE8 the event: "+n+" is not available on the window object. Please see https://github.com/Financial-Times/polyfill-service/issues/317 for more information.");e._events||(e._events={}),e._events[n]||(e._events[n]=function(t){var n,o=e._events[t.type].list,i=o.slice(),r=-1,c=i.length;for(t.preventDefault=function a(){!1!==t.cancelable&&(t.returnValue=!1)},t.stopPropagation=function l(){t.cancelBubble=!0},t.stopImmediatePropagation=function s(){t.cancelBubble=!0,t.cancelImmediate=!0},t.currentTarget=e,t.relatedTarget=t.fromElement||null,t.target=t.target||t.srcElement||e,t.timeStamp=(new Date).getTime(),t.clientX&&(t.pageX=t.clientX+document.documentElement.scrollLeft,t.pageY=t.clientY+document.documentElement.scrollTop);++r<c&&!t.cancelImmediate;)r in i&&(n=i[r],o.includes(n)&&"function"==typeof n&&n.call(e,t))},e._events[n].list=[],e.attachEvent&&e.attachEvent("on"+n,e._events[n])),e._events[n].list.push(o)},window.removeEventListener=Window.prototype.removeEventListener=Document.prototype.removeEventListener=Element.prototype.removeEventListener=function i(){var e,t=this,n=arguments[0],o=arguments[1];t._events&&t._events[n]&&t._events[n].list&&-1!==(e=t._events[n].list.indexOf(o))&&(t._events[n].list.splice(e,1),t._events[n].list.length||(t.detachEvent&&t.detachEvent("on"+n,t._events[n]),delete t._events[n]))},window.dispatchEvent=Window.prototype.dispatchEvent=Document.prototype.dispatchEvent=Element.prototype.dispatchEvent=function r(e){if(!arguments.length)throw new Error("Not enough arguments");if(!e||"string"!=typeof e.type)throw new Error("DOM Events Exception 0");var t=this,n=e.type;try{if(!e.bubbles){e.cancelBubble=!0;var o=function(e){e.cancelBubble=!0,(t||window).detachEvent("on"+n,o)};this.attachEvent("on"+n,o)}this.fireEvent("on"+n,e)}catch(i){e.target=t;do{e.currentTarget=t,"_events"in t&&"function"==typeof t._events[n]&&t._events[n].call(t,e),"function"==typeof t["on"+n]&&t["on"+n].call(t,e),t=9===t.nodeType?t.parentWindow:t.parentNode}while(t&&!e.cancelBubble)}return!0},document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&document.dispatchEvent(new e("DOMContentLoaded",{bubbles:!0}))}))}}();!function(){var e=Object.getOwnPropertyDescriptor,t=function(){try{return 1===Object.defineProperty(document.createElement("div"),"one",{get:function(){return 1}}).one}catch(e){return!1}},r={}.toString,n="".split;CreateMethodProperty(Object,"getOwnPropertyDescriptor",function c(o,i){var a=ToObject(o);a=("string"===Type(a)||a instanceof String)&&"[object String]"==r.call(o)?n.call(o,""):Object(o);var u=ToPropertyKey(i);if(t)try{return e(a,u)}catch(l){}if(HasOwnProperty(a,u))return{enumerable:!0,configurable:!0,writable:!0,value:a[u]}})}();!function(){"use strict";function e(e,t){if(!e.childNodes.length)return[];switch(e.nodeType){case Node.DOCUMENT_NODE:return f.call(e,t);case Node.DOCUMENT_FRAGMENT_NODE:return h.call(e,t);default:return s.call(e,t)}}var t="undefined"==typeof HTMLTemplateElement,o=!(document.createDocumentFragment().cloneNode()instanceof DocumentFragment),n=!1;/Trident/.test(navigator.userAgent)&&function(){function e(e,t){if(e instanceof DocumentFragment)for(var n;n=e.firstChild;)o.call(this,n,t);else o.call(this,e,t);return e}n=!0;var t=Node.prototype.cloneNode;Node.prototype.cloneNode=function i(e){var o=t.call(this,e);return this instanceof DocumentFragment&&(o.__proto__=DocumentFragment.prototype),o},DocumentFragment.prototype.querySelectorAll=HTMLElement.prototype.querySelectorAll,DocumentFragment.prototype.querySelector=HTMLElement.prototype.querySelector,Object.defineProperties(DocumentFragment.prototype,{nodeType:{get:function(){return Node.DOCUMENT_FRAGMENT_NODE}
915,configurable:!0},localName:{get:function(){return undefined},configurable:!0},nodeName:{get:function(){return"#document-fragment"},configurable:!0}});var o=Node.prototype.insertBefore;Node.prototype.insertBefore=e;var r=Node.prototype.appendChild;Node.prototype.appendChild=function p(t){return t instanceof DocumentFragment?e.call(this,t,null):r.call(this,t),t};var c=Node.prototype.removeChild,a=Node.prototype.replaceChild;Node.prototype.replaceChild=function u(t,o){return t instanceof DocumentFragment?(e.call(this,t,o),c.call(this,o)):a.call(this,t,o),o},Document.prototype.createDocumentFragment=function d(){var e=this.createElement("df");return e.__proto__=DocumentFragment.prototype,e};var l=Document.prototype.importNode;Document.prototype.importNode=function m(e,t){t=t||!1;var o=l.call(this,e,t);return e instanceof DocumentFragment&&(o.__proto__=DocumentFragment.prototype),o}}();var r=Node.prototype.cloneNode,c=Document.prototype.createElement,a=Document.prototype.importNode,l=Node.prototype.removeChild,i=Node.prototype.appendChild,p=Node.prototype.replaceChild,u=DOMParser.prototype.parseFromString,d=Object.getOwnPropertyDescriptor(window.HTMLElement.prototype,"innerHTML")||{get:function(){return this.innerHTML},set:function(e){this.innerHTML=e}},m=Object.getOwnPropertyDescriptor(window.Node.prototype,"childNodes")||{get:function(){return this.childNodes}},s=Element.prototype.querySelectorAll,f=Document.prototype.querySelectorAll,h=DocumentFragment.prototype.querySelectorAll,y=function(){if(!t){var e=document.createElement("template"),n=document.createElement("template");n.content.appendChild(document.createElement("div")),e.content.appendChild(n);var r=e.cloneNode(!0);return 0===r.content.childNodes.length||0===r.content.firstChild.content.childNodes.length||o}}(),N=function(){};if(t){var g=document.implementation.createHTMLDocument("template"),v=!0,D=document.createElement("style");D.textContent="template{display:none;}";var E=document.head;E.insertBefore(D,E.firstElementChild),N.prototype=Object.create(HTMLElement.prototype);var b=!document.createElement("div").hasOwnProperty("innerHTML");N.decorate=function(e){if(!e.content&&e.namespaceURI===document.documentElement.namespaceURI){e.content=g.createDocumentFragment();for(var t;t=e.firstChild;)i.call(e.content,t);if(b)e.__proto__=N.prototype;else if(e.cloneNode=function(e){return N._cloneNode(this,e)},v)try{C(e),_(e)}catch(o){v=!1}N.bootstrap(e.content)}};var T={option:["select"],thead:["table"],col:["colgroup","table"],tr:["tbody","table"],th:["tr","tbody","table"],td:["tr","tbody","table"]},M=function(e){return(/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(e)||["",""])[1].toLowerCase()},C=function k(e){Object.defineProperty(e,"innerHTML",{get:function(){return q(this)},set:function(e){var t=T[M(e)];if(t)for(var o=0;o<t.length;o++)e="<"+t[o]+">"+e+"</"+t[o]+">";for(g.body.innerHTML=e,N.bootstrap(g);this.content.firstChild;)l.call(this.content,this.content.firstChild);var n=g.body;if(t)for(var r=0;r<t.length;r++)n=n.lastChild;for(;n.firstChild;)i.call(this.content,n.firstChild)},configurable:!0})},_=function B(e){Object.defineProperty(e,"outerHTML",{get:function(){return"<template>"+this.innerHTML+"</template>"},set:function(e){if(!this.parentNode)throw new Error("Failed to set the 'outerHTML' property on 'Element': This element has no parent node.");g.body.innerHTML=e;for(var t=this.ownerDocument.createDocumentFragment();g.body.firstChild;)i.call(t,g.body.firstChild);p.call(this.parentNode,t,this)},configurable:!0})};C(N.prototype),_(N.prototype),N.bootstrap=function G(t){for(var o,n=e(t,"template"),r=0,c=n.length;r<c&&(o=n[r]);r++)N.decorate(o)},document.addEventListener("DOMContentLoaded",function(){N.bootstrap(document)}),Document.prototype.createElement=function z(){var e=c.apply(this,arguments);return"template"===e.localName&&N.decorate(e),e},DOMParser.prototype.parseFromString=function(){var e=u.apply(this,arguments);return N.bootstrap(e),e},Object.defineProperty(HTMLElement.prototype,"innerHTML",{get:function(){return q(this)},set:function(e){d.set.call(this,e),N.bootstrap(this)},configurable:!0,enumerable:!0});var F=/[&\u00A0"]/g,L=/[&\u00A0<>]/g,O=function(e){switch(e){case"&":return"&";case"<":return"<";case">":return">";
915case'"':return""";case" ":return" "}},w=function(e){return e.replace(F,O)},H=function(e){return e.replace(L,O)},A=function(e){for(var t={},o=0;o<e.length;o++)t[e[o]]=!0;return t},x=A(["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),S=A(["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"]),j=function(e,t,o){switch(e.nodeType){case Node.ELEMENT_NODE:for(var n,r=e.localName,c="<"+r,a=e.attributes,l=0;n=a[l];l++)c+=" "+n.name+'="'+w(n.value)+'"';return c+=">",x[r]?c:c+q(e,o)+"</"+r+">";case Node.TEXT_NODE:var i=e.data;return t&&S[t.localName]?i:H(i);case Node.COMMENT_NODE:return"\x3c!--"+e.data+"--\x3e";default:throw window.console.error(e),new Error("not implemented")}},q=function(e,t){"template"===e.localName&&(e=e.content);for(var o,n="",r=t?t(e):m.get.call(e),c=0,a=r.length;c<a&&(o=r[c]);c++)n+=j(o,e,t);return n}}if(t||y){N._cloneNode=function X(e,t){var o=r.call(e,!1);return this.decorate&&this.decorate(o),t&&(i.call(o.content,r.call(e.content,!0)),P(o.content,e.content)),o};var P=function J(t,o){if(o.querySelectorAll){var n=e(o,"template");if(0!==n.length)for(var r,c,a=e(t,"template"),l=0,i=a.length;l<i;l++)c=n[l],r=a[l],N&&N.decorate&&N.decorate(c),p.call(r.parentNode,R.call(c,!0),r)}},U=function K(t){for(var o,n,r=e(t,'script:not([type]),script[type="application/javascript"],script[type="text/javascript"]'),a=0;a<r.length;a++){n=r[a],o=c.call(document,"script"),o.textContent=n.textContent;for(var l,i=n.attributes,u=0;u<i.length;u++)l=i[u],o.setAttribute(l.name,l.value);p.call(n.parentNode,o,n)}},R=Node.prototype.cloneNode=function Q(e){var t;if(!n&&o&&this instanceof DocumentFragment){if(!e)return this.ownerDocument.createDocumentFragment();t=I.call(this.ownerDocument,this,!0)}else t=this.nodeType===Node.ELEMENT_NODE&&"template"===this.localName&&this.namespaceURI==document.documentElement.namespaceURI?N._cloneNode(this,e):r.call(this,e);return e&&P(t,this),t},I=Document.prototype.importNode=function V(e,t){if(t=t||!1,"template"===e.localName)return N._cloneNode(e,t);var o=a.call(this,e,t);return t&&(P(o,e),U(o)),o}}t&&(window.HTMLTemplateElement=N)}();})('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {}); 916 917 (function(scope) { 918 "use strict"; 919 if (!(window.performance && window.performance.now)) { 920 var start = Date.now(); 921 window.performance = { 922 now: function() { 923 return Date.now() - start; 924 } 925 }; 926 } 927 if (!window.requestAnimationFrame) { 928 window.requestAnimationFrame = function() { 929 var nativeRaf = window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame; 930 return nativeRaf ? function(callback) { 931 return nativeRaf(function() { 932 callback(performance.now()); 933 }); 934 } : function(callback) { 935 return window.setTimeout(callback, 1e3 / 60); 936 }; 937 }(); 938 } 939 if (!window.cancelAnimationFrame) { 940 window.cancelAnimationFrame = function() { 941 return window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || function(id) { 942 clearTimeout(id); 943 }; 944 }(); 945 } 946 var workingDefaultPrevented = function() { 947 var e = document.createEvent("Event"); 948 e.initEvent("foo", true, true); 949 e.preventDefault(); 950 return e.defaultPrevented; 951 }(); 952 if (!workingDefaultPrevented) { 953 var origPreventDefault = Event.prototype.preventDefault; 954 Event.prototype.preventDefault = function() { 955 if (!this.cancelable) { 956 return; 957 } 958 origPreventDefault.call(this); 959 Object.defineProperty(this, "defaultPrevented", { 960 get: function() { 961 return true; 962 }, 963 configurable: true 964 }); 965 }; 966 } 967 var isIE = /Trident/.test(navigator.userAgent); 968 if (!window.CustomEvent || isIE && typeof window.CustomEvent !== "function") { 969 window.CustomEvent = function(inType, params) { 970 params = params || {}; 971 var e = document.createEvent("CustomEvent"); 972 e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable), params.detail); 973 return e; 974 }; 975 window.CustomEvent.prototype = window.Event.prototype; 976 }
vendor: 39,614 bytes, lines 977-2334
977 if (!window.Event || isIE && typeof window.Event !== "function") { 978 var origEvent = window.Event; 979 window.Event = function(inType, params) { 980 params = params || {}; 981 var e = document.createEvent("Event"); 982 e.initEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable)); 983 return e; 984 }; 985 window.Event.prototype = origEvent.prototype; 986 } 987 })(window.WebComponents); 988 989 window.HTMLImports = window.HTMLImports || { 990 flags: {} 991 }; 992 993 (function(scope) { 994 var IMPORT_LINK_TYPE = "import"; 995 var useNative = Boolean(IMPORT_LINK_TYPE in document.createElement("link")); 996 var hasShadowDOMPolyfill = Boolean(window.ShadowDOMPolyfill); 997 var wrap = function(node) { 998 return hasShadowDOMPolyfill ? window.ShadowDOMPolyfill.wrapIfNeeded(node) : node; 999 }; 1000 var rootDocument = wrap(document); 1001 var currentScriptDescriptor = { 1002 get: function() { 1003 var script = window.HTMLImports.currentScript || document.currentScript || (document.readyState !== "complete" ? document.scripts[document.scripts.length - 1] : null); 1004 return wrap(script); 1005 }, 1006 configurable: true 1007 }; 1008 Object.defineProperty(document, "_currentScript", currentScriptDescriptor); 1009 Object.defineProperty(rootDocument, "_currentScript", currentScriptDescriptor); 1010 var isIE = /Trident/.test(navigator.userAgent); 1011 function whenReady(callback, doc) { 1012 doc = doc || rootDocument; 1013 whenDocumentReady(function() { 1014 watchImportsLoad(callback, doc); 1015 }, doc); 1016 } 1017 var requiredReadyState = isIE ? "complete" : "interactive"; 1018 var READY_EVENT = "readystatechange"; 1019 function isDocumentReady(doc) { 1020 return doc.readyState === "complete" || doc.readyState === requiredReadyState; 1021 } 1022 function whenDocumentReady(callback, doc) { 1023 if (!isDocumentReady(doc)) { 1024 var checkReady = function() { 1025 if (doc.readyState === "complete" || doc.readyState === requiredReadyState) { 1026 doc.removeEventListener(READY_EVENT, checkReady); 1027 whenDocumentReady(callback, doc); 1028 } 1029 }; 1030 doc.addEventListener(READY_EVENT, checkReady); 1031 } else if (callback) { 1032 callback(); 1033 } 1034 } 1035 function markTargetLoaded(event) { 1036 event.target.__loaded = true; 1037 } 1038 function watchImportsLoad(callback, doc) { 1039 var imports = doc.querySelectorAll("link[rel=import]"); 1040 var parsedCount = 0, importCount = imports.length, newImports = [], errorImports = []; 1041 function checkDone() { 1042 if (parsedCount == importCount && callback) { 1043 callback({ 1044 allImports: imports, 1045 loadedImports: newImports, 1046 errorImports: errorImports 1047 }); 1048 } 1049 } 1050 function loadedImport(e) { 1051 markTargetLoaded(e); 1052 newImports.push(this); 1053 parsedCount++; 1054 checkDone(); 1055 } 1056 function errorLoadingImport(e) { 1057 errorImports.push(this); 1058 parsedCount++; 1059 checkDone(); 1060 } 1061 if (importCount) { 1062 for (var i = 0, imp; i < importCount && (imp = imports[i]); i++) { 1063 if (isImportLoaded(imp)) { 1064 newImports.push(this); 1065 parsedCount++; 1066 checkDone(); 1067 } else { 1068 imp.addEventListener("load", loadedImport); 1069 imp.addEventListener("error", errorLoadingImport); 1070 } 1071 } 1072 } else { 1073 checkDone(); 1074 } 1075 } 1076 function isImportLoaded(link) { 1077 return useNative ? link.__loaded || link.import && link.import.readyState !== "loading" : link.__importParsed; 1078 } 1079 if (useNative) { 1080 new MutationObserver(function(mxns) { 1081 for (var i = 0, l = mxns.length, m; i < l && (m = mxns[i]); i++) { 1082 if (m.addedNodes) { 1083 handleImports(m.addedNodes); 1084 } 1085 } 1086 }).observe(document.head, { 1087 childList: true 1088 }); 1089 function handleImports(nodes) { 1090 for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) { 1091 if (isImport(n)) { 1092 handleImport(n); 1093 } 1094 } 1095 } 1096 function isImport(element) { 1097 return element.localName === "link" && element.rel === "import"; 1098 } 1099 function handleImport(element) { 1100 var loaded = element.import; 1101 if (loaded) { 1102 markTargetLoaded({ 1103 target: element 1104 }); 1105 } else { 1106 element.addEventListener("load", markTargetLoaded); 1107 element.addEventListener("error", markTargetLoaded); 1108 } 1109 } 1110 (function() { 1111 if (document.readyState === "loading") { 1112 var imports = document.querySelectorAll("link[rel=import]"); 1113 for (var i = 0, l = imports.length, imp; i < l && (imp = imports[i]); i++) { 1114 handleImport(imp); 1115 } 1116 } 1117 })(); 1118 } 1119 whenReady(function(detail) { 1120 window.HTMLImports.ready = true; 1121 window.HTMLImports.readyTime = new Date().getTime(); 1122 var evt = rootDocument.createEvent("CustomEvent"); 1123 evt.initCustomEvent("HTMLImportsLoaded", true, true, detail); 1124 rootDocument.dispatchEvent(evt); 1125 }); 1126 scope.IMPORT_LINK_TYPE = IMPORT_LINK_TYPE; 1127 scope.useNative = useNative; 1128 scope.rootDocument = rootDocument; 1129 scope.whenReady = whenReady; 1130 scope.isIE = isIE; 1131 })(window.HTMLImports); 1132 1133 (function(scope) { 1134 var modules = []; 1135 var addModule = function(module) { 1136 modules.push(module); 1137 }; 1138 var initializeModules = function() { 1139 modules.forEach(function(module) { 1140 module(scope); 1141 }); 1142 }; 1143 scope.addModule = addModule; 1144 scope.initializeModules = initializeModules; 1145 })(window.HTMLImports); 1146 1147 window.HTMLImports.addModule(function(scope) { 1148 var CSS_URL_REGEXP = /(url\()([^)]*)(\))/g; 1149 var CSS_IMPORT_REGEXP = /(@import[\s]+(?!url\())([^;]*)(;)/g; 1150 var path = { 1151 resolveUrlsInStyle: function(style, linkUrl) { 1152 var doc = style.ownerDocument; 1153 var resolver = doc.createElement("a"); 1154 style.textContent = this.resolveUrlsInCssText(style.textContent, linkUrl, resolver); 1155 return style; 1156 }, 1157 resolveUrlsInCssText: function(cssText, linkUrl, urlObj) { 1158 var r = this.replaceUrls(cssText, urlObj, linkUrl, CSS_URL_REGEXP); 1159 r = this.replaceUrls(r, urlObj, linkUrl, CSS_IMPORT_REGEXP); 1160 return r; 1161 }, 1162 replaceUrls: function(text, urlObj, linkUrl, regexp) { 1163 return text.replace(regexp, function(m, pre, url, post) { 1164 var urlPath = url.replace(/["']/g, ""); 1165 if (linkUrl) { 1166 urlPath = new URL(urlPath, linkUrl).href; 1167 } 1168 urlObj.href = urlPath; 1169 urlPath = urlObj.href; 1170 return pre + "'" + urlPath + "'" + post; 1171 }); 1172 } 1173 }; 1174 scope.path = path; 1175 }); 1176 1177 window.HTMLImports.addModule(function(scope) { 1178 var xhr = { 1179 async: true, 1180 ok: function(request) { 1181 return request.status >= 200 && request.status < 300 || request.status === 304 || request.status === 0; 1182 }, 1183 load: function(url, next, nextContext) { 1184 var request = new XMLHttpRequest(); 1185 if (scope.flags.debug || scope.flags.bust) { 1186 url += "?" + Math.random(); 1187 } 1188 request.open("GET", url, xhr.async); 1189 request.addEventListener("readystatechange", function(e) { 1190 if (request.readyState === 4) { 1191 var redirectedUrl = null; 1192 try { 1193 var locationHeader = request.getResponseHeader("Location"); 1194 if (locationHeader) { 1195 redirectedUrl = locationHeader.substr(0, 1) === "/" ? location.origin + locationHeader : locationHeader; 1196 } 1197 } catch (e) { 1198 console.error(e.message); 1199 } 1200 next.call(nextContext, !xhr.ok(request) && request, request.response || request.responseText, redirectedUrl); 1201 } 1202 }); 1203 request.send(); 1204 return request; 1205 }, 1206 loadDocument: function(url, next, nextContext) { 1207 this.load(url, next, nextContext).responseType = "document"; 1208 } 1209 }; 1210 scope.xhr = xhr; 1211 }); 1212 1213 window.HTMLImports.addModule(function(scope) { 1214 var xhr = scope.xhr; 1215 var flags = scope.flags; 1216 var Loader = function(onLoad, onComplete) { 1217 this.cache = {}; 1218 this.onload = onLoad; 1219 this.oncomplete = onComplete; 1220 this.inflight = 0; 1221 this.pending = {}; 1222 }; 1223 Loader.prototype = { 1224 addNodes: function(nodes) { 1225 this.inflight += nodes.length; 1226 for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) { 1227 this.require(n); 1228 } 1229 this.checkDone(); 1230 }, 1231 addNode: function(node) { 1232 this.inflight++; 1233 this.require(node); 1234 this.checkDone(); 1235 }, 1236 require: function(elt) { 1237 var url = elt.src || elt.href; 1238 elt.__nodeUrl = url; 1239 if (!this.dedupe(url, elt)) { 1240 this.fetch(url, elt); 1241 } 1242 }, 1243 dedupe: function(url, elt) { 1244 if (this.pending[url]) { 1245 this.pending[url].push(elt); 1246 return true; 1247 } 1248 var resource; 1249 if (this.cache[url]) { 1250 this.onload(url, elt, this.cache[url]); 1251 this.tail(); 1252 return true; 1253 } 1254 this.pending[url] = [ elt ]; 1255 return false; 1256 }, 1257 fetch: function(url, elt) { 1258 flags.load && console.log("fetch", url, elt); 1259 if (!url) { 1260 setTimeout(function() { 1261 this.receive(url, elt, { 1262 error: "href must be specified" 1263 }, null); 1264 }.bind(this), 0); 1265 } else if (url.match(/^data:/)) { 1266 var pieces = url.split(","); 1267 var header = pieces[0]; 1268 var body = pieces[1]; 1269 if (header.indexOf(";base64") > -1) { 1270 body = atob(body); 1271 } else { 1272 body = decodeURIComponent(body); 1273 } 1274 setTimeout(function() { 1275 this.receive(url, elt, null, body); 1276 }.bind(this), 0); 1277 } else { 1278 var receiveXhr = function(err, resource, redirectedUrl) { 1279 this.receive(url, elt, err, resource, redirectedUrl); 1280 }.bind(this); 1281 xhr.load(url, receiveXhr); 1282 } 1283 }, 1284 receive: function(url, elt, err, resource, redirectedUrl) { 1285 this.cache[url] = resource; 1286 var $p = this.pending[url]; 1287 for (var i = 0, l = $p.length, p; i < l && (p = $p[i]); i++) { 1288 this.onload(url, p, resource, err, redirectedUrl); 1289 this.tail(); 1290 } 1291 this.pending[url] = null; 1292 }, 1293 tail: function() { 1294 --this.inflight; 1295 this.checkDone(); 1296 }, 1297 checkDone: function() { 1298 if (!this.inflight) { 1299 this.oncomplete(); 1300 } 1301 } 1302 }; 1303 scope.Loader = Loader; 1304 }); 1305 1306 window.HTMLImports.addModule(function(scope) { 1307 var Observer = function(addCallback) { 1308 this.addCallback = addCallback; 1309 this.mo = new MutationObserver(this.handler.bind(this)); 1310 }; 1311 Observer.prototype = { 1312 handler: function(mutations) { 1313 for (var i = 0, l = mutations.length, m; i < l && (m = mutations[i]); i++) { 1314 if (m.type === "childList" && m.addedNodes.length) { 1315 this.addedNodes(m.addedNodes); 1316 } 1317 } 1318 }, 1319 addedNodes: function(nodes) { 1320 if (this.addCallback) { 1321 this.addCallback(nodes); 1322 } 1323 for (var i = 0, l = nodes.length, n, loading; i < l && (n = nodes[i]); i++) { 1324 if (n.children && n.children.length) { 1325 this.addedNodes(n.children); 1326 } 1327 } 1328 }, 1329 observe: function(root) { 1330 this.mo.observe(root, { 1331 childList: true, 1332 subtree: true 1333 }); 1334 } 1335 }; 1336 scope.Observer = Observer; 1337 }); 1338 1339 window.HTMLImports.addModule(function(scope) { 1340 var path = scope.path; 1341 var rootDocument = scope.rootDocument; 1342 var flags = scope.flags; 1343 var isIE = scope.isIE; 1344 var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE; 1345 var IMPORT_SELECTOR = "link[rel=" + IMPORT_LINK_TYPE + "]"; 1346 var importParser = { 1347 documentSelectors: IMPORT_SELECTOR, 1348 importsSelectors: [ IMPORT_SELECTOR, "link[rel=stylesheet]:not([type])", "style:not([type])", "script:not([type])", 'script[type="application/javascript"]', 'script[type="text/javascript"]' ].join(","), 1349 map: { 1350 link: "parseLink", 1351 script: "parseScript", 1352 style: "parseStyle" 1353 }, 1354 dynamicElements: [], 1355 parseNext: function() { 1356 var next = this.nextToParse(); 1357 if (next) { 1358 this.parse(next); 1359 } 1360 }, 1361 parse: function(elt) { 1362 if (this.isParsed(elt)) { 1363 flags.parse && console.log("[%s] is already parsed", elt.localName); 1364 return; 1365 } 1366 var fn = this[this.map[elt.localName]]; 1367 if (fn) { 1368 this.markParsing(elt); 1369 fn.call(this, elt); 1370 } 1371 }, 1372 parseDynamic: function(elt, quiet) { 1373 this.dynamicElements.push(elt); 1374 if (!quiet) { 1375 this.parseNext(); 1376 } 1377 }, 1378 markParsing: function(elt) { 1379 flags.parse && console.log("parsing", elt); 1380 this.parsingElement = elt; 1381 }, 1382 markParsingComplete: function(elt) { 1383 elt.__importParsed = true; 1384 this.markDynamicParsingComplete(elt); 1385 if (elt.__importElement) { 1386 elt.__importElement.__importParsed = true; 1387 this.markDynamicParsingComplete(elt.__importElement); 1388 } 1389 this.parsingElement = null; 1390 flags.parse && console.log("completed", elt); 1391 }, 1392 markDynamicParsingComplete: function(elt) { 1393 var i = this.dynamicElements.indexOf(elt); 1394 if (i >= 0) { 1395 this.dynamicElements.splice(i, 1); 1396 } 1397 }, 1398 parseImport: function(elt) { 1399 elt.import = elt.__doc; 1400 if (window.HTMLImports.__importsParsingHook) { 1401 window.HTMLImports.__importsParsingHook(elt); 1402 } 1403 if (elt.import) { 1404 elt.import.__importParsed = true; 1405 } 1406 this.markParsingComplete(elt); 1407 if (elt.__resource && !elt.__error) { 1408 elt.dispatchEvent(new CustomEvent("load", { 1409 bubbles: false 1410 })); 1411 } else { 1412 elt.dispatchEvent(new CustomEvent("error", { 1413 bubbles: false 1414 })); 1415 } 1416 if (elt.__pending) { 1417 var fn; 1418 while (elt.__pending.length) { 1419 fn = elt.__pending.shift(); 1420 if (fn) { 1421 fn({ 1422 target: elt 1423 }); 1424 } 1425 } 1426 } 1427 this.parseNext(); 1428 }, 1429 parseLink: function(linkElt) { 1430 if (nodeIsImport(linkElt)) { 1431 this.parseImport(linkElt); 1432 } else { 1433 linkElt.href = linkElt.href; 1434 this.parseGeneric(linkElt); 1435 } 1436 }, 1437 parseStyle: function(elt) { 1438 var src = elt; 1439 elt = cloneStyle(elt); 1440 src.__appliedElement = elt; 1441 elt.__importElement = src; 1442 this.parseGeneric(elt); 1443 }, 1444 parseGeneric: function(elt) { 1445 this.trackElement(elt); 1446 this.addElementToDocument(elt); 1447 }, 1448 rootImportForElement: function(elt) { 1449 var n = elt; 1450 while (n.ownerDocument.__importLink) { 1451 n = n.ownerDocument.__importLink; 1452 } 1453 return n; 1454 }, 1455 addElementToDocument: function(elt) { 1456 var port = this.rootImportForElement(elt.__importElement || elt); 1457 port.parentNode.insertBefore(elt, port); 1458 }, 1459 trackElement: function(elt, callback) { 1460 var self = this; 1461 var done = function(e) { 1462 elt.removeEventListener("load", done); 1463 elt.removeEventListener("error", done); 1464 if (callback) { 1465 callback(e); 1466 } 1467 self.markParsingComplete(elt); 1468 self.parseNext(); 1469 }; 1470 elt.addEventListener("load", done); 1471 elt.addEventListener("error", done); 1472 if (isIE && elt.localName === "style") { 1473 var fakeLoad = false; 1474 if (elt.textContent.indexOf("@import") == -1) { 1475 fakeLoad = true; 1476 } else if (elt.sheet) { 1477 fakeLoad = true; 1478 var csr = elt.sheet.cssRules; 1479 var len = csr ? csr.length : 0; 1480 for (var i = 0, r; i < len && (r = csr[i]); i++) { 1481 if (r.type === CSSRule.IMPORT_RULE) { 1482 fakeLoad = fakeLoad && Boolean(r.styleSheet); 1483 } 1484 } 1485 } 1486 if (fakeLoad) { 1487 setTimeout(function() { 1488 elt.dispatchEvent(new CustomEvent("load", { 1489 bubbles: false 1490 })); 1491 }); 1492 } 1493 } 1494 }, 1495 parseScript: function(scriptElt) { 1496 var script = document.createElement("script"); 1497 script.__importElement = scriptElt; 1498 script.src = scriptElt.src ? scriptElt.src : generateScriptDataUrl(scriptElt); 1499 scope.currentScript = scriptElt; 1500 this.trackElement(script, function(e) { 1501 if (script.parentNode) { 1502 script.parentNode.removeChild(script); 1503 } 1504 scope.currentScript = null; 1505 }); 1506 this.addElementToDocument(script); 1507 }, 1508 nextToParse: function() { 1509 this._mayParse = []; 1510 return !this.parsingElement && (this.nextToParseInDoc(rootDocument) || this.nextToParseDynamic()); 1511 }, 1512 nextToParseInDoc: function(doc, link) { 1513 if (doc && this._mayParse.indexOf(doc) < 0) { 1514 this._mayParse.push(doc); 1515 var nodes = doc.querySelectorAll(this.parseSelectorsForNode(doc)); 1516 for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) { 1517 if (!this.isParsed(n)) { 1518 if (this.hasResource(n)) { 1519 return nodeIsImport(n) ? this.nextToParseInDoc(n.__doc, n) : n; 1520 } else { 1521 return; 1522 } 1523 } 1524 } 1525 } 1526 return link; 1527 }, 1528 nextToParseDynamic: function() { 1529 return this.dynamicElements[0]; 1530 }, 1531 parseSelectorsForNode: function(node) { 1532 var doc = node.ownerDocument || node; 1533 return doc === rootDocument ? this.documentSelectors : this.importsSelectors; 1534 }, 1535 isParsed: function(node) { 1536 return node.__importParsed; 1537 }, 1538 needsDynamicParsing: function(elt) { 1539 return this.dynamicElements.indexOf(elt) >= 0; 1540 }, 1541 hasResource: function(node) { 1542 if (nodeIsImport(node) && node.__doc === undefined) { 1543 return false; 1544 } 1545 return true; 1546 } 1547 }; 1548 function nodeIsImport(elt) { 1549 return elt.localName === "link" && elt.rel === IMPORT_LINK_TYPE; 1550 } 1551 function generateScriptDataUrl(script) { 1552 var scriptContent = generateScriptContent(script); 1553 return "data:text/javascript;charset=utf-8," + encodeURIComponent(scriptContent); 1554 } 1555 function generateScriptContent(script) { 1556 return script.textContent + generateSourceMapHint(script); 1557 } 1558 function generateSourceMapHint(script) { 1559 var owner = script.ownerDocument; 1560 owner.__importedScripts = owner.__importedScripts || 0; 1561 var moniker = script.ownerDocument.baseURI; 1562 var num = owner.__importedScripts ? "-" + owner.__importedScripts : ""; 1563 owner.__importedScripts++; 1564 return "\n//# sourceURL=" + moniker + num + ".js\n"; 1565 } 1566 function cloneStyle(style) { 1567 var clone = style.ownerDocument.createElement("style"); 1568 clone.textContent = style.textContent; 1569 path.resolveUrlsInStyle(clone); 1570 return clone; 1571 } 1572 scope.parser = importParser; 1573 scope.IMPORT_SELECTOR = IMPORT_SELECTOR; 1574 }); 1575 1576 window.HTMLImports.addModule(function(scope) { 1577 var flags = scope.flags; 1578 var IMPORT_LINK_TYPE = scope.IMPORT_LINK_TYPE; 1579 var IMPORT_SELECTOR = scope.IMPORT_SELECTOR; 1580 var rootDocument = scope.rootDocument; 1581 var Loader = scope.Loader; 1582 var Observer = scope.Observer; 1583 var parser = scope.parser; 1584 var importer = { 1585 documents: {}, 1586 documentPreloadSelectors: IMPORT_SELECTOR, 1587 importsPreloadSelectors: [ IMPORT_SELECTOR ].join(","), 1588 loadNode: function(node) { 1589 importLoader.addNode(node); 1590 }, 1591 loadSubtree: function(parent) { 1592 var nodes = this.marshalNodes(parent); 1593 importLoader.addNodes(nodes); 1594 }, 1595 marshalNodes: function(parent) { 1596 return parent.querySelectorAll(this.loadSelectorsForNode(parent)); 1597 }, 1598 loadSelectorsForNode: function(node) { 1599 var doc = node.ownerDocument || node; 1600 return doc === rootDocument ? this.documentPreloadSelectors : this.importsPreloadSelectors; 1601 }, 1602 loaded: function(url, elt, resource, err, redirectedUrl) { 1603 flags.load && console.log("loaded", url, elt); 1604 elt.__resource = resource; 1605 elt.__error = err; 1606 if (isImportLink(elt)) { 1607 var doc = this.documents[url]; 1608 if (doc === undefined) { 1609 doc = err ? null : makeDocument(resource, redirectedUrl || url); 1610 if (doc) { 1611 doc.__importLink = elt; 1612 this.bootDocument(doc); 1613 } 1614 this.documents[url] = doc; 1615 } 1616 elt.__doc = doc; 1617 } 1618 parser.parseNext(); 1619 }, 1620 bootDocument: function(doc) { 1621 this.loadSubtree(doc); 1622 this.observer.observe(doc); 1623 parser.parseNext(); 1624 }, 1625 loadedAll: function() { 1626 parser.parseNext(); 1627 } 1628 }; 1629 var importLoader = new Loader(importer.loaded.bind(importer), importer.loadedAll.bind(importer)); 1630 importer.observer = new Observer(); 1631 function isImportLink(elt) { 1632 return isLinkRel(elt, IMPORT_LINK_TYPE); 1633 } 1634 function isLinkRel(elt, rel) { 1635 return elt.localName === "link" && elt.getAttribute("rel") === rel; 1636 } 1637 function hasBaseURIAccessor(doc) { 1638 return !!Object.getOwnPropertyDescriptor(doc, "baseURI"); 1639 } 1640 function makeDocument(resource, url) { 1641 var doc = document.implementation.createHTMLDocument(IMPORT_LINK_TYPE); 1642 doc._URL = url; 1643 var base = doc.createElement("base"); 1644 base.setAttribute("href", url); 1645 if (!doc.baseURI && !hasBaseURIAccessor(doc)) { 1646 Object.defineProperty(doc, "baseURI", { 1647 value: url 1648 }); 1649 } 1650 var meta = doc.createElement("meta"); 1651 meta.setAttribute("charset", "utf-8"); 1652 doc.head.appendChild(meta); 1653 doc.head.appendChild(base); 1654 doc.body.innerHTML = resource; 1655 return doc; 1656 } 1657 if (!document.baseURI) { 1658 var baseURIDescriptor = { 1659 get: function() { 1660 var base = document.querySelector("base"); 1661 return base ? base.href : window.location.href; 1662 }, 1663 configurable: true 1664 }; 1665 Object.defineProperty(document, "baseURI", baseURIDescriptor); 1666 Object.defineProperty(rootDocument, "baseURI", baseURIDescriptor); 1667 } 1668 scope.importer = importer; 1669 scope.importLoader = importLoader; 1670 }); 1671 1672 window.HTMLImports.addModule(function(scope) { 1673 var parser = scope.parser; 1674 var importer = scope.importer; 1675 var dynamic = { 1676 added: function(nodes) { 1677 var owner, parsed, loading; 1678 for (var i = 0, l = nodes.length, n; i < l && (n = nodes[i]); i++) { 1679 if (!owner) { 1680 owner = n.ownerDocument; 1681 parsed = parser.isParsed(owner); 1682 } 1683 loading = this.shouldLoadNode(n); 1684 if (loading) { 1685 importer.loadNode(n); 1686 } 1687 if (this.shouldParseNode(n) && parsed) { 1688 parser.parseDynamic(n, loading); 1689 } 1690 } 1691 }, 1692 shouldLoadNode: function(node) { 1693 return node.nodeType === 1 && matches.call(node, importer.loadSelectorsForNode(node)); 1694 }, 1695 shouldParseNode: function(node) { 1696 return node.nodeType === 1 && matches.call(node, parser.parseSelectorsForNode(node)); 1697 } 1698 }; 1699 importer.observer.addCallback = dynamic.added.bind(dynamic); 1700 var matches = HTMLElement.prototype.matches || HTMLElement.prototype.matchesSelector || HTMLElement.prototype.webkitMatchesSelector || HTMLElement.prototype.mozMatchesSelector || HTMLElement.prototype.msMatchesSelector; 1701 }); 1702 1703 (function(scope) { 1704 var initializeModules = scope.initializeModules; 1705 var isIE = scope.isIE; 1706 if (scope.useNative) { 1707 return; 1708 } 1709 initializeModules(); 1710 var rootDocument = scope.rootDocument; 1711 function bootstrap() { 1712 window.HTMLImports.importer.bootDocument(rootDocument); 1713 } 1714 if (document.readyState === "complete" || document.readyState === "interactive" && !window.attachEvent) { 1715 bootstrap(); 1716 } else { 1717 document.addEventListener("DOMContentLoaded", bootstrap); 1718 } 1719 })(window.HTMLImports); 1720 1721 window.CustomElements = window.CustomElements || { 1722 flags: {} 1723 }; 1724 1725 (function(scope) { 1726 var flags = scope.flags; 1727 var modules = []; 1728 var addModule = function(module) { 1729 modules.push(module); 1730 }; 1731 var initializeModules = function() { 1732 modules.forEach(function(module) { 1733 module(scope); 1734 }); 1735 }; 1736 scope.addModule = addModule; 1737 scope.initializeModules = initializeModules; 1738 scope.hasNative = Boolean(document.registerElement); 1739 scope.isIE = /Trident/.test(navigator.userAgent); 1740 scope.useNative = !flags.register && scope.hasNative && !window.ShadowDOMPolyfill && (!window.HTMLImports || window.HTMLImports.useNative); 1741 })(window.CustomElements); 1742 1743 window.CustomElements.addModule(function(scope) { 1744 var IMPORT_LINK_TYPE = window.HTMLImports ? window.HTMLImports.IMPORT_LINK_TYPE : "none"; 1745 function forSubtree(node, cb) { 1746 findAllElements(node, function(e) { 1747 if (cb(e)) { 1748 return true; 1749 } 1750 forRoots(e, cb); 1751 }); 1752 forRoots(node, cb); 1753 } 1754 function findAllElements(node, find, data) { 1755 var e = node.firstElementChild; 1756 if (!e) { 1757 e = node.firstChild; 1758 while (e && e.nodeType !== Node.ELEMENT_NODE) { 1759 e = e.nextSibling; 1760 } 1761 } 1762 while (e) { 1763 if (find(e, data) !== true) { 1764 findAllElements(e, find, data); 1765 } 1766 e = e.nextElementSibling; 1767 } 1768 return null; 1769 } 1770 function forRoots(node, cb) { 1771 var root = node.shadowRoot; 1772 while (root) { 1773 forSubtree(root, cb); 1774 root = root.olderShadowRoot; 1775 } 1776 } 1777 function forDocumentTree(doc, cb) { 1778 _forDocumentTree(doc, cb, []); 1779 } 1780 function _forDocumentTree(doc, cb, processingDocuments) { 1781 doc = window.wrap(doc); 1782 if (processingDocuments.indexOf(doc) >= 0) { 1783 return; 1784 } 1785 processingDocuments.push(doc); 1786 var imports = doc.querySelectorAll("link[rel=" + IMPORT_LINK_TYPE + "]"); 1787 for (var i = 0, l = imports.length, n; i < l && (n = imports[i]); i++) { 1788 if (n.import) { 1789 _forDocumentTree(n.import, cb, processingDocuments); 1790 } 1791 } 1792 cb(doc); 1793 } 1794 scope.forDocumentTree = forDocumentTree; 1795 scope.forSubtree = forSubtree; 1796 }); 1797 1798 window.CustomElements.addModule(function(scope) { 1799 var flags = scope.flags; 1800 var forSubtree = scope.forSubtree; 1801 var forDocumentTree = scope.forDocumentTree; 1802 function addedNode(node, isAttached) { 1803 return added(node, isAttached) || addedSubtree(node, isAttached); 1804 } 1805 function added(node, isAttached) { 1806 if (scope.upgrade(node, isAttached)) { 1807 return true; 1808 } 1809 if (isAttached) { 1810 attached(node); 1811 } 1812 } 1813 function addedSubtree(node, isAttached) { 1814 forSubtree(node, function(e) { 1815 if (added(e, isAttached)) { 1816 return true; 1817 } 1818 }); 1819 } 1820 var hasThrottledAttached = window.MutationObserver._isPolyfilled && flags["throttle-attached"]; 1821 scope.hasPolyfillMutations = hasThrottledAttached; 1822 scope.hasThrottledAttached = hasThrottledAttached; 1823 var isPendingMutations = false; 1824 var pendingMutations = []; 1825 function deferMutation(fn) { 1826 pendingMutations.push(fn); 1827 if (!isPendingMutations) { 1828 isPendingMutations = true; 1829 setTimeout(takeMutations); 1830 } 1831 } 1832 function takeMutations() { 1833 isPendingMutations = false; 1834 var $p = pendingMutations; 1835 for (var i = 0, l = $p.length, p; i < l && (p = $p[i]); i++) { 1836 p(); 1837 } 1838 pendingMutations = []; 1839 } 1840 function attached(element) { 1841 if (hasThrottledAttached) { 1842 deferMutation(function() { 1843 _attached(element); 1844 }); 1845 } else { 1846 _attached(element); 1847 } 1848 } 1849 function _attached(element) { 1850 if (element.__upgraded__ && !element.__attached) { 1851 element.__attached = true; 1852 if (element.attachedCallback) { 1853 element.attachedCallback(); 1854 } 1855 } 1856 } 1857 function detachedNode(node) { 1858 detached(node); 1859 forSubtree(node, function(e) { 1860 detached(e); 1861 }); 1862 } 1863 function detached(element) { 1864 if (hasThrottledAttached) { 1865 deferMutation(function() { 1866 _detached(element); 1867 }); 1868 } else { 1869 _detached(element); 1870 } 1871 } 1872 function _detached(element) { 1873 if (element.__upgraded__ && element.__attached) { 1874 element.__attached = false; 1875 if (element.detachedCallback) { 1876 element.detachedCallback(); 1877 } 1878 } 1879 } 1880 function inDocument(element) { 1881 var p = element; 1882 var doc = window.wrap(document); 1883 while (p) { 1884 if (p == doc) { 1885 return true; 1886 } 1887 p = p.parentNode || p.nodeType === Node.DOCUMENT_FRAGMENT_NODE && p.host; 1888 } 1889 } 1890 function watchShadow(node) { 1891 if (node.shadowRoot && !node.shadowRoot.__watched) { 1892 flags.dom && console.log("watching shadow-root for: ", node.localName); 1893 var root = node.shadowRoot; 1894 while (root) { 1895 observe(root); 1896 root = root.olderShadowRoot; 1897 } 1898 } 1899 } 1900 function handler(root, mutations) { 1901 if (flags.dom) { 1902 var mx = mutations[0]; 1903 if (mx && mx.type === "childList" && mx.addedNodes) { 1904 if (mx.addedNodes) { 1905 var d = mx.addedNodes[0]; 1906 while (d && d !== document && !d.host) { 1907 d = d.parentNode; 1908 } 1909 var u = d && (d.URL || d._URL || d.host && d.host.localName) || ""; 1910 u = u.split("/?").shift().split("/").pop(); 1911 } 1912 } 1913 console.group("mutations (%d) [%s]", mutations.length, u || ""); 1914 } 1915 var isAttached = inDocument(root); 1916 mutations.forEach(function(mx) { 1917 if (mx.type === "childList") { 1918 forEach(mx.addedNodes, function(n) { 1919 if (!n.localName) { 1920 return; 1921 } 1922 addedNode(n, isAttached); 1923 }); 1924 forEach(mx.removedNodes, function(n) { 1925 if (!n.localName) { 1926 return; 1927 } 1928 detachedNode(n); 1929 }); 1930 } 1931 }); 1932 flags.dom && console.groupEnd(); 1933 } 1934 function takeRecords(node) { 1935 node = window.wrap(node); 1936 if (!node) { 1937 node = window.wrap(document); 1938 } 1939 while (node.parentNode) { 1940 node = node.parentNode; 1941 } 1942 var observer = node.__observer; 1943 if (observer) { 1944 handler(node, observer.takeRecords()); 1945 takeMutations(); 1946 } 1947 } 1948 var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach); 1949 function observe(inRoot) { 1950 if (inRoot.__observer) { 1951 return; 1952 } 1953 var observer = new MutationObserver(handler.bind(this, inRoot)); 1954 observer.observe(inRoot, { 1955 childList: true, 1956 subtree: true 1957 }); 1958 inRoot.__observer = observer; 1959 } 1960 function upgradeDocument(doc) { 1961 doc = window.wrap(doc); 1962 flags.dom && console.group("upgradeDocument: ", doc.baseURI.split("/").pop()); 1963 var isMainDocument = doc === window.wrap(document); 1964 addedNode(doc, isMainDocument); 1965 observe(doc); 1966 flags.dom && console.groupEnd(); 1967 } 1968 function upgradeDocumentTree(doc) { 1969 forDocumentTree(doc, upgradeDocument); 1970 } 1971 var originalCreateShadowRoot = Element.prototype.createShadowRoot; 1972 if (originalCreateShadowRoot) { 1973 Element.prototype.createShadowRoot = function() { 1974 var root = originalCreateShadowRoot.call(this); 1975 window.CustomElements.watchShadow(this); 1976 return root; 1977 }; 1978 } 1979 scope.watchShadow = watchShadow; 1980 scope.upgradeDocumentTree = upgradeDocumentTree; 1981 scope.upgradeDocument = upgradeDocument; 1982 scope.upgradeSubtree = addedSubtree; 1983 scope.upgradeAll = addedNode; 1984 scope.attached = attached; 1985 scope.takeRecords = takeRecords; 1986 }); 1987 1988 window.CustomElements.addModule(function(scope) { 1989 var flags = scope.flags; 1990 function upgrade(node, isAttached) { 1991 if (node.localName === "template") { 1992 if (window.HTMLTemplateElement && HTMLTemplateElement.decorate) { 1993 HTMLTemplateElement.decorate(node); 1994 } 1995 } 1996 if (!node.__upgraded__ && node.nodeType === Node.ELEMENT_NODE) { 1997 var is = node.getAttribute("is"); 1998 var definition = scope.getRegisteredDefinition(node.localName) || scope.getRegisteredDefinition(is); 1999 if (definition) { 2000 if (is && definition.tag == node.localName || !is && !definition.extends) { 2001 return upgradeWithDefinition(node, definition, isAttached); 2002 } 2003 } 2004 } 2005 } 2006 function upgradeWithDefinition(element, definition, isAttached) { 2007 flags.upgrade && console.group("upgrade:", element.localName); 2008 if (definition.is) { 2009 element.setAttribute("is", definition.is); 2010 } 2011 implementPrototype(element, definition); 2012 element.__upgraded__ = true; 2013 created(element); 2014 if (isAttached) { 2015 scope.attached(element); 2016 } 2017 scope.upgradeSubtree(element, isAttached); 2018 flags.upgrade && console.groupEnd(); 2019 return element; 2020 } 2021 function implementPrototype(element, definition) { 2022 if (Object.__proto__) { 2023 element.__proto__ = definition.prototype; 2024 } else { 2025 customMixin(element, definition.prototype, definition.native); 2026 element.__proto__ = definition.prototype; 2027 } 2028 } 2029 function customMixin(inTarget, inSrc, inNative) { 2030 var used = {}; 2031 var p = inSrc; 2032 while (p !== inNative && p !== HTMLElement.prototype) { 2033 var keys = Object.getOwnPropertyNames(p); 2034 for (var i = 0, k; k = keys[i]; i++) { 2035 if (!used[k]) { 2036 Object.defineProperty(inTarget, k, Object.getOwnPropertyDescriptor(p, k)); 2037 used[k] = 1; 2038 } 2039 } 2040 p = Object.getPrototypeOf(p); 2041 } 2042 } 2043 function created(element) { 2044 if (element.createdCallback) { 2045 element.createdCallback(); 2046 } 2047 } 2048 scope.upgrade = upgrade; 2049 scope.upgradeWithDefinition = upgradeWithDefinition; 2050 scope.implementPrototype = implementPrototype; 2051 }); 2052 2053 window.CustomElements.addModule(function(scope) { 2054 var isIE = scope.isIE; 2055 var upgradeDocumentTree = scope.upgradeDocumentTree; 2056 var upgradeAll = scope.upgradeAll; 2057 var upgradeWithDefinition = scope.upgradeWithDefinition; 2058 var implementPrototype = scope.implementPrototype; 2059 var useNative = scope.useNative; 2060 function register(name, options) { 2061 var definition = options || {}; 2062 if (!name) { 2063 throw new Error("document.registerElement: first argument `name` must not be empty"); 2064 } 2065 if (name.indexOf("-") < 0) { 2066 throw new Error("document.registerElement: first argument ('name') must contain a dash ('-'). Argument provided was '" + String(name) + "'."); 2067 } 2068 if (isReservedTag(name)) { 2069 throw new Error("Failed to execute 'registerElement' on 'Document': Registration failed for type '" + String(name) + "'. The type name is invalid."); 2070 } 2071 if (getRegisteredDefinition(name)) { 2072 throw new Error("DuplicateDefinitionError: a type with name '" + String(name) + "' is already registered"); 2073 } 2074 if (!definition.prototype) { 2075 definition.prototype = Object.create(HTMLElement.prototype); 2076 } 2077 definition.__name = name.toLowerCase(); 2078 if (definition.extends) { 2079 definition.extends = definition.extends.toLowerCase(); 2080 } 2081 definition.lifecycle = definition.lifecycle || {}; 2082 definition.ancestry = ancestry(definition.extends); 2083 resolveTagName(definition); 2084 resolvePrototypeChain(definition); 2085 overrideAttributeApi(definition.prototype); 2086 registerDefinition(definition.__name, definition); 2087 definition.ctor = generateConstructor(definition); 2088 definition.ctor.prototype = definition.prototype; 2089 definition.prototype.constructor = definition.ctor; 2090 if (scope.ready) { 2091 upgradeDocumentTree(document); 2092 } 2093 return definition.ctor; 2094 } 2095 function overrideAttributeApi(prototype) { 2096 if (prototype.setAttribute._polyfilled) { 2097 return; 2098 } 2099 var setAttribute = prototype.setAttribute; 2100 prototype.setAttribute = function(name, value) { 2101 changeAttribute.call(this, name, value, setAttribute); 2102 }; 2103 var removeAttribute = prototype.removeAttribute; 2104 prototype.removeAttribute = function(name) { 2105 changeAttribute.call(this, name, null, removeAttribute); 2106 }; 2107 prototype.setAttribute._polyfilled = true; 2108 } 2109 function changeAttribute(name, value, operation) { 2110 name = name.toLowerCase(); 2111 var oldValue = this.getAttribute(name); 2112 operation.apply(this, arguments); 2113 var newValue = this.getAttribute(name); 2114 if (this.attributeChangedCallback && newValue !== oldValue) { 2115 this.attributeChangedCallback(name, oldValue, newValue); 2116 } 2117 } 2118 function isReservedTag(name) { 2119 for (var i = 0; i < reservedTagList.length; i++) { 2120 if (name === reservedTagList[i]) { 2121 return true; 2122 } 2123 } 2124 } 2125 var reservedTagList = [ "annotation-xml", "color-profile", "font-face", "font-face-src", "font-face-uri", "font-face-format", "font-face-name", "missing-glyph" ]; 2126 function ancestry(extnds) { 2127 var extendee = getRegisteredDefinition(extnds); 2128 if (extendee) { 2129 return ancestry(extendee.extends).concat([ extendee ]); 2130 } 2131 return []; 2132 } 2133 function resolveTagName(definition) { 2134 var baseTag = definition.extends; 2135 for (var i = 0, a; a = definition.ancestry[i]; i++) { 2136 baseTag = a.is && a.tag; 2137 } 2138 definition.tag = baseTag || definition.__name; 2139 if (baseTag) { 2140 definition.is = definition.__name; 2141 } 2142 } 2143 function resolvePrototypeChain(definition) { 2144 if (!Object.__proto__) { 2145 var nativePrototype = HTMLElement.prototype; 2146 if (definition.is) { 2147 var inst = document.createElement(definition.tag); 2148 nativePrototype = Object.getPrototypeOf(inst); 2149 } 2150 var proto = definition.prototype, ancestor; 2151 var foundPrototype = false; 2152 while (proto) { 2153 if (proto == nativePrototype) { 2154 foundPrototype = true; 2155 } 2156 ancestor = Object.getPrototypeOf(proto); 2157 if (ancestor) { 2158 proto.__proto__ = ancestor; 2159 } 2160 proto = ancestor; 2161 } 2162 if (!foundPrototype) { 2163 console.warn(definition.tag + " prototype not found in prototype chain for " + definition.is); 2164 } 2165 definition.native = nativePrototype; 2166 } 2167 } 2168 function instantiate(definition) { 2169 return upgradeWithDefinition(domCreateElement(definition.tag), definition); 2170 } 2171 var registry = {}; 2172 function getRegisteredDefinition(name) { 2173 if (name) { 2174 return registry[name.toLowerCase()]; 2175 } 2176 } 2177 function registerDefinition(name, definition) { 2178 registry[name] = definition; 2179 } 2180 function generateConstructor(definition) { 2181 return function() { 2182 return instantiate(definition); 2183 }; 2184 } 2185 var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml"; 2186 function createElementNS(namespace, tag, typeExtension) { 2187 if (namespace === HTML_NAMESPACE) { 2188 return createElement(tag, typeExtension); 2189 } else { 2190 return domCreateElementNS(namespace, tag); 2191 } 2192 } 2193 function createElement(tag, typeExtension) { 2194 if (tag) { 2195 tag = tag.toLowerCase(); 2196 } 2197 if (typeExtension) { 2198 typeExtension = typeExtension.toLowerCase(); 2199 } 2200 var definition = getRegisteredDefinition(typeExtension || tag); 2201 if (definition) { 2202 if (tag == definition.tag && typeExtension == definition.is) { 2203 return new definition.ctor(); 2204 } 2205 if (!typeExtension && !definition.is) { 2206 return new definition.ctor(); 2207 } 2208 } 2209 var element; 2210 if (typeExtension) { 2211 element = createElement(tag); 2212 element.setAttribute("is", typeExtension); 2213 return element; 2214 } 2215 element = domCreateElement(tag); 2216 if (tag.indexOf("-") >= 0) { 2217 implementPrototype(element, HTMLElement); 2218 } 2219 return element; 2220 } 2221 var domCreateElement = document.createElement.bind(document); 2222 var domCreateElementNS = document.createElementNS.bind(document); 2223 var isInstance; 2224 if (!Object.__proto__ && !useNative) { 2225 isInstance = function(obj, ctor) { 2226 if (obj instanceof ctor) { 2227 return true; 2228 } 2229 var p = obj; 2230 while (p) { 2231 if (p === ctor.prototype) { 2232 return true; 2233 } 2234 p = p.__proto__; 2235 } 2236 return false; 2237 }; 2238 } else { 2239 isInstance = function(obj, base) { 2240 return obj instanceof base; 2241 }; 2242 } 2243 function wrapDomMethodToForceUpgrade(obj, methodName) { 2244 var orig = obj[methodName]; 2245 obj[methodName] = function() { 2246 var n = orig.apply(this, arguments); 2247 upgradeAll(n); 2248 return n; 2249 }; 2250 } 2251 wrapDomMethodToForceUpgrade(Node.prototype, "cloneNode"); 2252 wrapDomMethodToForceUpgrade(document, "importNode"); 2253 document.registerElement = register; 2254 document.createElement = createElement; 2255 document.createElementNS = createElementNS; 2256 scope.registry = registry; 2257 scope.instanceof = isInstance; 2258 scope.reservedTagList = reservedTagList; 2259 scope.getRegisteredDefinition = getRegisteredDefinition; 2260 document.register = document.registerElement; 2261 }); 2262 2263 (function(scope) { 2264 var useNative = scope.useNative; 2265 var initializeModules = scope.initializeModules; 2266 var isIE = scope.isIE; 2267 if (useNative) { 2268 var nop = function() {}; 2269 scope.watchShadow = nop; 2270 scope.upgrade = nop; 2271 scope.upgradeAll = nop; 2272 scope.upgradeDocumentTree = nop; 2273 scope.upgradeSubtree = nop; 2274 scope.takeRecords = nop; 2275 scope.instanceof = function(obj, base) { 2276 return obj instanceof base; 2277 }; 2278 } else { 2279 initializeModules(); 2280 } 2281 var upgradeDocumentTree = scope.upgradeDocumentTree; 2282 var upgradeDocument = scope.upgradeDocument; 2283 if (!window.wrap) { 2284 if (window.ShadowDOMPolyfill) { 2285 window.wrap = window.ShadowDOMPolyfill.wrapIfNeeded; 2286 window.unwrap = window.ShadowDOMPolyfill.unwrapIfNeeded; 2287 } else { 2288 window.wrap = window.unwrap = function(node) { 2289 return node; 2290 }; 2291 } 2292 } 2293 if (window.HTMLImports) { 2294 window.HTMLImports.__importsParsingHook = function(elt) { 2295 if (elt.import) { 2296 upgradeDocument(wrap(elt.import)); 2297 } 2298 }; 2299 } 2300 function bootstrap() { 2301 upgradeDocumentTree(window.wrap(document)); 2302 window.CustomElements.ready = true; 2303 var requestAnimationFrame = window.requestAnimationFrame || function(f) { 2304 setTimeout(f, 16); 2305 }; 2306 requestAnimationFrame(function() { 2307 setTimeout(function() { 2308 window.CustomElements.readyTime = Date.now(); 2309 if (window.HTMLImports) { 2310 window.CustomElements.elapsed = window.CustomElements.readyTime - window.HTMLImports.readyTime; 2311 } 2312 document.dispatchEvent(new CustomEvent("WebComponentsReady", { 2313 bubbles: true 2314 })); 2315 }); 2316 }); 2317 } 2318 if (document.readyState === "complete" || scope.flags.eager) { 2319 bootstrap(); 2320 } else if (document.readyState === "interactive" && !window.attachEvent && (!window.HTMLImports || window.HTMLImports.ready)) { 2321 bootstrap(); 2322 } else { 2323 var loadEvent = window.HTMLImports && !window.HTMLImports.ready ? "HTMLImportsLoaded" : "DOMContentLoaded"; 2324 window.addEventListener(loadEvent, bootstrap); 2325 } 2326 })(window.CustomElements); 2327 2328 (function(scope) { 2329 var style = document.createElement("style"); 2330 style.textContent = "" + "body {" + "transition: opacity ease-in 0.2s;" + " } \n" + "body[unresolved] {" + "opacity: 0; display: block; overflow: hidden; position: relative;" + " } \n"; 2331 var head = document.querySelector("head"); 2332 head.insertBefore(style, head.firstChild); 2333 })(window.WebComponents); 2334//
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.