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