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