polymer-rails 1.1.5 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/polymer/LICENSE.txt +27 -0
  3. data/app/assets/javascripts/polymer/bower.json +27 -0
  4. data/app/assets/javascripts/polymer/build.log +27 -0
  5. data/app/assets/javascripts/polymer/polymer-micro.html +598 -597
  6. data/app/assets/javascripts/polymer/polymer-mini.html +1859 -1527
  7. data/app/assets/javascripts/polymer/polymer.html +4467 -4284
  8. data/app/assets/javascripts/webcomponentsjs/CustomElements.js +1041 -0
  9. data/app/assets/javascripts/webcomponentsjs/CustomElements.min.js +11 -0
  10. data/app/assets/javascripts/webcomponentsjs/HTMLImports.js +1155 -0
  11. data/app/assets/javascripts/webcomponentsjs/HTMLImports.min.js +11 -0
  12. data/app/assets/javascripts/webcomponentsjs/MutationObserver.js +350 -0
  13. data/app/assets/javascripts/webcomponentsjs/MutationObserver.min.js +11 -0
  14. data/app/assets/javascripts/webcomponentsjs/README.md +125 -0
  15. data/app/assets/javascripts/webcomponentsjs/ShadowDOM.js +4452 -0
  16. data/app/assets/javascripts/webcomponentsjs/ShadowDOM.min.js +13 -0
  17. data/app/assets/javascripts/webcomponentsjs/bower.json +21 -0
  18. data/app/assets/javascripts/webcomponentsjs/build.log +398 -0
  19. data/app/assets/javascripts/webcomponentsjs/package.json +28 -0
  20. data/app/assets/javascripts/webcomponentsjs/webcomponents-lite.js +169 -151
  21. data/app/assets/javascripts/webcomponentsjs/webcomponents-lite.min.js +12 -0
  22. data/app/assets/javascripts/webcomponentsjs/webcomponents.js +108 -70
  23. data/app/assets/javascripts/webcomponentsjs/webcomponents.min.js +14 -0
  24. data/lib/polymer-rails/version.rb +1 -1
  25. metadata +22 -5
@@ -0,0 +1,1041 @@
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.17
11
+ if (typeof WeakMap === "undefined") {
12
+ (function() {
13
+ var defineProperty = Object.defineProperty;
14
+ var counter = Date.now() % 1e9;
15
+ var WeakMap = function() {
16
+ this.name = "__st" + (Math.random() * 1e9 >>> 0) + (counter++ + "__");
17
+ };
18
+ WeakMap.prototype = {
19
+ set: function(key, value) {
20
+ var entry = key[this.name];
21
+ if (entry && entry[0] === key) entry[1] = value; else defineProperty(key, this.name, {
22
+ value: [ key, value ],
23
+ writable: true
24
+ });
25
+ return this;
26
+ },
27
+ get: function(key) {
28
+ var entry;
29
+ return (entry = key[this.name]) && entry[0] === key ? entry[1] : undefined;
30
+ },
31
+ "delete": function(key) {
32
+ var entry = key[this.name];
33
+ if (!entry || entry[0] !== key) return false;
34
+ entry[0] = entry[1] = undefined;
35
+ return true;
36
+ },
37
+ has: function(key) {
38
+ var entry = key[this.name];
39
+ if (!entry) return false;
40
+ return entry[0] === key;
41
+ }
42
+ };
43
+ window.WeakMap = WeakMap;
44
+ })();
45
+ }
46
+
47
+ (function(global) {
48
+ if (global.JsMutationObserver) {
49
+ return;
50
+ }
51
+ var registrationsTable = new WeakMap();
52
+ var setImmediate;
53
+ if (/Trident|Edge/.test(navigator.userAgent)) {
54
+ setImmediate = setTimeout;
55
+ } else if (window.setImmediate) {
56
+ setImmediate = window.setImmediate;
57
+ } else {
58
+ var setImmediateQueue = [];
59
+ var sentinel = String(Math.random());
60
+ window.addEventListener("message", function(e) {
61
+ if (e.data === sentinel) {
62
+ var queue = setImmediateQueue;
63
+ setImmediateQueue = [];
64
+ queue.forEach(function(func) {
65
+ func();
66
+ });
67
+ }
68
+ });
69
+ setImmediate = function(func) {
70
+ setImmediateQueue.push(func);
71
+ window.postMessage(sentinel, "*");
72
+ };
73
+ }
74
+ var isScheduled = false;
75
+ var scheduledObservers = [];
76
+ function scheduleCallback(observer) {
77
+ scheduledObservers.push(observer);
78
+ if (!isScheduled) {
79
+ isScheduled = true;
80
+ setImmediate(dispatchCallbacks);
81
+ }
82
+ }
83
+ function wrapIfNeeded(node) {
84
+ return window.ShadowDOMPolyfill && window.ShadowDOMPolyfill.wrapIfNeeded(node) || node;
85
+ }
86
+ function dispatchCallbacks() {
87
+ isScheduled = false;
88
+ var observers = scheduledObservers;
89
+ scheduledObservers = [];
90
+ observers.sort(function(o1, o2) {
91
+ return o1.uid_ - o2.uid_;
92
+ });
93
+ var anyNonEmpty = false;
94
+ observers.forEach(function(observer) {
95
+ var queue = observer.takeRecords();
96
+ removeTransientObserversFor(observer);
97
+ if (queue.length) {
98
+ observer.callback_(queue, observer);
99
+ anyNonEmpty = true;
100
+ }
101
+ });
102
+ if (anyNonEmpty) dispatchCallbacks();
103
+ }
104
+ function removeTransientObserversFor(observer) {
105
+ observer.nodes_.forEach(function(node) {
106
+ var registrations = registrationsTable.get(node);
107
+ if (!registrations) return;
108
+ registrations.forEach(function(registration) {
109
+ if (registration.observer === observer) registration.removeTransientObservers();
110
+ });
111
+ });
112
+ }
113
+ function forEachAncestorAndObserverEnqueueRecord(target, callback) {
114
+ for (var node = target; node; node = node.parentNode) {
115
+ var registrations = registrationsTable.get(node);
116
+ if (registrations) {
117
+ for (var j = 0; j < registrations.length; j++) {
118
+ var registration = registrations[j];
119
+ var options = registration.options;
120
+ if (node !== target && !options.subtree) continue;
121
+ var record = callback(options);
122
+ if (record) registration.enqueue(record);
123
+ }
124
+ }
125
+ }
126
+ }
127
+ var uidCounter = 0;
128
+ function JsMutationObserver(callback) {
129
+ this.callback_ = callback;
130
+ this.nodes_ = [];
131
+ this.records_ = [];
132
+ this.uid_ = ++uidCounter;
133
+ }
134
+ JsMutationObserver.prototype = {
135
+ observe: function(target, options) {
136
+ target = wrapIfNeeded(target);
137
+ if (!options.childList && !options.attributes && !options.characterData || options.attributeOldValue && !options.attributes || options.attributeFilter && options.attributeFilter.length && !options.attributes || options.characterDataOldValue && !options.characterData) {
138
+ throw new SyntaxError();
139
+ }
140
+ var registrations = registrationsTable.get(target);
141
+ if (!registrations) registrationsTable.set(target, registrations = []);
142
+ var registration;
143
+ for (var i = 0; i < registrations.length; i++) {
144
+ if (registrations[i].observer === this) {
145
+ registration = registrations[i];
146
+ registration.removeListeners();
147
+ registration.options = options;
148
+ break;
149
+ }
150
+ }
151
+ if (!registration) {
152
+ registration = new Registration(this, target, options);
153
+ registrations.push(registration);
154
+ this.nodes_.push(target);
155
+ }
156
+ registration.addListeners();
157
+ },
158
+ disconnect: function() {
159
+ this.nodes_.forEach(function(node) {
160
+ var registrations = registrationsTable.get(node);
161
+ for (var i = 0; i < registrations.length; i++) {
162
+ var registration = registrations[i];
163
+ if (registration.observer === this) {
164
+ registration.removeListeners();
165
+ registrations.splice(i, 1);
166
+ break;
167
+ }
168
+ }
169
+ }, this);
170
+ this.records_ = [];
171
+ },
172
+ takeRecords: function() {
173
+ var copyOfRecords = this.records_;
174
+ this.records_ = [];
175
+ return copyOfRecords;
176
+ }
177
+ };
178
+ function MutationRecord(type, target) {
179
+ this.type = type;
180
+ this.target = target;
181
+ this.addedNodes = [];
182
+ this.removedNodes = [];
183
+ this.previousSibling = null;
184
+ this.nextSibling = null;
185
+ this.attributeName = null;
186
+ this.attributeNamespace = null;
187
+ this.oldValue = null;
188
+ }
189
+ function copyMutationRecord(original) {
190
+ var record = new MutationRecord(original.type, original.target);
191
+ record.addedNodes = original.addedNodes.slice();
192
+ record.removedNodes = original.removedNodes.slice();
193
+ record.previousSibling = original.previousSibling;
194
+ record.nextSibling = original.nextSibling;
195
+ record.attributeName = original.attributeName;
196
+ record.attributeNamespace = original.attributeNamespace;
197
+ record.oldValue = original.oldValue;
198
+ return record;
199
+ }
200
+ var currentRecord, recordWithOldValue;
201
+ function getRecord(type, target) {
202
+ return currentRecord = new MutationRecord(type, target);
203
+ }
204
+ function getRecordWithOldValue(oldValue) {
205
+ if (recordWithOldValue) return recordWithOldValue;
206
+ recordWithOldValue = copyMutationRecord(currentRecord);
207
+ recordWithOldValue.oldValue = oldValue;
208
+ return recordWithOldValue;
209
+ }
210
+ function clearRecords() {
211
+ currentRecord = recordWithOldValue = undefined;
212
+ }
213
+ function recordRepresentsCurrentMutation(record) {
214
+ return record === recordWithOldValue || record === currentRecord;
215
+ }
216
+ function selectRecord(lastRecord, newRecord) {
217
+ if (lastRecord === newRecord) return lastRecord;
218
+ if (recordWithOldValue && recordRepresentsCurrentMutation(lastRecord)) return recordWithOldValue;
219
+ return null;
220
+ }
221
+ function Registration(observer, target, options) {
222
+ this.observer = observer;
223
+ this.target = target;
224
+ this.options = options;
225
+ this.transientObservedNodes = [];
226
+ }
227
+ Registration.prototype = {
228
+ enqueue: function(record) {
229
+ var records = this.observer.records_;
230
+ var length = records.length;
231
+ if (records.length > 0) {
232
+ var lastRecord = records[length - 1];
233
+ var recordToReplaceLast = selectRecord(lastRecord, record);
234
+ if (recordToReplaceLast) {
235
+ records[length - 1] = recordToReplaceLast;
236
+ return;
237
+ }
238
+ } else {
239
+ scheduleCallback(this.observer);
240
+ }
241
+ records[length] = record;
242
+ },
243
+ addListeners: function() {
244
+ this.addListeners_(this.target);
245
+ },
246
+ addListeners_: function(node) {
247
+ var options = this.options;
248
+ if (options.attributes) node.addEventListener("DOMAttrModified", this, true);
249
+ if (options.characterData) node.addEventListener("DOMCharacterDataModified", this, true);
250
+ if (options.childList) node.addEventListener("DOMNodeInserted", this, true);
251
+ if (options.childList || options.subtree) node.addEventListener("DOMNodeRemoved", this, true);
252
+ },
253
+ removeListeners: function() {
254
+ this.removeListeners_(this.target);
255
+ },
256
+ removeListeners_: function(node) {
257
+ var options = this.options;
258
+ if (options.attributes) node.removeEventListener("DOMAttrModified", this, true);
259
+ if (options.characterData) node.removeEventListener("DOMCharacterDataModified", this, true);
260
+ if (options.childList) node.removeEventListener("DOMNodeInserted", this, true);
261
+ if (options.childList || options.subtree) node.removeEventListener("DOMNodeRemoved", this, true);
262
+ },
263
+ addTransientObserver: function(node) {
264
+ if (node === this.target) return;
265
+ this.addListeners_(node);
266
+ this.transientObservedNodes.push(node);
267
+ var registrations = registrationsTable.get(node);
268
+ if (!registrations) registrationsTable.set(node, registrations = []);
269
+ registrations.push(this);
270
+ },
271
+ removeTransientObservers: function() {
272
+ var transientObservedNodes = this.transientObservedNodes;
273
+ this.transientObservedNodes = [];
274
+ transientObservedNodes.forEach(function(node) {
275
+ this.removeListeners_(node);
276
+ var registrations = registrationsTable.get(node);
277
+ for (var i = 0; i < registrations.length; i++) {
278
+ if (registrations[i] === this) {
279
+ registrations.splice(i, 1);
280
+ break;
281
+ }
282
+ }
283
+ }, this);
284
+ },
285
+ handleEvent: function(e) {
286
+ e.stopImmediatePropagation();
287
+ switch (e.type) {
288
+ case "DOMAttrModified":
289
+ var name = e.attrName;
290
+ var namespace = e.relatedNode.namespaceURI;
291
+ var target = e.target;
292
+ var record = new getRecord("attributes", target);
293
+ record.attributeName = name;
294
+ record.attributeNamespace = namespace;
295
+ var oldValue = e.attrChange === MutationEvent.ADDITION ? null : e.prevValue;
296
+ forEachAncestorAndObserverEnqueueRecord(target, function(options) {
297
+ if (!options.attributes) return;
298
+ if (options.attributeFilter && options.attributeFilter.length && options.attributeFilter.indexOf(name) === -1 && options.attributeFilter.indexOf(namespace) === -1) {
299
+ return;
300
+ }
301
+ if (options.attributeOldValue) return getRecordWithOldValue(oldValue);
302
+ return record;
303
+ });
304
+ break;
305
+
306
+ case "DOMCharacterDataModified":
307
+ var target = e.target;
308
+ var record = getRecord("characterData", target);
309
+ var oldValue = e.prevValue;
310
+ forEachAncestorAndObserverEnqueueRecord(target, function(options) {
311
+ if (!options.characterData) return;
312
+ if (options.characterDataOldValue) return getRecordWithOldValue(oldValue);
313
+ return record;
314
+ });
315
+ break;
316
+
317
+ case "DOMNodeRemoved":
318
+ this.addTransientObserver(e.target);
319
+
320
+ case "DOMNodeInserted":
321
+ var changedNode = e.target;
322
+ var addedNodes, removedNodes;
323
+ if (e.type === "DOMNodeInserted") {
324
+ addedNodes = [ changedNode ];
325
+ removedNodes = [];
326
+ } else {
327
+ addedNodes = [];
328
+ removedNodes = [ changedNode ];
329
+ }
330
+ var previousSibling = changedNode.previousSibling;
331
+ var nextSibling = changedNode.nextSibling;
332
+ var record = getRecord("childList", e.target.parentNode);
333
+ record.addedNodes = addedNodes;
334
+ record.removedNodes = removedNodes;
335
+ record.previousSibling = previousSibling;
336
+ record.nextSibling = nextSibling;
337
+ forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function(options) {
338
+ if (!options.childList) return;
339
+ return record;
340
+ });
341
+ }
342
+ clearRecords();
343
+ }
344
+ };
345
+ global.JsMutationObserver = JsMutationObserver;
346
+ if (!global.MutationObserver) {
347
+ global.MutationObserver = JsMutationObserver;
348
+ JsMutationObserver._isPolyfilled = true;
349
+ }
350
+ })(self);
351
+
352
+ (function(scope) {
353
+ "use strict";
354
+ if (!window.performance) {
355
+ var start = Date.now();
356
+ window.performance = {
357
+ now: function() {
358
+ return Date.now() - start;
359
+ }
360
+ };
361
+ }
362
+ if (!window.requestAnimationFrame) {
363
+ window.requestAnimationFrame = function() {
364
+ var nativeRaf = window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame;
365
+ return nativeRaf ? function(callback) {
366
+ return nativeRaf(function() {
367
+ callback(performance.now());
368
+ });
369
+ } : function(callback) {
370
+ return window.setTimeout(callback, 1e3 / 60);
371
+ };
372
+ }();
373
+ }
374
+ if (!window.cancelAnimationFrame) {
375
+ window.cancelAnimationFrame = function() {
376
+ return window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || function(id) {
377
+ clearTimeout(id);
378
+ };
379
+ }();
380
+ }
381
+ var workingDefaultPrevented = function() {
382
+ var e = document.createEvent("Event");
383
+ e.initEvent("foo", true, true);
384
+ e.preventDefault();
385
+ return e.defaultPrevented;
386
+ }();
387
+ if (!workingDefaultPrevented) {
388
+ var origPreventDefault = Event.prototype.preventDefault;
389
+ Event.prototype.preventDefault = function() {
390
+ if (!this.cancelable) {
391
+ return;
392
+ }
393
+ origPreventDefault.call(this);
394
+ Object.defineProperty(this, "defaultPrevented", {
395
+ get: function() {
396
+ return true;
397
+ }
398
+ });
399
+ };
400
+ }
401
+ var isIE = /Trident/.test(navigator.userAgent);
402
+ if (!window.CustomEvent || isIE && typeof window.CustomEvent !== "function") {
403
+ window.CustomEvent = function(inType, params) {
404
+ params = params || {};
405
+ var e = document.createEvent("CustomEvent");
406
+ e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable), params.detail);
407
+ return e;
408
+ };
409
+ window.CustomEvent.prototype = window.Event.prototype;
410
+ }
411
+ if (!window.Event || isIE && typeof window.Event !== "function") {
412
+ var origEvent = window.Event;
413
+ window.Event = function(inType, params) {
414
+ params = params || {};
415
+ var e = document.createEvent("Event");
416
+ e.initEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable));
417
+ return e;
418
+ };
419
+ window.Event.prototype = origEvent.prototype;
420
+ }
421
+ })(window.WebComponents);
422
+
423
+ window.CustomElements = window.CustomElements || {
424
+ flags: {}
425
+ };
426
+
427
+ (function(scope) {
428
+ var flags = scope.flags;
429
+ var modules = [];
430
+ var addModule = function(module) {
431
+ modules.push(module);
432
+ };
433
+ var initializeModules = function() {
434
+ modules.forEach(function(module) {
435
+ module(scope);
436
+ });
437
+ };
438
+ scope.addModule = addModule;
439
+ scope.initializeModules = initializeModules;
440
+ scope.hasNative = Boolean(document.registerElement);
441
+ scope.isIE = /Trident/.test(navigator.userAgent);
442
+ scope.useNative = !flags.register && scope.hasNative && !window.ShadowDOMPolyfill && (!window.HTMLImports || window.HTMLImports.useNative);
443
+ })(window.CustomElements);
444
+
445
+ window.CustomElements.addModule(function(scope) {
446
+ var IMPORT_LINK_TYPE = window.HTMLImports ? window.HTMLImports.IMPORT_LINK_TYPE : "none";
447
+ function forSubtree(node, cb) {
448
+ findAllElements(node, function(e) {
449
+ if (cb(e)) {
450
+ return true;
451
+ }
452
+ forRoots(e, cb);
453
+ });
454
+ forRoots(node, cb);
455
+ }
456
+ function findAllElements(node, find, data) {
457
+ var e = node.firstElementChild;
458
+ if (!e) {
459
+ e = node.firstChild;
460
+ while (e && e.nodeType !== Node.ELEMENT_NODE) {
461
+ e = e.nextSibling;
462
+ }
463
+ }
464
+ while (e) {
465
+ if (find(e, data) !== true) {
466
+ findAllElements(e, find, data);
467
+ }
468
+ e = e.nextElementSibling;
469
+ }
470
+ return null;
471
+ }
472
+ function forRoots(node, cb) {
473
+ var root = node.shadowRoot;
474
+ while (root) {
475
+ forSubtree(root, cb);
476
+ root = root.olderShadowRoot;
477
+ }
478
+ }
479
+ function forDocumentTree(doc, cb) {
480
+ _forDocumentTree(doc, cb, []);
481
+ }
482
+ function _forDocumentTree(doc, cb, processingDocuments) {
483
+ doc = window.wrap(doc);
484
+ if (processingDocuments.indexOf(doc) >= 0) {
485
+ return;
486
+ }
487
+ processingDocuments.push(doc);
488
+ var imports = doc.querySelectorAll("link[rel=" + IMPORT_LINK_TYPE + "]");
489
+ for (var i = 0, l = imports.length, n; i < l && (n = imports[i]); i++) {
490
+ if (n.import) {
491
+ _forDocumentTree(n.import, cb, processingDocuments);
492
+ }
493
+ }
494
+ cb(doc);
495
+ }
496
+ scope.forDocumentTree = forDocumentTree;
497
+ scope.forSubtree = forSubtree;
498
+ });
499
+
500
+ window.CustomElements.addModule(function(scope) {
501
+ var flags = scope.flags;
502
+ var forSubtree = scope.forSubtree;
503
+ var forDocumentTree = scope.forDocumentTree;
504
+ function addedNode(node, isAttached) {
505
+ return added(node, isAttached) || addedSubtree(node, isAttached);
506
+ }
507
+ function added(node, isAttached) {
508
+ if (scope.upgrade(node, isAttached)) {
509
+ return true;
510
+ }
511
+ if (isAttached) {
512
+ attached(node);
513
+ }
514
+ }
515
+ function addedSubtree(node, isAttached) {
516
+ forSubtree(node, function(e) {
517
+ if (added(e, isAttached)) {
518
+ return true;
519
+ }
520
+ });
521
+ }
522
+ var hasThrottledAttached = window.MutationObserver._isPolyfilled && flags["throttle-attached"];
523
+ scope.hasPolyfillMutations = hasThrottledAttached;
524
+ scope.hasThrottledAttached = hasThrottledAttached;
525
+ var isPendingMutations = false;
526
+ var pendingMutations = [];
527
+ function deferMutation(fn) {
528
+ pendingMutations.push(fn);
529
+ if (!isPendingMutations) {
530
+ isPendingMutations = true;
531
+ setTimeout(takeMutations);
532
+ }
533
+ }
534
+ function takeMutations() {
535
+ isPendingMutations = false;
536
+ var $p = pendingMutations;
537
+ for (var i = 0, l = $p.length, p; i < l && (p = $p[i]); i++) {
538
+ p();
539
+ }
540
+ pendingMutations = [];
541
+ }
542
+ function attached(element) {
543
+ if (hasThrottledAttached) {
544
+ deferMutation(function() {
545
+ _attached(element);
546
+ });
547
+ } else {
548
+ _attached(element);
549
+ }
550
+ }
551
+ function _attached(element) {
552
+ if (element.__upgraded__ && !element.__attached) {
553
+ element.__attached = true;
554
+ if (element.attachedCallback) {
555
+ element.attachedCallback();
556
+ }
557
+ }
558
+ }
559
+ function detachedNode(node) {
560
+ detached(node);
561
+ forSubtree(node, function(e) {
562
+ detached(e);
563
+ });
564
+ }
565
+ function detached(element) {
566
+ if (hasThrottledAttached) {
567
+ deferMutation(function() {
568
+ _detached(element);
569
+ });
570
+ } else {
571
+ _detached(element);
572
+ }
573
+ }
574
+ function _detached(element) {
575
+ if (element.__upgraded__ && element.__attached) {
576
+ element.__attached = false;
577
+ if (element.detachedCallback) {
578
+ element.detachedCallback();
579
+ }
580
+ }
581
+ }
582
+ function inDocument(element) {
583
+ var p = element;
584
+ var doc = window.wrap(document);
585
+ while (p) {
586
+ if (p == doc) {
587
+ return true;
588
+ }
589
+ p = p.parentNode || p.nodeType === Node.DOCUMENT_FRAGMENT_NODE && p.host;
590
+ }
591
+ }
592
+ function watchShadow(node) {
593
+ if (node.shadowRoot && !node.shadowRoot.__watched) {
594
+ flags.dom && console.log("watching shadow-root for: ", node.localName);
595
+ var root = node.shadowRoot;
596
+ while (root) {
597
+ observe(root);
598
+ root = root.olderShadowRoot;
599
+ }
600
+ }
601
+ }
602
+ function handler(root, mutations) {
603
+ if (flags.dom) {
604
+ var mx = mutations[0];
605
+ if (mx && mx.type === "childList" && mx.addedNodes) {
606
+ if (mx.addedNodes) {
607
+ var d = mx.addedNodes[0];
608
+ while (d && d !== document && !d.host) {
609
+ d = d.parentNode;
610
+ }
611
+ var u = d && (d.URL || d._URL || d.host && d.host.localName) || "";
612
+ u = u.split("/?").shift().split("/").pop();
613
+ }
614
+ }
615
+ console.group("mutations (%d) [%s]", mutations.length, u || "");
616
+ }
617
+ var isAttached = inDocument(root);
618
+ mutations.forEach(function(mx) {
619
+ if (mx.type === "childList") {
620
+ forEach(mx.addedNodes, function(n) {
621
+ if (!n.localName) {
622
+ return;
623
+ }
624
+ addedNode(n, isAttached);
625
+ });
626
+ forEach(mx.removedNodes, function(n) {
627
+ if (!n.localName) {
628
+ return;
629
+ }
630
+ detachedNode(n);
631
+ });
632
+ }
633
+ });
634
+ flags.dom && console.groupEnd();
635
+ }
636
+ function takeRecords(node) {
637
+ node = window.wrap(node);
638
+ if (!node) {
639
+ node = window.wrap(document);
640
+ }
641
+ while (node.parentNode) {
642
+ node = node.parentNode;
643
+ }
644
+ var observer = node.__observer;
645
+ if (observer) {
646
+ handler(node, observer.takeRecords());
647
+ takeMutations();
648
+ }
649
+ }
650
+ var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach);
651
+ function observe(inRoot) {
652
+ if (inRoot.__observer) {
653
+ return;
654
+ }
655
+ var observer = new MutationObserver(handler.bind(this, inRoot));
656
+ observer.observe(inRoot, {
657
+ childList: true,
658
+ subtree: true
659
+ });
660
+ inRoot.__observer = observer;
661
+ }
662
+ function upgradeDocument(doc) {
663
+ doc = window.wrap(doc);
664
+ flags.dom && console.group("upgradeDocument: ", doc.baseURI.split("/").pop());
665
+ var isMainDocument = doc === window.wrap(document);
666
+ addedNode(doc, isMainDocument);
667
+ observe(doc);
668
+ flags.dom && console.groupEnd();
669
+ }
670
+ function upgradeDocumentTree(doc) {
671
+ forDocumentTree(doc, upgradeDocument);
672
+ }
673
+ var originalCreateShadowRoot = Element.prototype.createShadowRoot;
674
+ if (originalCreateShadowRoot) {
675
+ Element.prototype.createShadowRoot = function() {
676
+ var root = originalCreateShadowRoot.call(this);
677
+ window.CustomElements.watchShadow(this);
678
+ return root;
679
+ };
680
+ }
681
+ function upgradeAll(doc) {
682
+ if (HTMLTemplateElement && HTMLTemplateElement.bootstrap) {
683
+ HTMLTemplateElement.bootstrap(doc);
684
+ }
685
+ addedNode(doc);
686
+ }
687
+ scope.watchShadow = watchShadow;
688
+ scope.upgradeDocumentTree = upgradeDocumentTree;
689
+ scope.upgradeDocument = upgradeDocument;
690
+ scope.upgradeSubtree = addedSubtree;
691
+ scope.upgradeAll = upgradeAll;
692
+ scope.attached = attached;
693
+ scope.takeRecords = takeRecords;
694
+ });
695
+
696
+ window.CustomElements.addModule(function(scope) {
697
+ var flags = scope.flags;
698
+ function upgrade(node, isAttached) {
699
+ if (!node.__upgraded__ && node.nodeType === Node.ELEMENT_NODE) {
700
+ var is = node.getAttribute("is");
701
+ var definition = scope.getRegisteredDefinition(node.localName) || scope.getRegisteredDefinition(is);
702
+ if (definition) {
703
+ if (is && definition.tag == node.localName || !is && !definition.extends) {
704
+ return upgradeWithDefinition(node, definition, isAttached);
705
+ }
706
+ }
707
+ }
708
+ }
709
+ function upgradeWithDefinition(element, definition, isAttached) {
710
+ flags.upgrade && console.group("upgrade:", element.localName);
711
+ if (definition.is) {
712
+ element.setAttribute("is", definition.is);
713
+ }
714
+ implementPrototype(element, definition);
715
+ element.__upgraded__ = true;
716
+ created(element);
717
+ if (isAttached) {
718
+ scope.attached(element);
719
+ }
720
+ scope.upgradeSubtree(element, isAttached);
721
+ flags.upgrade && console.groupEnd();
722
+ return element;
723
+ }
724
+ function implementPrototype(element, definition) {
725
+ if (Object.__proto__) {
726
+ element.__proto__ = definition.prototype;
727
+ } else {
728
+ customMixin(element, definition.prototype, definition.native);
729
+ element.__proto__ = definition.prototype;
730
+ }
731
+ }
732
+ function customMixin(inTarget, inSrc, inNative) {
733
+ var used = {};
734
+ var p = inSrc;
735
+ while (p !== inNative && p !== HTMLElement.prototype) {
736
+ var keys = Object.getOwnPropertyNames(p);
737
+ for (var i = 0, k; k = keys[i]; i++) {
738
+ if (!used[k]) {
739
+ Object.defineProperty(inTarget, k, Object.getOwnPropertyDescriptor(p, k));
740
+ used[k] = 1;
741
+ }
742
+ }
743
+ p = Object.getPrototypeOf(p);
744
+ }
745
+ }
746
+ function created(element) {
747
+ if (element.createdCallback) {
748
+ element.createdCallback();
749
+ }
750
+ }
751
+ scope.upgrade = upgrade;
752
+ scope.upgradeWithDefinition = upgradeWithDefinition;
753
+ scope.implementPrototype = implementPrototype;
754
+ });
755
+
756
+ window.CustomElements.addModule(function(scope) {
757
+ var isIE = scope.isIE;
758
+ var upgradeDocumentTree = scope.upgradeDocumentTree;
759
+ var upgradeAll = scope.upgradeAll;
760
+ var upgradeWithDefinition = scope.upgradeWithDefinition;
761
+ var implementPrototype = scope.implementPrototype;
762
+ var useNative = scope.useNative;
763
+ function register(name, options) {
764
+ var definition = options || {};
765
+ if (!name) {
766
+ throw new Error("document.registerElement: first argument `name` must not be empty");
767
+ }
768
+ if (name.indexOf("-") < 0) {
769
+ throw new Error("document.registerElement: first argument ('name') must contain a dash ('-'). Argument provided was '" + String(name) + "'.");
770
+ }
771
+ if (isReservedTag(name)) {
772
+ throw new Error("Failed to execute 'registerElement' on 'Document': Registration failed for type '" + String(name) + "'. The type name is invalid.");
773
+ }
774
+ if (getRegisteredDefinition(name)) {
775
+ throw new Error("DuplicateDefinitionError: a type with name '" + String(name) + "' is already registered");
776
+ }
777
+ if (!definition.prototype) {
778
+ definition.prototype = Object.create(HTMLElement.prototype);
779
+ }
780
+ definition.__name = name.toLowerCase();
781
+ definition.lifecycle = definition.lifecycle || {};
782
+ definition.ancestry = ancestry(definition.extends);
783
+ resolveTagName(definition);
784
+ resolvePrototypeChain(definition);
785
+ overrideAttributeApi(definition.prototype);
786
+ registerDefinition(definition.__name, definition);
787
+ definition.ctor = generateConstructor(definition);
788
+ definition.ctor.prototype = definition.prototype;
789
+ definition.prototype.constructor = definition.ctor;
790
+ if (scope.ready) {
791
+ upgradeDocumentTree(document);
792
+ }
793
+ return definition.ctor;
794
+ }
795
+ function overrideAttributeApi(prototype) {
796
+ if (prototype.setAttribute._polyfilled) {
797
+ return;
798
+ }
799
+ var setAttribute = prototype.setAttribute;
800
+ prototype.setAttribute = function(name, value) {
801
+ changeAttribute.call(this, name, value, setAttribute);
802
+ };
803
+ var removeAttribute = prototype.removeAttribute;
804
+ prototype.removeAttribute = function(name) {
805
+ changeAttribute.call(this, name, null, removeAttribute);
806
+ };
807
+ prototype.setAttribute._polyfilled = true;
808
+ }
809
+ function changeAttribute(name, value, operation) {
810
+ name = name.toLowerCase();
811
+ var oldValue = this.getAttribute(name);
812
+ operation.apply(this, arguments);
813
+ var newValue = this.getAttribute(name);
814
+ if (this.attributeChangedCallback && newValue !== oldValue) {
815
+ this.attributeChangedCallback(name, oldValue, newValue);
816
+ }
817
+ }
818
+ function isReservedTag(name) {
819
+ for (var i = 0; i < reservedTagList.length; i++) {
820
+ if (name === reservedTagList[i]) {
821
+ return true;
822
+ }
823
+ }
824
+ }
825
+ var reservedTagList = [ "annotation-xml", "color-profile", "font-face", "font-face-src", "font-face-uri", "font-face-format", "font-face-name", "missing-glyph" ];
826
+ function ancestry(extnds) {
827
+ var extendee = getRegisteredDefinition(extnds);
828
+ if (extendee) {
829
+ return ancestry(extendee.extends).concat([ extendee ]);
830
+ }
831
+ return [];
832
+ }
833
+ function resolveTagName(definition) {
834
+ var baseTag = definition.extends;
835
+ for (var i = 0, a; a = definition.ancestry[i]; i++) {
836
+ baseTag = a.is && a.tag;
837
+ }
838
+ definition.tag = baseTag || definition.__name;
839
+ if (baseTag) {
840
+ definition.is = definition.__name;
841
+ }
842
+ }
843
+ function resolvePrototypeChain(definition) {
844
+ if (!Object.__proto__) {
845
+ var nativePrototype = HTMLElement.prototype;
846
+ if (definition.is) {
847
+ var inst = document.createElement(definition.tag);
848
+ nativePrototype = Object.getPrototypeOf(inst);
849
+ }
850
+ var proto = definition.prototype, ancestor;
851
+ var foundPrototype = false;
852
+ while (proto) {
853
+ if (proto == nativePrototype) {
854
+ foundPrototype = true;
855
+ }
856
+ ancestor = Object.getPrototypeOf(proto);
857
+ if (ancestor) {
858
+ proto.__proto__ = ancestor;
859
+ }
860
+ proto = ancestor;
861
+ }
862
+ if (!foundPrototype) {
863
+ console.warn(definition.tag + " prototype not found in prototype chain for " + definition.is);
864
+ }
865
+ definition.native = nativePrototype;
866
+ }
867
+ }
868
+ function instantiate(definition) {
869
+ return upgradeWithDefinition(domCreateElement(definition.tag), definition);
870
+ }
871
+ var registry = {};
872
+ function getRegisteredDefinition(name) {
873
+ if (name) {
874
+ return registry[name.toLowerCase()];
875
+ }
876
+ }
877
+ function registerDefinition(name, definition) {
878
+ registry[name] = definition;
879
+ }
880
+ function generateConstructor(definition) {
881
+ return function() {
882
+ return instantiate(definition);
883
+ };
884
+ }
885
+ var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
886
+ function createElementNS(namespace, tag, typeExtension) {
887
+ if (namespace === HTML_NAMESPACE) {
888
+ return createElement(tag, typeExtension);
889
+ } else {
890
+ return domCreateElementNS(namespace, tag);
891
+ }
892
+ }
893
+ function createElement(tag, typeExtension) {
894
+ if (tag) {
895
+ tag = tag.toLowerCase();
896
+ }
897
+ if (typeExtension) {
898
+ typeExtension = typeExtension.toLowerCase();
899
+ }
900
+ var definition = getRegisteredDefinition(typeExtension || tag);
901
+ if (definition) {
902
+ if (tag == definition.tag && typeExtension == definition.is) {
903
+ return new definition.ctor();
904
+ }
905
+ if (!typeExtension && !definition.is) {
906
+ return new definition.ctor();
907
+ }
908
+ }
909
+ var element;
910
+ if (typeExtension) {
911
+ element = createElement(tag);
912
+ element.setAttribute("is", typeExtension);
913
+ return element;
914
+ }
915
+ element = domCreateElement(tag);
916
+ if (tag.indexOf("-") >= 0) {
917
+ implementPrototype(element, HTMLElement);
918
+ }
919
+ return element;
920
+ }
921
+ var domCreateElement = document.createElement.bind(document);
922
+ var domCreateElementNS = document.createElementNS.bind(document);
923
+ var isInstance;
924
+ if (!Object.__proto__ && !useNative) {
925
+ isInstance = function(obj, ctor) {
926
+ if (obj instanceof ctor) {
927
+ return true;
928
+ }
929
+ var p = obj;
930
+ while (p) {
931
+ if (p === ctor.prototype) {
932
+ return true;
933
+ }
934
+ p = p.__proto__;
935
+ }
936
+ return false;
937
+ };
938
+ } else {
939
+ isInstance = function(obj, base) {
940
+ return obj instanceof base;
941
+ };
942
+ }
943
+ function wrapDomMethodToForceUpgrade(obj, methodName) {
944
+ var orig = obj[methodName];
945
+ obj[methodName] = function() {
946
+ var n = orig.apply(this, arguments);
947
+ upgradeAll(n);
948
+ return n;
949
+ };
950
+ }
951
+ wrapDomMethodToForceUpgrade(Node.prototype, "cloneNode");
952
+ wrapDomMethodToForceUpgrade(document, "importNode");
953
+ if (isIE) {
954
+ (function() {
955
+ var importNode = document.importNode;
956
+ document.importNode = function() {
957
+ var n = importNode.apply(document, arguments);
958
+ if (n.nodeType == n.DOCUMENT_FRAGMENT_NODE) {
959
+ var f = document.createDocumentFragment();
960
+ f.appendChild(n);
961
+ return f;
962
+ } else {
963
+ return n;
964
+ }
965
+ };
966
+ })();
967
+ }
968
+ document.registerElement = register;
969
+ document.createElement = createElement;
970
+ document.createElementNS = createElementNS;
971
+ scope.registry = registry;
972
+ scope.instanceof = isInstance;
973
+ scope.reservedTagList = reservedTagList;
974
+ scope.getRegisteredDefinition = getRegisteredDefinition;
975
+ document.register = document.registerElement;
976
+ });
977
+
978
+ (function(scope) {
979
+ var useNative = scope.useNative;
980
+ var initializeModules = scope.initializeModules;
981
+ var isIE = scope.isIE;
982
+ if (useNative) {
983
+ var nop = function() {};
984
+ scope.watchShadow = nop;
985
+ scope.upgrade = nop;
986
+ scope.upgradeAll = nop;
987
+ scope.upgradeDocumentTree = nop;
988
+ scope.upgradeSubtree = nop;
989
+ scope.takeRecords = nop;
990
+ scope.instanceof = function(obj, base) {
991
+ return obj instanceof base;
992
+ };
993
+ } else {
994
+ initializeModules();
995
+ }
996
+ var upgradeDocumentTree = scope.upgradeDocumentTree;
997
+ var upgradeDocument = scope.upgradeDocument;
998
+ if (!window.wrap) {
999
+ if (window.ShadowDOMPolyfill) {
1000
+ window.wrap = window.ShadowDOMPolyfill.wrapIfNeeded;
1001
+ window.unwrap = window.ShadowDOMPolyfill.unwrapIfNeeded;
1002
+ } else {
1003
+ window.wrap = window.unwrap = function(node) {
1004
+ return node;
1005
+ };
1006
+ }
1007
+ }
1008
+ if (window.HTMLImports) {
1009
+ window.HTMLImports.__importsParsingHook = function(elt) {
1010
+ if (elt.import) {
1011
+ upgradeDocument(wrap(elt.import));
1012
+ }
1013
+ };
1014
+ }
1015
+ function bootstrap() {
1016
+ upgradeDocumentTree(window.wrap(document));
1017
+ window.CustomElements.ready = true;
1018
+ var requestAnimationFrame = window.requestAnimationFrame || function(f) {
1019
+ setTimeout(f, 16);
1020
+ };
1021
+ requestAnimationFrame(function() {
1022
+ setTimeout(function() {
1023
+ window.CustomElements.readyTime = Date.now();
1024
+ if (window.HTMLImports) {
1025
+ window.CustomElements.elapsed = window.CustomElements.readyTime - window.HTMLImports.readyTime;
1026
+ }
1027
+ document.dispatchEvent(new CustomEvent("WebComponentsReady", {
1028
+ bubbles: true
1029
+ }));
1030
+ });
1031
+ });
1032
+ }
1033
+ if (document.readyState === "complete" || scope.flags.eager) {
1034
+ bootstrap();
1035
+ } else if (document.readyState === "interactive" && !window.attachEvent && (!window.HTMLImports || window.HTMLImports.ready)) {
1036
+ bootstrap();
1037
+ } else {
1038
+ var loadEvent = window.HTMLImports && !window.HTMLImports.ready ? "HTMLImportsLoaded" : "DOMContentLoaded";
1039
+ window.addEventListener(loadEvent, bootstrap);
1040
+ }
1041
+ })(window.CustomElements);