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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/polymer/LICENSE.txt +27 -0
- data/app/assets/javascripts/polymer/bower.json +27 -0
- data/app/assets/javascripts/polymer/build.log +27 -0
- data/app/assets/javascripts/polymer/polymer-micro.html +598 -597
- data/app/assets/javascripts/polymer/polymer-mini.html +1859 -1527
- data/app/assets/javascripts/polymer/polymer.html +4467 -4284
- data/app/assets/javascripts/webcomponentsjs/CustomElements.js +1041 -0
- data/app/assets/javascripts/webcomponentsjs/CustomElements.min.js +11 -0
- data/app/assets/javascripts/webcomponentsjs/HTMLImports.js +1155 -0
- data/app/assets/javascripts/webcomponentsjs/HTMLImports.min.js +11 -0
- data/app/assets/javascripts/webcomponentsjs/MutationObserver.js +350 -0
- data/app/assets/javascripts/webcomponentsjs/MutationObserver.min.js +11 -0
- data/app/assets/javascripts/webcomponentsjs/README.md +125 -0
- data/app/assets/javascripts/webcomponentsjs/ShadowDOM.js +4452 -0
- data/app/assets/javascripts/webcomponentsjs/ShadowDOM.min.js +13 -0
- data/app/assets/javascripts/webcomponentsjs/bower.json +21 -0
- data/app/assets/javascripts/webcomponentsjs/build.log +398 -0
- data/app/assets/javascripts/webcomponentsjs/package.json +28 -0
- data/app/assets/javascripts/webcomponentsjs/webcomponents-lite.js +169 -151
- data/app/assets/javascripts/webcomponentsjs/webcomponents-lite.min.js +12 -0
- data/app/assets/javascripts/webcomponentsjs/webcomponents.js +108 -70
- data/app/assets/javascripts/webcomponentsjs/webcomponents.min.js +14 -0
- data/lib/polymer-rails/version.rb +1 -1
- metadata +22 -5
@@ -1,1527 +1,1859 @@
|
|
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
|
-
--><link rel="import" href="polymer-micro.html">
|
10
|
-
|
11
|
-
<script>Polymer.Base._addFeature({
|
12
|
-
_prepTemplate: function () {
|
13
|
-
this._template = this._template || Polymer.DomModule.import(this.is, 'template');
|
14
|
-
if (this._template && this._template.hasAttribute('is')) {
|
15
|
-
this._warn(this._logf('_prepTemplate', 'top-level Polymer template ' + 'must not be a type-extension, found', this._template, 'Move inside simple <template>.'));
|
16
|
-
}
|
17
|
-
if (this._template && !this._template.content && HTMLTemplateElement.bootstrap) {
|
18
|
-
HTMLTemplateElement.decorate(this._template);
|
19
|
-
HTMLTemplateElement.bootstrap(this._template.content);
|
20
|
-
}
|
21
|
-
},
|
22
|
-
_stampTemplate: function () {
|
23
|
-
if (this._template) {
|
24
|
-
this.root = this.instanceTemplate(this._template);
|
25
|
-
}
|
26
|
-
},
|
27
|
-
instanceTemplate: function (template) {
|
28
|
-
var dom = document.importNode(template._content || template.content, true);
|
29
|
-
return dom;
|
30
|
-
}
|
31
|
-
});
|
32
|
-
(function () {
|
33
|
-
var baseAttachedCallback = Polymer.Base.attachedCallback;
|
34
|
-
Polymer.Base._addFeature({
|
35
|
-
_hostStack: [],
|
36
|
-
ready: function () {
|
37
|
-
},
|
38
|
-
_pushHost: function (host) {
|
39
|
-
this.dataHost = host = host || Polymer.Base._hostStack[Polymer.Base._hostStack.length - 1];
|
40
|
-
if (host && host._clients) {
|
41
|
-
host._clients.push(this);
|
42
|
-
}
|
43
|
-
this._beginHost();
|
44
|
-
},
|
45
|
-
_beginHost: function () {
|
46
|
-
Polymer.Base._hostStack.push(this);
|
47
|
-
if (!this._clients) {
|
48
|
-
this._clients = [];
|
49
|
-
}
|
50
|
-
},
|
51
|
-
_popHost: function () {
|
52
|
-
Polymer.Base._hostStack.pop();
|
53
|
-
},
|
54
|
-
_tryReady: function () {
|
55
|
-
if (this._canReady()) {
|
56
|
-
this._ready();
|
57
|
-
}
|
58
|
-
},
|
59
|
-
_canReady: function () {
|
60
|
-
return !this.dataHost || this.dataHost._clientsReadied;
|
61
|
-
},
|
62
|
-
_ready: function () {
|
63
|
-
this._beforeClientsReady();
|
64
|
-
this._setupRoot();
|
65
|
-
this._readyClients();
|
66
|
-
this._afterClientsReady();
|
67
|
-
this._readySelf();
|
68
|
-
},
|
69
|
-
_readyClients: function () {
|
70
|
-
this._beginDistribute();
|
71
|
-
var c$ = this._clients;
|
72
|
-
for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
|
73
|
-
c._ready();
|
74
|
-
}
|
75
|
-
this._finishDistribute();
|
76
|
-
this._clientsReadied = true;
|
77
|
-
this._clients = null;
|
78
|
-
},
|
79
|
-
_readySelf: function () {
|
80
|
-
this._doBehavior('ready');
|
81
|
-
this._readied = true;
|
82
|
-
if (this._attachedPending) {
|
83
|
-
this._attachedPending = false;
|
84
|
-
this.attachedCallback();
|
85
|
-
}
|
86
|
-
},
|
87
|
-
_beforeClientsReady: function () {
|
88
|
-
},
|
89
|
-
_afterClientsReady: function () {
|
90
|
-
},
|
91
|
-
_beforeAttached: function () {
|
92
|
-
},
|
93
|
-
attachedCallback: function () {
|
94
|
-
if (this._readied) {
|
95
|
-
this._beforeAttached();
|
96
|
-
baseAttachedCallback.call(this);
|
97
|
-
} else {
|
98
|
-
this._attachedPending = true;
|
99
|
-
}
|
100
|
-
}
|
101
|
-
});
|
102
|
-
}());
|
103
|
-
Polymer.ArraySplice = function () {
|
104
|
-
function newSplice(index, removed, addedCount) {
|
105
|
-
return {
|
106
|
-
index: index,
|
107
|
-
removed: removed,
|
108
|
-
addedCount: addedCount
|
109
|
-
};
|
110
|
-
}
|
111
|
-
var EDIT_LEAVE = 0;
|
112
|
-
var EDIT_UPDATE = 1;
|
113
|
-
var EDIT_ADD = 2;
|
114
|
-
var EDIT_DELETE = 3;
|
115
|
-
function ArraySplice() {
|
116
|
-
}
|
117
|
-
ArraySplice.prototype = {
|
118
|
-
calcEditDistances: function (current, currentStart, currentEnd, old, oldStart, oldEnd) {
|
119
|
-
var rowCount = oldEnd - oldStart + 1;
|
120
|
-
var columnCount = currentEnd - currentStart + 1;
|
121
|
-
var distances = new Array(rowCount);
|
122
|
-
for (var i = 0; i < rowCount; i++) {
|
123
|
-
distances[i] = new Array(columnCount);
|
124
|
-
distances[i][0] = i;
|
125
|
-
}
|
126
|
-
for (var j = 0; j < columnCount; j++)
|
127
|
-
distances[0][j] = j;
|
128
|
-
for (var i = 1; i < rowCount; i++) {
|
129
|
-
for (var j = 1; j < columnCount; j++) {
|
130
|
-
if (this.equals(current[currentStart + j - 1], old[oldStart + i - 1]))
|
131
|
-
distances[i][j] = distances[i - 1][j - 1];
|
132
|
-
else {
|
133
|
-
var north = distances[i - 1][j] + 1;
|
134
|
-
var west = distances[i][j - 1] + 1;
|
135
|
-
distances[i][j] = north < west ? north : west;
|
136
|
-
}
|
137
|
-
}
|
138
|
-
}
|
139
|
-
return distances;
|
140
|
-
},
|
141
|
-
spliceOperationsFromEditDistances: function (distances) {
|
142
|
-
var i = distances.length - 1;
|
143
|
-
var j = distances[0].length - 1;
|
144
|
-
var current = distances[i][j];
|
145
|
-
var edits = [];
|
146
|
-
while (i > 0 || j > 0) {
|
147
|
-
if (i == 0) {
|
148
|
-
edits.push(EDIT_ADD);
|
149
|
-
j--;
|
150
|
-
continue;
|
151
|
-
}
|
152
|
-
if (j == 0) {
|
153
|
-
edits.push(EDIT_DELETE);
|
154
|
-
i--;
|
155
|
-
continue;
|
156
|
-
}
|
157
|
-
var northWest = distances[i - 1][j - 1];
|
158
|
-
var west = distances[i - 1][j];
|
159
|
-
var north = distances[i][j - 1];
|
160
|
-
var min;
|
161
|
-
if (west < north)
|
162
|
-
min = west < northWest ? west : northWest;
|
163
|
-
else
|
164
|
-
min = north < northWest ? north : northWest;
|
165
|
-
if (min == northWest) {
|
166
|
-
if (northWest == current) {
|
167
|
-
edits.push(EDIT_LEAVE);
|
168
|
-
} else {
|
169
|
-
edits.push(EDIT_UPDATE);
|
170
|
-
current = northWest;
|
171
|
-
}
|
172
|
-
i--;
|
173
|
-
j--;
|
174
|
-
} else if (min == west) {
|
175
|
-
edits.push(EDIT_DELETE);
|
176
|
-
i--;
|
177
|
-
current = west;
|
178
|
-
} else {
|
179
|
-
edits.push(EDIT_ADD);
|
180
|
-
j--;
|
181
|
-
current = north;
|
182
|
-
}
|
183
|
-
}
|
184
|
-
edits.reverse();
|
185
|
-
return edits;
|
186
|
-
},
|
187
|
-
calcSplices: function (current, currentStart, currentEnd, old, oldStart, oldEnd) {
|
188
|
-
var prefixCount = 0;
|
189
|
-
var suffixCount = 0;
|
190
|
-
var minLength = Math.min(currentEnd - currentStart, oldEnd - oldStart);
|
191
|
-
if (currentStart == 0 && oldStart == 0)
|
192
|
-
prefixCount = this.sharedPrefix(current, old, minLength);
|
193
|
-
if (currentEnd == current.length && oldEnd == old.length)
|
194
|
-
suffixCount = this.sharedSuffix(current, old, minLength - prefixCount);
|
195
|
-
currentStart += prefixCount;
|
196
|
-
oldStart += prefixCount;
|
197
|
-
currentEnd -= suffixCount;
|
198
|
-
oldEnd -= suffixCount;
|
199
|
-
if (currentEnd - currentStart == 0 && oldEnd - oldStart == 0)
|
200
|
-
return [];
|
201
|
-
if (currentStart == currentEnd) {
|
202
|
-
var splice = newSplice(currentStart, [], 0);
|
203
|
-
while (oldStart < oldEnd)
|
204
|
-
splice.removed.push(old[oldStart++]);
|
205
|
-
return [splice];
|
206
|
-
} else if (oldStart == oldEnd)
|
207
|
-
return [newSplice(currentStart, [], currentEnd - currentStart)];
|
208
|
-
var ops = this.spliceOperationsFromEditDistances(this.calcEditDistances(current, currentStart, currentEnd, old, oldStart, oldEnd));
|
209
|
-
var splice = undefined;
|
210
|
-
var splices = [];
|
211
|
-
var index = currentStart;
|
212
|
-
var oldIndex = oldStart;
|
213
|
-
for (var i = 0; i < ops.length; i++) {
|
214
|
-
switch (ops[i]) {
|
215
|
-
case EDIT_LEAVE:
|
216
|
-
if (splice) {
|
217
|
-
splices.push(splice);
|
218
|
-
splice = undefined;
|
219
|
-
}
|
220
|
-
index++;
|
221
|
-
oldIndex++;
|
222
|
-
break;
|
223
|
-
case EDIT_UPDATE:
|
224
|
-
if (!splice)
|
225
|
-
splice = newSplice(index, [], 0);
|
226
|
-
splice.addedCount++;
|
227
|
-
index++;
|
228
|
-
splice.removed.push(old[oldIndex]);
|
229
|
-
oldIndex++;
|
230
|
-
break;
|
231
|
-
case EDIT_ADD:
|
232
|
-
if (!splice)
|
233
|
-
splice = newSplice(index, [], 0);
|
234
|
-
splice.addedCount++;
|
235
|
-
index++;
|
236
|
-
break;
|
237
|
-
case EDIT_DELETE:
|
238
|
-
if (!splice)
|
239
|
-
splice = newSplice(index, [], 0);
|
240
|
-
splice.removed.push(old[oldIndex]);
|
241
|
-
oldIndex++;
|
242
|
-
break;
|
243
|
-
}
|
244
|
-
}
|
245
|
-
if (splice) {
|
246
|
-
splices.push(splice);
|
247
|
-
}
|
248
|
-
return splices;
|
249
|
-
},
|
250
|
-
sharedPrefix: function (current, old, searchLength) {
|
251
|
-
for (var i = 0; i < searchLength; i++)
|
252
|
-
if (!this.equals(current[i], old[i]))
|
253
|
-
return i;
|
254
|
-
return searchLength;
|
255
|
-
},
|
256
|
-
sharedSuffix: function (current, old, searchLength) {
|
257
|
-
var index1 = current.length;
|
258
|
-
var index2 = old.length;
|
259
|
-
var count = 0;
|
260
|
-
while (count < searchLength && this.equals(current[--index1], old[--index2]))
|
261
|
-
count++;
|
262
|
-
return count;
|
263
|
-
},
|
264
|
-
calculateSplices: function (current, previous) {
|
265
|
-
return this.calcSplices(current, 0, current.length, previous, 0, previous.length);
|
266
|
-
},
|
267
|
-
equals: function (currentValue, previousValue) {
|
268
|
-
return currentValue === previousValue;
|
269
|
-
}
|
270
|
-
};
|
271
|
-
return new ArraySplice();
|
272
|
-
}();
|
273
|
-
Polymer.
|
274
|
-
var
|
275
|
-
var
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
return
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
return
|
288
|
-
}
|
289
|
-
}
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
var
|
298
|
-
var
|
299
|
-
|
300
|
-
|
301
|
-
return
|
302
|
-
}
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
function
|
332
|
-
switch (
|
333
|
-
case
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
return
|
343
|
-
}
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
}
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
'
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
'
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
var
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
return
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
if (
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
}
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
var
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
}
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
this.
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
}
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
insertBefore
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
}
|
472
|
-
|
473
|
-
if (
|
474
|
-
|
475
|
-
|
476
|
-
if (
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
}
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
}
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
}
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
if (node.
|
530
|
-
var
|
531
|
-
if (
|
532
|
-
|
533
|
-
}
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
},
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
var
|
553
|
-
|
554
|
-
|
555
|
-
}
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
}
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
}
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
var
|
584
|
-
if (
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
}
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
return
|
603
|
-
}
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
root
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
}
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
var
|
630
|
-
if (
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
}
|
642
|
-
}
|
643
|
-
|
644
|
-
},
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
}
|
652
|
-
}
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
}
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
}
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
if (
|
677
|
-
|
678
|
-
}
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
}
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
},
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
}
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
},
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
var
|
735
|
-
var
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
}
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
}
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
this.
|
761
|
-
}
|
762
|
-
|
763
|
-
|
764
|
-
this.
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
}
|
781
|
-
|
782
|
-
},
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
}
|
797
|
-
|
798
|
-
get: function () {
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
}
|
810
|
-
|
811
|
-
|
812
|
-
this.
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
},
|
819
|
-
|
820
|
-
|
821
|
-
this.
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
}
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
},
|
834
|
-
|
835
|
-
|
836
|
-
children
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
}
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
},
|
848
|
-
configurable: true
|
849
|
-
},
|
850
|
-
|
851
|
-
get: function () {
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
}
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
var
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
}
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
}
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
},
|
885
|
-
configurable: true
|
886
|
-
},
|
887
|
-
|
888
|
-
get: function () {
|
889
|
-
var
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
}
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
return
|
925
|
-
}
|
926
|
-
}
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
if (
|
934
|
-
|
935
|
-
}
|
936
|
-
|
937
|
-
}
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
var
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
}
|
963
|
-
});
|
964
|
-
DomApi.prototype
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
};
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
}
|
1028
|
-
|
1029
|
-
|
1030
|
-
return
|
1031
|
-
}
|
1032
|
-
|
1033
|
-
|
1034
|
-
}
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
}
|
1057
|
-
}
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
node.
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
if (
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
}
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
}
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
}
|
1101
|
-
}
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
}
|
1130
|
-
|
1131
|
-
|
1132
|
-
}
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
}
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
}
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
return
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
}
|
1175
|
-
|
1176
|
-
|
1177
|
-
Polymer.
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
}
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
this.
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
}
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
this.
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
}
|
1206
|
-
|
1207
|
-
}
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
if (this.
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
}
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
this.
|
1227
|
-
|
1228
|
-
},
|
1229
|
-
|
1230
|
-
|
1231
|
-
this.
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
}
|
1240
|
-
|
1241
|
-
}
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
this.
|
1250
|
-
this.
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
this.
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
var
|
1268
|
-
if (
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
}
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
},
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
}
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
if (
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
var
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
}
|
1347
|
-
}
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
for (var i = 0, s
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
}
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
}
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
var
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
}
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
}
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
if (
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
host.
|
1427
|
-
|
1428
|
-
}
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
}
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
}
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
}
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1457
|
-
}
|
1458
|
-
}
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
}
|
1472
|
-
}
|
1473
|
-
}
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
1485
|
-
|
1486
|
-
}
|
1487
|
-
|
1488
|
-
}
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
},
|
1495
|
-
|
1496
|
-
this.
|
1497
|
-
|
1498
|
-
|
1499
|
-
}
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
1509
|
-
this.
|
1510
|
-
this.
|
1511
|
-
|
1512
|
-
|
1513
|
-
this.
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
this.
|
1521
|
-
|
1522
|
-
|
1523
|
-
this.
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
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
|
+
--><link rel="import" href="polymer-micro.html">
|
10
|
+
|
11
|
+
<script>Polymer.Base._addFeature({
|
12
|
+
_prepTemplate: function () {
|
13
|
+
this._template = this._template || Polymer.DomModule.import(this.is, 'template');
|
14
|
+
if (this._template && this._template.hasAttribute('is')) {
|
15
|
+
this._warn(this._logf('_prepTemplate', 'top-level Polymer template ' + 'must not be a type-extension, found', this._template, 'Move inside simple <template>.'));
|
16
|
+
}
|
17
|
+
if (this._template && !this._template.content && HTMLTemplateElement.bootstrap) {
|
18
|
+
HTMLTemplateElement.decorate(this._template);
|
19
|
+
HTMLTemplateElement.bootstrap(this._template.content);
|
20
|
+
}
|
21
|
+
},
|
22
|
+
_stampTemplate: function () {
|
23
|
+
if (this._template) {
|
24
|
+
this.root = this.instanceTemplate(this._template);
|
25
|
+
}
|
26
|
+
},
|
27
|
+
instanceTemplate: function (template) {
|
28
|
+
var dom = document.importNode(template._content || template.content, true);
|
29
|
+
return dom;
|
30
|
+
}
|
31
|
+
});
|
32
|
+
(function () {
|
33
|
+
var baseAttachedCallback = Polymer.Base.attachedCallback;
|
34
|
+
Polymer.Base._addFeature({
|
35
|
+
_hostStack: [],
|
36
|
+
ready: function () {
|
37
|
+
},
|
38
|
+
_pushHost: function (host) {
|
39
|
+
this.dataHost = host = host || Polymer.Base._hostStack[Polymer.Base._hostStack.length - 1];
|
40
|
+
if (host && host._clients) {
|
41
|
+
host._clients.push(this);
|
42
|
+
}
|
43
|
+
this._beginHost();
|
44
|
+
},
|
45
|
+
_beginHost: function () {
|
46
|
+
Polymer.Base._hostStack.push(this);
|
47
|
+
if (!this._clients) {
|
48
|
+
this._clients = [];
|
49
|
+
}
|
50
|
+
},
|
51
|
+
_popHost: function () {
|
52
|
+
Polymer.Base._hostStack.pop();
|
53
|
+
},
|
54
|
+
_tryReady: function () {
|
55
|
+
if (this._canReady()) {
|
56
|
+
this._ready();
|
57
|
+
}
|
58
|
+
},
|
59
|
+
_canReady: function () {
|
60
|
+
return !this.dataHost || this.dataHost._clientsReadied;
|
61
|
+
},
|
62
|
+
_ready: function () {
|
63
|
+
this._beforeClientsReady();
|
64
|
+
this._setupRoot();
|
65
|
+
this._readyClients();
|
66
|
+
this._afterClientsReady();
|
67
|
+
this._readySelf();
|
68
|
+
},
|
69
|
+
_readyClients: function () {
|
70
|
+
this._beginDistribute();
|
71
|
+
var c$ = this._clients;
|
72
|
+
for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
|
73
|
+
c._ready();
|
74
|
+
}
|
75
|
+
this._finishDistribute();
|
76
|
+
this._clientsReadied = true;
|
77
|
+
this._clients = null;
|
78
|
+
},
|
79
|
+
_readySelf: function () {
|
80
|
+
this._doBehavior('ready');
|
81
|
+
this._readied = true;
|
82
|
+
if (this._attachedPending) {
|
83
|
+
this._attachedPending = false;
|
84
|
+
this.attachedCallback();
|
85
|
+
}
|
86
|
+
},
|
87
|
+
_beforeClientsReady: function () {
|
88
|
+
},
|
89
|
+
_afterClientsReady: function () {
|
90
|
+
},
|
91
|
+
_beforeAttached: function () {
|
92
|
+
},
|
93
|
+
attachedCallback: function () {
|
94
|
+
if (this._readied) {
|
95
|
+
this._beforeAttached();
|
96
|
+
baseAttachedCallback.call(this);
|
97
|
+
} else {
|
98
|
+
this._attachedPending = true;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
});
|
102
|
+
}());
|
103
|
+
Polymer.ArraySplice = function () {
|
104
|
+
function newSplice(index, removed, addedCount) {
|
105
|
+
return {
|
106
|
+
index: index,
|
107
|
+
removed: removed,
|
108
|
+
addedCount: addedCount
|
109
|
+
};
|
110
|
+
}
|
111
|
+
var EDIT_LEAVE = 0;
|
112
|
+
var EDIT_UPDATE = 1;
|
113
|
+
var EDIT_ADD = 2;
|
114
|
+
var EDIT_DELETE = 3;
|
115
|
+
function ArraySplice() {
|
116
|
+
}
|
117
|
+
ArraySplice.prototype = {
|
118
|
+
calcEditDistances: function (current, currentStart, currentEnd, old, oldStart, oldEnd) {
|
119
|
+
var rowCount = oldEnd - oldStart + 1;
|
120
|
+
var columnCount = currentEnd - currentStart + 1;
|
121
|
+
var distances = new Array(rowCount);
|
122
|
+
for (var i = 0; i < rowCount; i++) {
|
123
|
+
distances[i] = new Array(columnCount);
|
124
|
+
distances[i][0] = i;
|
125
|
+
}
|
126
|
+
for (var j = 0; j < columnCount; j++)
|
127
|
+
distances[0][j] = j;
|
128
|
+
for (var i = 1; i < rowCount; i++) {
|
129
|
+
for (var j = 1; j < columnCount; j++) {
|
130
|
+
if (this.equals(current[currentStart + j - 1], old[oldStart + i - 1]))
|
131
|
+
distances[i][j] = distances[i - 1][j - 1];
|
132
|
+
else {
|
133
|
+
var north = distances[i - 1][j] + 1;
|
134
|
+
var west = distances[i][j - 1] + 1;
|
135
|
+
distances[i][j] = north < west ? north : west;
|
136
|
+
}
|
137
|
+
}
|
138
|
+
}
|
139
|
+
return distances;
|
140
|
+
},
|
141
|
+
spliceOperationsFromEditDistances: function (distances) {
|
142
|
+
var i = distances.length - 1;
|
143
|
+
var j = distances[0].length - 1;
|
144
|
+
var current = distances[i][j];
|
145
|
+
var edits = [];
|
146
|
+
while (i > 0 || j > 0) {
|
147
|
+
if (i == 0) {
|
148
|
+
edits.push(EDIT_ADD);
|
149
|
+
j--;
|
150
|
+
continue;
|
151
|
+
}
|
152
|
+
if (j == 0) {
|
153
|
+
edits.push(EDIT_DELETE);
|
154
|
+
i--;
|
155
|
+
continue;
|
156
|
+
}
|
157
|
+
var northWest = distances[i - 1][j - 1];
|
158
|
+
var west = distances[i - 1][j];
|
159
|
+
var north = distances[i][j - 1];
|
160
|
+
var min;
|
161
|
+
if (west < north)
|
162
|
+
min = west < northWest ? west : northWest;
|
163
|
+
else
|
164
|
+
min = north < northWest ? north : northWest;
|
165
|
+
if (min == northWest) {
|
166
|
+
if (northWest == current) {
|
167
|
+
edits.push(EDIT_LEAVE);
|
168
|
+
} else {
|
169
|
+
edits.push(EDIT_UPDATE);
|
170
|
+
current = northWest;
|
171
|
+
}
|
172
|
+
i--;
|
173
|
+
j--;
|
174
|
+
} else if (min == west) {
|
175
|
+
edits.push(EDIT_DELETE);
|
176
|
+
i--;
|
177
|
+
current = west;
|
178
|
+
} else {
|
179
|
+
edits.push(EDIT_ADD);
|
180
|
+
j--;
|
181
|
+
current = north;
|
182
|
+
}
|
183
|
+
}
|
184
|
+
edits.reverse();
|
185
|
+
return edits;
|
186
|
+
},
|
187
|
+
calcSplices: function (current, currentStart, currentEnd, old, oldStart, oldEnd) {
|
188
|
+
var prefixCount = 0;
|
189
|
+
var suffixCount = 0;
|
190
|
+
var minLength = Math.min(currentEnd - currentStart, oldEnd - oldStart);
|
191
|
+
if (currentStart == 0 && oldStart == 0)
|
192
|
+
prefixCount = this.sharedPrefix(current, old, minLength);
|
193
|
+
if (currentEnd == current.length && oldEnd == old.length)
|
194
|
+
suffixCount = this.sharedSuffix(current, old, minLength - prefixCount);
|
195
|
+
currentStart += prefixCount;
|
196
|
+
oldStart += prefixCount;
|
197
|
+
currentEnd -= suffixCount;
|
198
|
+
oldEnd -= suffixCount;
|
199
|
+
if (currentEnd - currentStart == 0 && oldEnd - oldStart == 0)
|
200
|
+
return [];
|
201
|
+
if (currentStart == currentEnd) {
|
202
|
+
var splice = newSplice(currentStart, [], 0);
|
203
|
+
while (oldStart < oldEnd)
|
204
|
+
splice.removed.push(old[oldStart++]);
|
205
|
+
return [splice];
|
206
|
+
} else if (oldStart == oldEnd)
|
207
|
+
return [newSplice(currentStart, [], currentEnd - currentStart)];
|
208
|
+
var ops = this.spliceOperationsFromEditDistances(this.calcEditDistances(current, currentStart, currentEnd, old, oldStart, oldEnd));
|
209
|
+
var splice = undefined;
|
210
|
+
var splices = [];
|
211
|
+
var index = currentStart;
|
212
|
+
var oldIndex = oldStart;
|
213
|
+
for (var i = 0; i < ops.length; i++) {
|
214
|
+
switch (ops[i]) {
|
215
|
+
case EDIT_LEAVE:
|
216
|
+
if (splice) {
|
217
|
+
splices.push(splice);
|
218
|
+
splice = undefined;
|
219
|
+
}
|
220
|
+
index++;
|
221
|
+
oldIndex++;
|
222
|
+
break;
|
223
|
+
case EDIT_UPDATE:
|
224
|
+
if (!splice)
|
225
|
+
splice = newSplice(index, [], 0);
|
226
|
+
splice.addedCount++;
|
227
|
+
index++;
|
228
|
+
splice.removed.push(old[oldIndex]);
|
229
|
+
oldIndex++;
|
230
|
+
break;
|
231
|
+
case EDIT_ADD:
|
232
|
+
if (!splice)
|
233
|
+
splice = newSplice(index, [], 0);
|
234
|
+
splice.addedCount++;
|
235
|
+
index++;
|
236
|
+
break;
|
237
|
+
case EDIT_DELETE:
|
238
|
+
if (!splice)
|
239
|
+
splice = newSplice(index, [], 0);
|
240
|
+
splice.removed.push(old[oldIndex]);
|
241
|
+
oldIndex++;
|
242
|
+
break;
|
243
|
+
}
|
244
|
+
}
|
245
|
+
if (splice) {
|
246
|
+
splices.push(splice);
|
247
|
+
}
|
248
|
+
return splices;
|
249
|
+
},
|
250
|
+
sharedPrefix: function (current, old, searchLength) {
|
251
|
+
for (var i = 0; i < searchLength; i++)
|
252
|
+
if (!this.equals(current[i], old[i]))
|
253
|
+
return i;
|
254
|
+
return searchLength;
|
255
|
+
},
|
256
|
+
sharedSuffix: function (current, old, searchLength) {
|
257
|
+
var index1 = current.length;
|
258
|
+
var index2 = old.length;
|
259
|
+
var count = 0;
|
260
|
+
while (count < searchLength && this.equals(current[--index1], old[--index2]))
|
261
|
+
count++;
|
262
|
+
return count;
|
263
|
+
},
|
264
|
+
calculateSplices: function (current, previous) {
|
265
|
+
return this.calcSplices(current, 0, current.length, previous, 0, previous.length);
|
266
|
+
},
|
267
|
+
equals: function (currentValue, previousValue) {
|
268
|
+
return currentValue === previousValue;
|
269
|
+
}
|
270
|
+
};
|
271
|
+
return new ArraySplice();
|
272
|
+
}();
|
273
|
+
Polymer.domInnerHTML = function () {
|
274
|
+
var escapeAttrRegExp = /[&\u00A0"]/g;
|
275
|
+
var escapeDataRegExp = /[&\u00A0<>]/g;
|
276
|
+
function escapeReplace(c) {
|
277
|
+
switch (c) {
|
278
|
+
case '&':
|
279
|
+
return '&';
|
280
|
+
case '<':
|
281
|
+
return '<';
|
282
|
+
case '>':
|
283
|
+
return '>';
|
284
|
+
case '"':
|
285
|
+
return '"';
|
286
|
+
case '\xA0':
|
287
|
+
return ' ';
|
288
|
+
}
|
289
|
+
}
|
290
|
+
function escapeAttr(s) {
|
291
|
+
return s.replace(escapeAttrRegExp, escapeReplace);
|
292
|
+
}
|
293
|
+
function escapeData(s) {
|
294
|
+
return s.replace(escapeDataRegExp, escapeReplace);
|
295
|
+
}
|
296
|
+
function makeSet(arr) {
|
297
|
+
var set = {};
|
298
|
+
for (var i = 0; i < arr.length; i++) {
|
299
|
+
set[arr[i]] = true;
|
300
|
+
}
|
301
|
+
return set;
|
302
|
+
}
|
303
|
+
var voidElements = makeSet([
|
304
|
+
'area',
|
305
|
+
'base',
|
306
|
+
'br',
|
307
|
+
'col',
|
308
|
+
'command',
|
309
|
+
'embed',
|
310
|
+
'hr',
|
311
|
+
'img',
|
312
|
+
'input',
|
313
|
+
'keygen',
|
314
|
+
'link',
|
315
|
+
'meta',
|
316
|
+
'param',
|
317
|
+
'source',
|
318
|
+
'track',
|
319
|
+
'wbr'
|
320
|
+
]);
|
321
|
+
var plaintextParents = makeSet([
|
322
|
+
'style',
|
323
|
+
'script',
|
324
|
+
'xmp',
|
325
|
+
'iframe',
|
326
|
+
'noembed',
|
327
|
+
'noframes',
|
328
|
+
'plaintext',
|
329
|
+
'noscript'
|
330
|
+
]);
|
331
|
+
function getOuterHTML(node, parentNode, composed) {
|
332
|
+
switch (node.nodeType) {
|
333
|
+
case Node.ELEMENT_NODE:
|
334
|
+
var tagName = node.localName;
|
335
|
+
var s = '<' + tagName;
|
336
|
+
var attrs = node.attributes;
|
337
|
+
for (var i = 0, attr; attr = attrs[i]; i++) {
|
338
|
+
s += ' ' + attr.name + '="' + escapeAttr(attr.value) + '"';
|
339
|
+
}
|
340
|
+
s += '>';
|
341
|
+
if (voidElements[tagName]) {
|
342
|
+
return s;
|
343
|
+
}
|
344
|
+
return s + getInnerHTML(node, composed) + '</' + tagName + '>';
|
345
|
+
case Node.TEXT_NODE:
|
346
|
+
var data = node.data;
|
347
|
+
if (parentNode && plaintextParents[parentNode.localName]) {
|
348
|
+
return data;
|
349
|
+
}
|
350
|
+
return escapeData(data);
|
351
|
+
case Node.COMMENT_NODE:
|
352
|
+
return '<!--' + node.data + '-->';
|
353
|
+
default:
|
354
|
+
console.error(node);
|
355
|
+
throw new Error('not implemented');
|
356
|
+
}
|
357
|
+
}
|
358
|
+
function getInnerHTML(node, composed) {
|
359
|
+
if (node instanceof HTMLTemplateElement)
|
360
|
+
node = node.content;
|
361
|
+
var s = '';
|
362
|
+
var c$ = Polymer.dom(node).childNodes;
|
363
|
+
c$ = composed ? node._composedChildren : c$;
|
364
|
+
for (var i = 0, l = c$.length, child; i < l && (child = c$[i]); i++) {
|
365
|
+
s += getOuterHTML(child, node, composed);
|
366
|
+
}
|
367
|
+
return s;
|
368
|
+
}
|
369
|
+
return { getInnerHTML: getInnerHTML };
|
370
|
+
}();
|
371
|
+
Polymer.DomApi = function () {
|
372
|
+
'use strict';
|
373
|
+
var Settings = Polymer.Settings;
|
374
|
+
var getInnerHTML = Polymer.domInnerHTML.getInnerHTML;
|
375
|
+
var nativeInsertBefore = Element.prototype.insertBefore;
|
376
|
+
var nativeRemoveChild = Element.prototype.removeChild;
|
377
|
+
var nativeAppendChild = Element.prototype.appendChild;
|
378
|
+
var nativeCloneNode = Element.prototype.cloneNode;
|
379
|
+
var nativeImportNode = Document.prototype.importNode;
|
380
|
+
var DomApi = function (node) {
|
381
|
+
this.node = node;
|
382
|
+
if (this.patch) {
|
383
|
+
this.patch();
|
384
|
+
}
|
385
|
+
};
|
386
|
+
if (window.wrap && Settings.useShadow && !Settings.useNativeShadow) {
|
387
|
+
DomApi = function (node) {
|
388
|
+
this.node = wrap(node);
|
389
|
+
if (this.patch) {
|
390
|
+
this.patch();
|
391
|
+
}
|
392
|
+
};
|
393
|
+
}
|
394
|
+
DomApi.prototype = {
|
395
|
+
flush: function () {
|
396
|
+
Polymer.dom.flush();
|
397
|
+
},
|
398
|
+
_lazyDistribute: function (host) {
|
399
|
+
if (host.shadyRoot && host.shadyRoot._distributionClean) {
|
400
|
+
host.shadyRoot._distributionClean = false;
|
401
|
+
Polymer.dom.addDebouncer(host.debounce('_distribute', host._distributeContent));
|
402
|
+
}
|
403
|
+
},
|
404
|
+
appendChild: function (node) {
|
405
|
+
return this._addNode(node);
|
406
|
+
},
|
407
|
+
insertBefore: function (node, ref_node) {
|
408
|
+
return this._addNode(node, ref_node);
|
409
|
+
},
|
410
|
+
_addNode: function (node, ref_node) {
|
411
|
+
this._removeNodeFromParent(node);
|
412
|
+
var addedInsertionPoint;
|
413
|
+
var root = this.getOwnerRoot();
|
414
|
+
if (root) {
|
415
|
+
addedInsertionPoint = this._maybeAddInsertionPoint(node, this.node);
|
416
|
+
}
|
417
|
+
if (this._nodeHasLogicalChildren(this.node)) {
|
418
|
+
if (ref_node) {
|
419
|
+
var children = this.childNodes;
|
420
|
+
var index = children.indexOf(ref_node);
|
421
|
+
if (index < 0) {
|
422
|
+
throw Error('The ref_node to be inserted before is not a child ' + 'of this node');
|
423
|
+
}
|
424
|
+
}
|
425
|
+
this._addLogicalInfo(node, this.node, index);
|
426
|
+
}
|
427
|
+
this._addNodeToHost(node);
|
428
|
+
if (!this._maybeDistribute(node, this.node) && !this._tryRemoveUndistributedNode(node)) {
|
429
|
+
if (ref_node) {
|
430
|
+
ref_node = ref_node.localName === CONTENT ? this._firstComposedNode(ref_node) : ref_node;
|
431
|
+
}
|
432
|
+
var container = this.node._isShadyRoot ? this.node.host : this.node;
|
433
|
+
addToComposedParent(container, node, ref_node);
|
434
|
+
if (ref_node) {
|
435
|
+
nativeInsertBefore.call(container, node, ref_node);
|
436
|
+
} else {
|
437
|
+
nativeAppendChild.call(container, node);
|
438
|
+
}
|
439
|
+
}
|
440
|
+
if (addedInsertionPoint) {
|
441
|
+
this._updateInsertionPoints(root.host);
|
442
|
+
}
|
443
|
+
this.notifyObserver();
|
444
|
+
return node;
|
445
|
+
},
|
446
|
+
removeChild: function (node) {
|
447
|
+
if (factory(node).parentNode !== this.node) {
|
448
|
+
console.warn('The node to be removed is not a child of this node', node);
|
449
|
+
}
|
450
|
+
this._removeNodeFromHost(node);
|
451
|
+
if (!this._maybeDistribute(node, this.node)) {
|
452
|
+
var container = this.node._isShadyRoot ? this.node.host : this.node;
|
453
|
+
if (container === node.parentNode) {
|
454
|
+
removeFromComposedParent(container, node);
|
455
|
+
nativeRemoveChild.call(container, node);
|
456
|
+
}
|
457
|
+
}
|
458
|
+
this.notifyObserver();
|
459
|
+
return node;
|
460
|
+
},
|
461
|
+
replaceChild: function (node, ref_node) {
|
462
|
+
this.insertBefore(node, ref_node);
|
463
|
+
this.removeChild(ref_node);
|
464
|
+
return node;
|
465
|
+
},
|
466
|
+
_hasCachedOwnerRoot: function (node) {
|
467
|
+
return Boolean(node._ownerShadyRoot !== undefined);
|
468
|
+
},
|
469
|
+
getOwnerRoot: function () {
|
470
|
+
return this._ownerShadyRootForNode(this.node);
|
471
|
+
},
|
472
|
+
_ownerShadyRootForNode: function (node) {
|
473
|
+
if (!node) {
|
474
|
+
return;
|
475
|
+
}
|
476
|
+
if (node._ownerShadyRoot === undefined) {
|
477
|
+
var root;
|
478
|
+
if (node._isShadyRoot) {
|
479
|
+
root = node;
|
480
|
+
} else {
|
481
|
+
var parent = Polymer.dom(node).parentNode;
|
482
|
+
if (parent) {
|
483
|
+
root = parent._isShadyRoot ? parent : this._ownerShadyRootForNode(parent);
|
484
|
+
} else {
|
485
|
+
root = null;
|
486
|
+
}
|
487
|
+
}
|
488
|
+
node._ownerShadyRoot = root;
|
489
|
+
}
|
490
|
+
return node._ownerShadyRoot;
|
491
|
+
},
|
492
|
+
_maybeDistribute: function (node, parent) {
|
493
|
+
var fragContent = node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && !node.__noContent && Polymer.dom(node).querySelector(CONTENT);
|
494
|
+
var wrappedContent = fragContent && Polymer.dom(fragContent).parentNode.nodeType !== Node.DOCUMENT_FRAGMENT_NODE;
|
495
|
+
var hasContent = fragContent || node.localName === CONTENT;
|
496
|
+
if (hasContent) {
|
497
|
+
var root = this._ownerShadyRootForNode(parent);
|
498
|
+
if (root) {
|
499
|
+
var host = root.host;
|
500
|
+
this._lazyDistribute(host);
|
501
|
+
}
|
502
|
+
}
|
503
|
+
var parentNeedsDist = this._parentNeedsDistribution(parent);
|
504
|
+
if (parentNeedsDist) {
|
505
|
+
this._lazyDistribute(parent);
|
506
|
+
}
|
507
|
+
return parentNeedsDist || hasContent && !wrappedContent;
|
508
|
+
},
|
509
|
+
_maybeAddInsertionPoint: function (node, parent) {
|
510
|
+
var added;
|
511
|
+
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && !node.__noContent) {
|
512
|
+
var c$ = factory(node).querySelectorAll(CONTENT);
|
513
|
+
for (var i = 0, n, np, na; i < c$.length && (n = c$[i]); i++) {
|
514
|
+
np = factory(n).parentNode;
|
515
|
+
if (np === node) {
|
516
|
+
np = parent;
|
517
|
+
}
|
518
|
+
na = this._maybeAddInsertionPoint(n, np);
|
519
|
+
added = added || na;
|
520
|
+
}
|
521
|
+
} else if (node.localName === CONTENT) {
|
522
|
+
saveLightChildrenIfNeeded(parent);
|
523
|
+
saveLightChildrenIfNeeded(node);
|
524
|
+
added = true;
|
525
|
+
}
|
526
|
+
return added;
|
527
|
+
},
|
528
|
+
_tryRemoveUndistributedNode: function (node) {
|
529
|
+
if (this.node.shadyRoot) {
|
530
|
+
var parent = getComposedParent(node);
|
531
|
+
if (parent) {
|
532
|
+
nativeRemoveChild.call(parent, node);
|
533
|
+
}
|
534
|
+
return true;
|
535
|
+
}
|
536
|
+
},
|
537
|
+
_updateInsertionPoints: function (host) {
|
538
|
+
var i$ = host.shadyRoot._insertionPoints = factory(host.shadyRoot).querySelectorAll(CONTENT);
|
539
|
+
for (var i = 0, c; i < i$.length; i++) {
|
540
|
+
c = i$[i];
|
541
|
+
saveLightChildrenIfNeeded(c);
|
542
|
+
saveLightChildrenIfNeeded(factory(c).parentNode);
|
543
|
+
}
|
544
|
+
},
|
545
|
+
_nodeHasLogicalChildren: function (node) {
|
546
|
+
return Boolean(node._lightChildren !== undefined);
|
547
|
+
},
|
548
|
+
_parentNeedsDistribution: function (parent) {
|
549
|
+
return parent && parent.shadyRoot && hasInsertionPoint(parent.shadyRoot);
|
550
|
+
},
|
551
|
+
_removeNodeFromParent: function (node) {
|
552
|
+
var parent = node._lightParent || node.parentNode;
|
553
|
+
if (parent && hasDomApi(parent)) {
|
554
|
+
factory(parent).notifyObserver();
|
555
|
+
}
|
556
|
+
this._removeNodeFromHost(node, true);
|
557
|
+
},
|
558
|
+
_removeNodeFromHost: function (node, ensureComposedRemoval) {
|
559
|
+
var hostNeedsDist;
|
560
|
+
var root;
|
561
|
+
var parent = node._lightParent;
|
562
|
+
if (parent) {
|
563
|
+
factory(node)._distributeParent();
|
564
|
+
root = this._ownerShadyRootForNode(node);
|
565
|
+
if (root) {
|
566
|
+
root.host._elementRemove(node);
|
567
|
+
hostNeedsDist = this._removeDistributedChildren(root, node);
|
568
|
+
}
|
569
|
+
this._removeLogicalInfo(node, parent);
|
570
|
+
}
|
571
|
+
this._removeOwnerShadyRoot(node);
|
572
|
+
if (root && hostNeedsDist) {
|
573
|
+
this._updateInsertionPoints(root.host);
|
574
|
+
this._lazyDistribute(root.host);
|
575
|
+
} else if (ensureComposedRemoval) {
|
576
|
+
removeFromComposedParent(getComposedParent(node), node);
|
577
|
+
}
|
578
|
+
},
|
579
|
+
_removeDistributedChildren: function (root, container) {
|
580
|
+
var hostNeedsDist;
|
581
|
+
var ip$ = root._insertionPoints;
|
582
|
+
for (var i = 0; i < ip$.length; i++) {
|
583
|
+
var content = ip$[i];
|
584
|
+
if (this._contains(container, content)) {
|
585
|
+
var dc$ = factory(content).getDistributedNodes();
|
586
|
+
for (var j = 0; j < dc$.length; j++) {
|
587
|
+
hostNeedsDist = true;
|
588
|
+
var node = dc$[j];
|
589
|
+
var parent = node.parentNode;
|
590
|
+
if (parent) {
|
591
|
+
removeFromComposedParent(parent, node);
|
592
|
+
nativeRemoveChild.call(parent, node);
|
593
|
+
}
|
594
|
+
}
|
595
|
+
}
|
596
|
+
}
|
597
|
+
return hostNeedsDist;
|
598
|
+
},
|
599
|
+
_contains: function (container, node) {
|
600
|
+
while (node) {
|
601
|
+
if (node == container) {
|
602
|
+
return true;
|
603
|
+
}
|
604
|
+
node = factory(node).parentNode;
|
605
|
+
}
|
606
|
+
},
|
607
|
+
_addNodeToHost: function (node) {
|
608
|
+
var root = this.getOwnerRoot();
|
609
|
+
if (root) {
|
610
|
+
root.host._elementAdd(node);
|
611
|
+
}
|
612
|
+
},
|
613
|
+
_addLogicalInfo: function (node, container, index) {
|
614
|
+
var children = factory(container).childNodes;
|
615
|
+
index = index === undefined ? children.length : index;
|
616
|
+
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
617
|
+
var c$ = Array.prototype.slice.call(node.childNodes);
|
618
|
+
for (var i = 0, n; i < c$.length && (n = c$[i]); i++) {
|
619
|
+
children.splice(index++, 0, n);
|
620
|
+
n._lightParent = container;
|
621
|
+
}
|
622
|
+
} else {
|
623
|
+
children.splice(index, 0, node);
|
624
|
+
node._lightParent = container;
|
625
|
+
}
|
626
|
+
},
|
627
|
+
_removeLogicalInfo: function (node, container) {
|
628
|
+
var children = factory(container).childNodes;
|
629
|
+
var index = children.indexOf(node);
|
630
|
+
if (index < 0 || container !== node._lightParent) {
|
631
|
+
throw Error('The node to be removed is not a child of this node');
|
632
|
+
}
|
633
|
+
children.splice(index, 1);
|
634
|
+
node._lightParent = null;
|
635
|
+
},
|
636
|
+
_removeOwnerShadyRoot: function (node) {
|
637
|
+
if (this._hasCachedOwnerRoot(node)) {
|
638
|
+
var c$ = factory(node).childNodes;
|
639
|
+
for (var i = 0, l = c$.length, n; i < l && (n = c$[i]); i++) {
|
640
|
+
this._removeOwnerShadyRoot(n);
|
641
|
+
}
|
642
|
+
}
|
643
|
+
node._ownerShadyRoot = undefined;
|
644
|
+
},
|
645
|
+
_firstComposedNode: function (content) {
|
646
|
+
var n$ = factory(content).getDistributedNodes();
|
647
|
+
for (var i = 0, l = n$.length, n, p$; i < l && (n = n$[i]); i++) {
|
648
|
+
p$ = factory(n).getDestinationInsertionPoints();
|
649
|
+
if (p$[p$.length - 1] === content) {
|
650
|
+
return n;
|
651
|
+
}
|
652
|
+
}
|
653
|
+
},
|
654
|
+
querySelector: function (selector) {
|
655
|
+
return this.querySelectorAll(selector)[0];
|
656
|
+
},
|
657
|
+
querySelectorAll: function (selector) {
|
658
|
+
return this._query(function (n) {
|
659
|
+
return matchesSelector.call(n, selector);
|
660
|
+
}, this.node);
|
661
|
+
},
|
662
|
+
_query: function (matcher, node) {
|
663
|
+
node = node || this.node;
|
664
|
+
var list = [];
|
665
|
+
this._queryElements(factory(node).childNodes, matcher, list);
|
666
|
+
return list;
|
667
|
+
},
|
668
|
+
_queryElements: function (elements, matcher, list) {
|
669
|
+
for (var i = 0, l = elements.length, c; i < l && (c = elements[i]); i++) {
|
670
|
+
if (c.nodeType === Node.ELEMENT_NODE) {
|
671
|
+
this._queryElement(c, matcher, list);
|
672
|
+
}
|
673
|
+
}
|
674
|
+
},
|
675
|
+
_queryElement: function (node, matcher, list) {
|
676
|
+
if (matcher(node)) {
|
677
|
+
list.push(node);
|
678
|
+
}
|
679
|
+
this._queryElements(factory(node).childNodes, matcher, list);
|
680
|
+
},
|
681
|
+
getDestinationInsertionPoints: function () {
|
682
|
+
return this.node._destinationInsertionPoints || [];
|
683
|
+
},
|
684
|
+
getDistributedNodes: function () {
|
685
|
+
return this.node._distributedNodes || [];
|
686
|
+
},
|
687
|
+
queryDistributedElements: function (selector) {
|
688
|
+
var c$ = this.getEffectiveChildNodes();
|
689
|
+
var list = [];
|
690
|
+
for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
|
691
|
+
if (c.nodeType === Node.ELEMENT_NODE && matchesSelector.call(c, selector)) {
|
692
|
+
list.push(c);
|
693
|
+
}
|
694
|
+
}
|
695
|
+
return list;
|
696
|
+
},
|
697
|
+
getEffectiveChildNodes: function () {
|
698
|
+
var list = [];
|
699
|
+
var c$ = this.childNodes;
|
700
|
+
for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
|
701
|
+
if (c.localName === CONTENT) {
|
702
|
+
var d$ = factory(c).getDistributedNodes();
|
703
|
+
for (var j = 0; j < d$.length; j++) {
|
704
|
+
list.push(d$[j]);
|
705
|
+
}
|
706
|
+
} else {
|
707
|
+
list.push(c);
|
708
|
+
}
|
709
|
+
}
|
710
|
+
return list;
|
711
|
+
},
|
712
|
+
_clear: function () {
|
713
|
+
while (this.childNodes.length) {
|
714
|
+
this.removeChild(this.childNodes[0]);
|
715
|
+
}
|
716
|
+
},
|
717
|
+
setAttribute: function (name, value) {
|
718
|
+
this.node.setAttribute(name, value);
|
719
|
+
this._distributeParent();
|
720
|
+
},
|
721
|
+
removeAttribute: function (name) {
|
722
|
+
this.node.removeAttribute(name);
|
723
|
+
this._distributeParent();
|
724
|
+
},
|
725
|
+
_distributeParent: function () {
|
726
|
+
if (this._parentNeedsDistribution(this.parentNode)) {
|
727
|
+
this._lazyDistribute(this.parentNode);
|
728
|
+
}
|
729
|
+
},
|
730
|
+
cloneNode: function (deep) {
|
731
|
+
var n = nativeCloneNode.call(this.node, false);
|
732
|
+
if (deep) {
|
733
|
+
var c$ = this.childNodes;
|
734
|
+
var d = factory(n);
|
735
|
+
for (var i = 0, nc; i < c$.length; i++) {
|
736
|
+
nc = factory(c$[i]).cloneNode(true);
|
737
|
+
d.appendChild(nc);
|
738
|
+
}
|
739
|
+
}
|
740
|
+
return n;
|
741
|
+
},
|
742
|
+
importNode: function (externalNode, deep) {
|
743
|
+
var doc = this.node instanceof Document ? this.node : this.node.ownerDocument;
|
744
|
+
var n = nativeImportNode.call(doc, externalNode, false);
|
745
|
+
if (deep) {
|
746
|
+
var c$ = factory(externalNode).childNodes;
|
747
|
+
var d = factory(n);
|
748
|
+
for (var i = 0, nc; i < c$.length; i++) {
|
749
|
+
nc = factory(doc).importNode(c$[i], true);
|
750
|
+
d.appendChild(nc);
|
751
|
+
}
|
752
|
+
}
|
753
|
+
return n;
|
754
|
+
},
|
755
|
+
observeNodes: function (callback) {
|
756
|
+
if (callback) {
|
757
|
+
if (!this.observer) {
|
758
|
+
this.observer = this.node.localName === CONTENT ? new DomApi.DistributedNodesObserver(this) : new DomApi.EffectiveNodesObserver(this);
|
759
|
+
}
|
760
|
+
return this.observer.addListener(callback);
|
761
|
+
}
|
762
|
+
},
|
763
|
+
unobserveNodes: function (handle) {
|
764
|
+
if (this.observer) {
|
765
|
+
this.observer.removeListener(handle);
|
766
|
+
}
|
767
|
+
},
|
768
|
+
notifyObserver: function () {
|
769
|
+
if (this.observer) {
|
770
|
+
this.observer.notify();
|
771
|
+
}
|
772
|
+
}
|
773
|
+
};
|
774
|
+
if (!Settings.useShadow) {
|
775
|
+
Object.defineProperties(DomApi.prototype, {
|
776
|
+
childNodes: {
|
777
|
+
get: function () {
|
778
|
+
var c$ = getLightChildren(this.node);
|
779
|
+
return Array.isArray(c$) ? c$ : Array.prototype.slice.call(c$);
|
780
|
+
},
|
781
|
+
configurable: true
|
782
|
+
},
|
783
|
+
children: {
|
784
|
+
get: function () {
|
785
|
+
return Array.prototype.filter.call(this.childNodes, function (n) {
|
786
|
+
return n.nodeType === Node.ELEMENT_NODE;
|
787
|
+
});
|
788
|
+
},
|
789
|
+
configurable: true
|
790
|
+
},
|
791
|
+
parentNode: {
|
792
|
+
get: function () {
|
793
|
+
return this.node._lightParent || getComposedParent(this.node);
|
794
|
+
},
|
795
|
+
configurable: true
|
796
|
+
},
|
797
|
+
firstChild: {
|
798
|
+
get: function () {
|
799
|
+
return this.childNodes[0];
|
800
|
+
},
|
801
|
+
configurable: true
|
802
|
+
},
|
803
|
+
lastChild: {
|
804
|
+
get: function () {
|
805
|
+
var c$ = this.childNodes;
|
806
|
+
return c$[c$.length - 1];
|
807
|
+
},
|
808
|
+
configurable: true
|
809
|
+
},
|
810
|
+
nextSibling: {
|
811
|
+
get: function () {
|
812
|
+
var c$ = this.parentNode && factory(this.parentNode).childNodes;
|
813
|
+
if (c$) {
|
814
|
+
return c$[Array.prototype.indexOf.call(c$, this.node) + 1];
|
815
|
+
}
|
816
|
+
},
|
817
|
+
configurable: true
|
818
|
+
},
|
819
|
+
previousSibling: {
|
820
|
+
get: function () {
|
821
|
+
var c$ = this.parentNode && factory(this.parentNode).childNodes;
|
822
|
+
if (c$) {
|
823
|
+
return c$[Array.prototype.indexOf.call(c$, this.node) - 1];
|
824
|
+
}
|
825
|
+
},
|
826
|
+
configurable: true
|
827
|
+
},
|
828
|
+
firstElementChild: {
|
829
|
+
get: function () {
|
830
|
+
return this.children[0];
|
831
|
+
},
|
832
|
+
configurable: true
|
833
|
+
},
|
834
|
+
lastElementChild: {
|
835
|
+
get: function () {
|
836
|
+
var c$ = this.children;
|
837
|
+
return c$[c$.length - 1];
|
838
|
+
},
|
839
|
+
configurable: true
|
840
|
+
},
|
841
|
+
nextElementSibling: {
|
842
|
+
get: function () {
|
843
|
+
var c$ = this.parentNode && factory(this.parentNode).children;
|
844
|
+
if (c$) {
|
845
|
+
return c$[Array.prototype.indexOf.call(c$, this.node) + 1];
|
846
|
+
}
|
847
|
+
},
|
848
|
+
configurable: true
|
849
|
+
},
|
850
|
+
previousElementSibling: {
|
851
|
+
get: function () {
|
852
|
+
var c$ = this.parentNode && factory(this.parentNode).children;
|
853
|
+
if (c$) {
|
854
|
+
return c$[Array.prototype.indexOf.call(c$, this.node) - 1];
|
855
|
+
}
|
856
|
+
},
|
857
|
+
configurable: true
|
858
|
+
},
|
859
|
+
textContent: {
|
860
|
+
get: function () {
|
861
|
+
var nt = this.node.nodeType;
|
862
|
+
if (nt === Node.TEXT_NODE || nt === Node.COMMENT_NODE) {
|
863
|
+
return this.node.textContent;
|
864
|
+
} else {
|
865
|
+
var tc = [];
|
866
|
+
for (var i = 0, cn = this.childNodes, c; c = cn[i]; i++) {
|
867
|
+
if (c.nodeType !== Node.COMMENT_NODE) {
|
868
|
+
tc.push(c.textContent);
|
869
|
+
}
|
870
|
+
}
|
871
|
+
return tc.join('');
|
872
|
+
}
|
873
|
+
},
|
874
|
+
set: function (text) {
|
875
|
+
var nt = this.node.nodeType;
|
876
|
+
if (nt === Node.TEXT_NODE || nt === Node.COMMENT_NODE) {
|
877
|
+
this.node.textContent = text;
|
878
|
+
} else {
|
879
|
+
this._clear();
|
880
|
+
if (text) {
|
881
|
+
this.appendChild(document.createTextNode(text));
|
882
|
+
}
|
883
|
+
}
|
884
|
+
},
|
885
|
+
configurable: true
|
886
|
+
},
|
887
|
+
innerHTML: {
|
888
|
+
get: function () {
|
889
|
+
var nt = this.node.nodeType;
|
890
|
+
if (nt === Node.TEXT_NODE || nt === Node.COMMENT_NODE) {
|
891
|
+
return null;
|
892
|
+
} else {
|
893
|
+
return getInnerHTML(this.node);
|
894
|
+
}
|
895
|
+
},
|
896
|
+
set: function (text) {
|
897
|
+
var nt = this.node.nodeType;
|
898
|
+
if (nt !== Node.TEXT_NODE || nt !== Node.COMMENT_NODE) {
|
899
|
+
this._clear();
|
900
|
+
var d = document.createElement('div');
|
901
|
+
d.innerHTML = text;
|
902
|
+
var c$ = Array.prototype.slice.call(d.childNodes);
|
903
|
+
for (var i = 0; i < c$.length; i++) {
|
904
|
+
this.appendChild(c$[i]);
|
905
|
+
}
|
906
|
+
}
|
907
|
+
},
|
908
|
+
configurable: true
|
909
|
+
}
|
910
|
+
});
|
911
|
+
DomApi.prototype._getComposedInnerHTML = function () {
|
912
|
+
return getInnerHTML(this.node, true);
|
913
|
+
};
|
914
|
+
} else {
|
915
|
+
var forwardMethods = [
|
916
|
+
'cloneNode',
|
917
|
+
'appendChild',
|
918
|
+
'insertBefore',
|
919
|
+
'removeChild',
|
920
|
+
'replaceChild'
|
921
|
+
];
|
922
|
+
forwardMethods.forEach(function (name) {
|
923
|
+
DomApi.prototype[name] = function () {
|
924
|
+
return this.node[name].apply(this.node, arguments);
|
925
|
+
};
|
926
|
+
});
|
927
|
+
DomApi.prototype.querySelectorAll = function (selector) {
|
928
|
+
return Array.prototype.slice.call(this.node.querySelectorAll(selector));
|
929
|
+
};
|
930
|
+
DomApi.prototype.getOwnerRoot = function () {
|
931
|
+
var n = this.node;
|
932
|
+
while (n) {
|
933
|
+
if (n.nodeType === Node.DOCUMENT_FRAGMENT_NODE && n.host) {
|
934
|
+
return n;
|
935
|
+
}
|
936
|
+
n = n.parentNode;
|
937
|
+
}
|
938
|
+
};
|
939
|
+
DomApi.prototype.importNode = function (externalNode, deep) {
|
940
|
+
var doc = this.node instanceof Document ? this.node : this.node.ownerDocument;
|
941
|
+
return doc.importNode(externalNode, deep);
|
942
|
+
};
|
943
|
+
DomApi.prototype.getDestinationInsertionPoints = function () {
|
944
|
+
var n$ = this.node.getDestinationInsertionPoints && this.node.getDestinationInsertionPoints();
|
945
|
+
return n$ ? Array.prototype.slice.call(n$) : [];
|
946
|
+
};
|
947
|
+
DomApi.prototype.getDistributedNodes = function () {
|
948
|
+
var n$ = this.node.getDistributedNodes && this.node.getDistributedNodes();
|
949
|
+
return n$ ? Array.prototype.slice.call(n$) : [];
|
950
|
+
};
|
951
|
+
DomApi.prototype._distributeParent = function () {
|
952
|
+
};
|
953
|
+
var nativeForwards = [
|
954
|
+
'appendChild',
|
955
|
+
'insertBefore',
|
956
|
+
'removeChild',
|
957
|
+
'replaceChild'
|
958
|
+
];
|
959
|
+
nativeForwards.forEach(function (forward) {
|
960
|
+
DomApi.prototype[forward] = function () {
|
961
|
+
return this.node[forward].apply(this.node, arguments);
|
962
|
+
};
|
963
|
+
});
|
964
|
+
Object.defineProperties(DomApi.prototype, {
|
965
|
+
childNodes: {
|
966
|
+
get: function () {
|
967
|
+
return Array.prototype.slice.call(this.node.childNodes);
|
968
|
+
},
|
969
|
+
configurable: true
|
970
|
+
},
|
971
|
+
children: {
|
972
|
+
get: function () {
|
973
|
+
return Array.prototype.slice.call(this.node.children);
|
974
|
+
},
|
975
|
+
configurable: true
|
976
|
+
},
|
977
|
+
textContent: {
|
978
|
+
get: function () {
|
979
|
+
return this.node.textContent;
|
980
|
+
},
|
981
|
+
set: function (value) {
|
982
|
+
return this.node.textContent = value;
|
983
|
+
},
|
984
|
+
configurable: true
|
985
|
+
},
|
986
|
+
innerHTML: {
|
987
|
+
get: function () {
|
988
|
+
return this.node.innerHTML;
|
989
|
+
},
|
990
|
+
set: function (value) {
|
991
|
+
return this.node.innerHTML = value;
|
992
|
+
},
|
993
|
+
configurable: true
|
994
|
+
}
|
995
|
+
});
|
996
|
+
var forwardProperties = [
|
997
|
+
'parentNode',
|
998
|
+
'firstChild',
|
999
|
+
'lastChild',
|
1000
|
+
'nextSibling',
|
1001
|
+
'previousSibling',
|
1002
|
+
'firstElementChild',
|
1003
|
+
'lastElementChild',
|
1004
|
+
'nextElementSibling',
|
1005
|
+
'previousElementSibling'
|
1006
|
+
];
|
1007
|
+
forwardProperties.forEach(function (name) {
|
1008
|
+
Object.defineProperty(DomApi.prototype, name, {
|
1009
|
+
get: function () {
|
1010
|
+
return this.node[name];
|
1011
|
+
},
|
1012
|
+
configurable: true
|
1013
|
+
});
|
1014
|
+
});
|
1015
|
+
}
|
1016
|
+
var CONTENT = 'content';
|
1017
|
+
function factory(node, patch) {
|
1018
|
+
node = node || document;
|
1019
|
+
if (!node.__domApi) {
|
1020
|
+
node.__domApi = new DomApi(node, patch);
|
1021
|
+
}
|
1022
|
+
return node.__domApi;
|
1023
|
+
}
|
1024
|
+
;
|
1025
|
+
function hasDomApi(node) {
|
1026
|
+
return Boolean(node.__domApi);
|
1027
|
+
}
|
1028
|
+
Polymer.dom = function (obj, patch) {
|
1029
|
+
if (obj instanceof Event) {
|
1030
|
+
return Polymer.EventApi.factory(obj);
|
1031
|
+
} else {
|
1032
|
+
return factory(obj, patch);
|
1033
|
+
}
|
1034
|
+
};
|
1035
|
+
function getLightChildren(node) {
|
1036
|
+
var children = node._lightChildren;
|
1037
|
+
return children ? children : node.childNodes;
|
1038
|
+
}
|
1039
|
+
function getComposedChildren(node) {
|
1040
|
+
if (!node._composedChildren) {
|
1041
|
+
node._composedChildren = Array.prototype.slice.call(node.childNodes);
|
1042
|
+
}
|
1043
|
+
return node._composedChildren;
|
1044
|
+
}
|
1045
|
+
function addToComposedParent(parent, node, ref_node) {
|
1046
|
+
var children = getComposedChildren(parent);
|
1047
|
+
var i = ref_node ? children.indexOf(ref_node) : -1;
|
1048
|
+
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
1049
|
+
var fragChildren = getComposedChildren(node);
|
1050
|
+
for (var j = 0; j < fragChildren.length; j++) {
|
1051
|
+
addNodeToComposedChildren(fragChildren[j], parent, children, i + j);
|
1052
|
+
}
|
1053
|
+
node._composedChildren = null;
|
1054
|
+
} else {
|
1055
|
+
addNodeToComposedChildren(node, parent, children, i);
|
1056
|
+
}
|
1057
|
+
}
|
1058
|
+
function getComposedParent(node) {
|
1059
|
+
return node.__patched ? node._composedParent : node.parentNode;
|
1060
|
+
}
|
1061
|
+
function addNodeToComposedChildren(node, parent, children, i) {
|
1062
|
+
node._composedParent = parent;
|
1063
|
+
children.splice(i >= 0 ? i : children.length, 0, node);
|
1064
|
+
}
|
1065
|
+
function removeFromComposedParent(parent, node) {
|
1066
|
+
node._composedParent = null;
|
1067
|
+
if (parent) {
|
1068
|
+
var children = getComposedChildren(parent);
|
1069
|
+
var i = children.indexOf(node);
|
1070
|
+
if (i >= 0) {
|
1071
|
+
children.splice(i, 1);
|
1072
|
+
}
|
1073
|
+
}
|
1074
|
+
}
|
1075
|
+
function saveLightChildrenIfNeeded(node) {
|
1076
|
+
if (!node._lightChildren) {
|
1077
|
+
var c$ = Array.prototype.slice.call(node.childNodes);
|
1078
|
+
for (var i = 0, l = c$.length, child; i < l && (child = c$[i]); i++) {
|
1079
|
+
child._lightParent = child._lightParent || node;
|
1080
|
+
}
|
1081
|
+
node._lightChildren = c$;
|
1082
|
+
}
|
1083
|
+
}
|
1084
|
+
function hasInsertionPoint(root) {
|
1085
|
+
return Boolean(root && root._insertionPoints.length);
|
1086
|
+
}
|
1087
|
+
var p = Element.prototype;
|
1088
|
+
var matchesSelector = p.matches || p.matchesSelector || p.mozMatchesSelector || p.msMatchesSelector || p.oMatchesSelector || p.webkitMatchesSelector;
|
1089
|
+
return {
|
1090
|
+
getLightChildren: getLightChildren,
|
1091
|
+
getComposedParent: getComposedParent,
|
1092
|
+
getComposedChildren: getComposedChildren,
|
1093
|
+
removeFromComposedParent: removeFromComposedParent,
|
1094
|
+
saveLightChildrenIfNeeded: saveLightChildrenIfNeeded,
|
1095
|
+
matchesSelector: matchesSelector,
|
1096
|
+
hasInsertionPoint: hasInsertionPoint,
|
1097
|
+
ctor: DomApi,
|
1098
|
+
factory: factory,
|
1099
|
+
hasDomApi: hasDomApi
|
1100
|
+
};
|
1101
|
+
}();
|
1102
|
+
Polymer.Base.extend(Polymer.dom, {
|
1103
|
+
_flushGuard: 0,
|
1104
|
+
_FLUSH_MAX: 100,
|
1105
|
+
_needsTakeRecords: !Polymer.Settings.useNativeCustomElements,
|
1106
|
+
_debouncers: [],
|
1107
|
+
_staticFlushList: [],
|
1108
|
+
_finishDebouncer: null,
|
1109
|
+
flush: function () {
|
1110
|
+
this._flushGuard = 0;
|
1111
|
+
this._prepareFlush();
|
1112
|
+
while (this._debouncers.length && this._flushGuard < this._FLUSH_MAX) {
|
1113
|
+
for (var i = 0; i < this._debouncers.length; i++) {
|
1114
|
+
this._debouncers[i].complete();
|
1115
|
+
}
|
1116
|
+
if (this._finishDebouncer) {
|
1117
|
+
this._finishDebouncer.complete();
|
1118
|
+
}
|
1119
|
+
this._prepareFlush();
|
1120
|
+
this._flushGuard++;
|
1121
|
+
}
|
1122
|
+
if (this._flushGuard >= this._FLUSH_MAX) {
|
1123
|
+
console.warn('Polymer.dom.flush aborted. Flush may not be complete.');
|
1124
|
+
}
|
1125
|
+
},
|
1126
|
+
_prepareFlush: function () {
|
1127
|
+
if (this._needsTakeRecords) {
|
1128
|
+
CustomElements.takeRecords();
|
1129
|
+
}
|
1130
|
+
for (var i = 0; i < this._staticFlushList.length; i++) {
|
1131
|
+
this._staticFlushList[i]();
|
1132
|
+
}
|
1133
|
+
},
|
1134
|
+
addStaticFlush: function (fn) {
|
1135
|
+
this._staticFlushList.push(fn);
|
1136
|
+
},
|
1137
|
+
removeStaticFlush: function (fn) {
|
1138
|
+
var i = this._staticFlushList.indexOf(fn);
|
1139
|
+
if (i >= 0) {
|
1140
|
+
this._staticFlushList.splice(i, 1);
|
1141
|
+
}
|
1142
|
+
},
|
1143
|
+
addDebouncer: function (debouncer) {
|
1144
|
+
this._debouncers.push(debouncer);
|
1145
|
+
this._finishDebouncer = Polymer.Debounce(this._finishDebouncer, this._finishFlush);
|
1146
|
+
},
|
1147
|
+
_finishFlush: function () {
|
1148
|
+
Polymer.dom._debouncers = [];
|
1149
|
+
}
|
1150
|
+
});
|
1151
|
+
Polymer.EventApi = function () {
|
1152
|
+
'use strict';
|
1153
|
+
var DomApi = Polymer.DomApi.ctor;
|
1154
|
+
var Settings = Polymer.Settings;
|
1155
|
+
DomApi.Event = function (event) {
|
1156
|
+
this.event = event;
|
1157
|
+
};
|
1158
|
+
if (Settings.useShadow) {
|
1159
|
+
DomApi.Event.prototype = {
|
1160
|
+
get rootTarget() {
|
1161
|
+
return this.event.path[0];
|
1162
|
+
},
|
1163
|
+
get localTarget() {
|
1164
|
+
return this.event.target;
|
1165
|
+
},
|
1166
|
+
get path() {
|
1167
|
+
return this.event.path;
|
1168
|
+
}
|
1169
|
+
};
|
1170
|
+
} else {
|
1171
|
+
DomApi.Event.prototype = {
|
1172
|
+
get rootTarget() {
|
1173
|
+
return this.event.target;
|
1174
|
+
},
|
1175
|
+
get localTarget() {
|
1176
|
+
var current = this.event.currentTarget;
|
1177
|
+
var currentRoot = current && Polymer.dom(current).getOwnerRoot();
|
1178
|
+
var p$ = this.path;
|
1179
|
+
for (var i = 0; i < p$.length; i++) {
|
1180
|
+
if (Polymer.dom(p$[i]).getOwnerRoot() === currentRoot) {
|
1181
|
+
return p$[i];
|
1182
|
+
}
|
1183
|
+
}
|
1184
|
+
},
|
1185
|
+
get path() {
|
1186
|
+
if (!this.event._path) {
|
1187
|
+
var path = [];
|
1188
|
+
var o = this.rootTarget;
|
1189
|
+
while (o) {
|
1190
|
+
path.push(o);
|
1191
|
+
o = Polymer.dom(o).parentNode || o.host;
|
1192
|
+
}
|
1193
|
+
path.push(window);
|
1194
|
+
this.event._path = path;
|
1195
|
+
}
|
1196
|
+
return this.event._path;
|
1197
|
+
}
|
1198
|
+
};
|
1199
|
+
}
|
1200
|
+
var factory = function (event) {
|
1201
|
+
if (!event.__eventApi) {
|
1202
|
+
event.__eventApi = new DomApi.Event(event);
|
1203
|
+
}
|
1204
|
+
return event.__eventApi;
|
1205
|
+
};
|
1206
|
+
return { factory: factory };
|
1207
|
+
}();
|
1208
|
+
(function () {
|
1209
|
+
'use strict';
|
1210
|
+
var DomApi = Polymer.DomApi.ctor;
|
1211
|
+
Object.defineProperty(DomApi.prototype, 'classList', {
|
1212
|
+
get: function () {
|
1213
|
+
if (!this._classList) {
|
1214
|
+
this._classList = new DomApi.ClassList(this);
|
1215
|
+
}
|
1216
|
+
return this._classList;
|
1217
|
+
},
|
1218
|
+
configurable: true
|
1219
|
+
});
|
1220
|
+
DomApi.ClassList = function (host) {
|
1221
|
+
this.domApi = host;
|
1222
|
+
this.node = host.node;
|
1223
|
+
};
|
1224
|
+
DomApi.ClassList.prototype = {
|
1225
|
+
add: function () {
|
1226
|
+
this.node.classList.add.apply(this.node.classList, arguments);
|
1227
|
+
this.domApi._distributeParent();
|
1228
|
+
},
|
1229
|
+
remove: function () {
|
1230
|
+
this.node.classList.remove.apply(this.node.classList, arguments);
|
1231
|
+
this.domApi._distributeParent();
|
1232
|
+
},
|
1233
|
+
toggle: function () {
|
1234
|
+
this.node.classList.toggle.apply(this.node.classList, arguments);
|
1235
|
+
this.domApi._distributeParent();
|
1236
|
+
},
|
1237
|
+
contains: function () {
|
1238
|
+
return this.node.classList.contains.apply(this.node.classList, arguments);
|
1239
|
+
}
|
1240
|
+
};
|
1241
|
+
}());
|
1242
|
+
(function () {
|
1243
|
+
'use strict';
|
1244
|
+
var DomApi = Polymer.DomApi.ctor;
|
1245
|
+
var Settings = Polymer.Settings;
|
1246
|
+
var hasDomApi = Polymer.DomApi.hasDomApi;
|
1247
|
+
DomApi.EffectiveNodesObserver = function (domApi) {
|
1248
|
+
this.domApi = domApi;
|
1249
|
+
this.node = this.domApi.node;
|
1250
|
+
this._listeners = [];
|
1251
|
+
};
|
1252
|
+
DomApi.EffectiveNodesObserver.prototype = {
|
1253
|
+
addListener: function (callback) {
|
1254
|
+
if (!this._isSetup) {
|
1255
|
+
this._setup();
|
1256
|
+
this._isSetup = true;
|
1257
|
+
}
|
1258
|
+
var listener = {
|
1259
|
+
fn: callback,
|
1260
|
+
_nodes: []
|
1261
|
+
};
|
1262
|
+
this._listeners.push(listener);
|
1263
|
+
this._scheduleNotify();
|
1264
|
+
return listener;
|
1265
|
+
},
|
1266
|
+
removeListener: function (handle) {
|
1267
|
+
var i = this._listeners.indexOf(handle);
|
1268
|
+
if (i >= 0) {
|
1269
|
+
this._listeners.splice(i, 1);
|
1270
|
+
handle._nodes = [];
|
1271
|
+
}
|
1272
|
+
if (!this._hasListeners()) {
|
1273
|
+
this._cleanup();
|
1274
|
+
this._isSetup = false;
|
1275
|
+
}
|
1276
|
+
},
|
1277
|
+
_setup: function () {
|
1278
|
+
this._observeContentElements(this.domApi.childNodes);
|
1279
|
+
},
|
1280
|
+
_cleanup: function () {
|
1281
|
+
this._unobserveContentElements(this.domApi.childNodes);
|
1282
|
+
},
|
1283
|
+
_hasListeners: function () {
|
1284
|
+
return Boolean(this._listeners.length);
|
1285
|
+
},
|
1286
|
+
_scheduleNotify: function () {
|
1287
|
+
if (this._debouncer) {
|
1288
|
+
this._debouncer.stop();
|
1289
|
+
}
|
1290
|
+
this._debouncer = Polymer.Debounce(this._debouncer, this._notify);
|
1291
|
+
this._debouncer.context = this;
|
1292
|
+
Polymer.dom.addDebouncer(this._debouncer);
|
1293
|
+
},
|
1294
|
+
notify: function () {
|
1295
|
+
if (this._hasListeners()) {
|
1296
|
+
this._scheduleNotify();
|
1297
|
+
}
|
1298
|
+
},
|
1299
|
+
_notify: function (mxns) {
|
1300
|
+
this._beforeCallListeners();
|
1301
|
+
this._callListeners();
|
1302
|
+
},
|
1303
|
+
_beforeCallListeners: function () {
|
1304
|
+
this._updateContentElements();
|
1305
|
+
},
|
1306
|
+
_updateContentElements: function () {
|
1307
|
+
this._observeContentElements(this.domApi.childNodes);
|
1308
|
+
},
|
1309
|
+
_observeContentElements: function (elements) {
|
1310
|
+
for (var i = 0, n; i < elements.length && (n = elements[i]); i++) {
|
1311
|
+
if (this._isContent(n)) {
|
1312
|
+
n.__observeNodesMap = n.__observeNodesMap || new WeakMap();
|
1313
|
+
if (!n.__observeNodesMap.has(this)) {
|
1314
|
+
n.__observeNodesMap.set(this, this._observeContent(n));
|
1315
|
+
}
|
1316
|
+
}
|
1317
|
+
}
|
1318
|
+
},
|
1319
|
+
_observeContent: function (content) {
|
1320
|
+
var h = Polymer.dom(content).observeNodes(this._scheduleNotify.bind(this));
|
1321
|
+
h._avoidChangeCalculation = true;
|
1322
|
+
return h;
|
1323
|
+
},
|
1324
|
+
_unobserveContentElements: function (elements) {
|
1325
|
+
for (var i = 0, n, h; i < elements.length && (n = elements[i]); i++) {
|
1326
|
+
if (this._isContent(n)) {
|
1327
|
+
h = n.__observeNodesMap.get(this);
|
1328
|
+
if (h) {
|
1329
|
+
Polymer.dom(n).unobserveNodes(h);
|
1330
|
+
n.__observeNodesMap.delete(this);
|
1331
|
+
}
|
1332
|
+
}
|
1333
|
+
}
|
1334
|
+
},
|
1335
|
+
_isContent: function (node) {
|
1336
|
+
return node.localName === 'content';
|
1337
|
+
},
|
1338
|
+
_callListeners: function () {
|
1339
|
+
var o$ = this._listeners;
|
1340
|
+
var nodes = this._getEffectiveNodes();
|
1341
|
+
for (var i = 0, o; i < o$.length && (o = o$[i]); i++) {
|
1342
|
+
var info = this._generateListenerInfo(o, nodes);
|
1343
|
+
if (info || o._alwaysNotify) {
|
1344
|
+
this._callListener(o, info);
|
1345
|
+
}
|
1346
|
+
}
|
1347
|
+
},
|
1348
|
+
_getEffectiveNodes: function () {
|
1349
|
+
return this.domApi.getEffectiveChildNodes();
|
1350
|
+
},
|
1351
|
+
_generateListenerInfo: function (listener, newNodes) {
|
1352
|
+
if (listener._avoidChangeCalculation) {
|
1353
|
+
return true;
|
1354
|
+
}
|
1355
|
+
var oldNodes = listener._nodes;
|
1356
|
+
var info = {
|
1357
|
+
target: this.node,
|
1358
|
+
addedNodes: [],
|
1359
|
+
removedNodes: []
|
1360
|
+
};
|
1361
|
+
var splices = Polymer.ArraySplice.calculateSplices(newNodes, oldNodes);
|
1362
|
+
for (var i = 0, s; i < splices.length && (s = splices[i]); i++) {
|
1363
|
+
for (var j = 0, n; j < s.removed.length && (n = s.removed[j]); j++) {
|
1364
|
+
info.removedNodes.push(n);
|
1365
|
+
}
|
1366
|
+
}
|
1367
|
+
for (var i = 0, s; i < splices.length && (s = splices[i]); i++) {
|
1368
|
+
for (var j = s.index; j < s.index + s.addedCount; j++) {
|
1369
|
+
info.addedNodes.push(newNodes[j]);
|
1370
|
+
}
|
1371
|
+
}
|
1372
|
+
listener._nodes = newNodes;
|
1373
|
+
if (info.addedNodes.length || info.removedNodes.length) {
|
1374
|
+
return info;
|
1375
|
+
}
|
1376
|
+
},
|
1377
|
+
_callListener: function (listener, info) {
|
1378
|
+
return listener.fn.call(this.node, info);
|
1379
|
+
},
|
1380
|
+
enableShadowAttributeTracking: function () {
|
1381
|
+
}
|
1382
|
+
};
|
1383
|
+
if (Settings.useShadow) {
|
1384
|
+
var baseSetup = DomApi.EffectiveNodesObserver.prototype._setup;
|
1385
|
+
var baseCleanup = DomApi.EffectiveNodesObserver.prototype._cleanup;
|
1386
|
+
var beforeCallListeners = DomApi.EffectiveNodesObserver.prototype._beforeCallListeners;
|
1387
|
+
Polymer.Base.extend(DomApi.EffectiveNodesObserver.prototype, {
|
1388
|
+
_setup: function () {
|
1389
|
+
if (!this._observer) {
|
1390
|
+
var self = this;
|
1391
|
+
this._mutationHandler = function (mxns) {
|
1392
|
+
if (mxns && mxns.length) {
|
1393
|
+
self._scheduleNotify();
|
1394
|
+
}
|
1395
|
+
};
|
1396
|
+
this._observer = new MutationObserver(this._mutationHandler);
|
1397
|
+
this._boundFlush = this._flush.bind(this);
|
1398
|
+
Polymer.dom.addStaticFlush(this._boundFlush);
|
1399
|
+
this._observer.observe(this.node, { childList: true });
|
1400
|
+
}
|
1401
|
+
baseSetup.call(this);
|
1402
|
+
},
|
1403
|
+
_cleanup: function () {
|
1404
|
+
this._observer.disconnect();
|
1405
|
+
this._observer = null;
|
1406
|
+
this._mutationHandler = null;
|
1407
|
+
Polymer.dom.removeStaticFlush(this._boundFlush);
|
1408
|
+
baseCleanup.call(this);
|
1409
|
+
},
|
1410
|
+
_flush: function () {
|
1411
|
+
if (this._observer) {
|
1412
|
+
this._mutationHandler(this._observer.takeRecords());
|
1413
|
+
}
|
1414
|
+
},
|
1415
|
+
enableShadowAttributeTracking: function () {
|
1416
|
+
if (this._observer) {
|
1417
|
+
this._makeContentListenersAlwaysNotify();
|
1418
|
+
this._observer.disconnect();
|
1419
|
+
this._observer.observe(this.node, {
|
1420
|
+
childList: true,
|
1421
|
+
attributes: true,
|
1422
|
+
subtree: true
|
1423
|
+
});
|
1424
|
+
var root = this.domApi.getOwnerRoot();
|
1425
|
+
var host = root && root.host;
|
1426
|
+
if (host && Polymer.dom(host).observer) {
|
1427
|
+
Polymer.dom(host).observer.enableShadowAttributeTracking();
|
1428
|
+
}
|
1429
|
+
}
|
1430
|
+
},
|
1431
|
+
_makeContentListenersAlwaysNotify: function () {
|
1432
|
+
for (var i = 0, h; i < this._listeners.length; i++) {
|
1433
|
+
h = this._listeners[i];
|
1434
|
+
h._alwaysNotify = h._isContentListener;
|
1435
|
+
}
|
1436
|
+
}
|
1437
|
+
});
|
1438
|
+
}
|
1439
|
+
}());
|
1440
|
+
(function () {
|
1441
|
+
'use strict';
|
1442
|
+
var DomApi = Polymer.DomApi.ctor;
|
1443
|
+
var Settings = Polymer.Settings;
|
1444
|
+
DomApi.DistributedNodesObserver = function (domApi) {
|
1445
|
+
DomApi.EffectiveNodesObserver.call(this, domApi);
|
1446
|
+
};
|
1447
|
+
DomApi.DistributedNodesObserver.prototype = Object.create(DomApi.EffectiveNodesObserver.prototype);
|
1448
|
+
Polymer.Base.extend(DomApi.DistributedNodesObserver.prototype, {
|
1449
|
+
_setup: function () {
|
1450
|
+
},
|
1451
|
+
_cleanup: function () {
|
1452
|
+
},
|
1453
|
+
_beforeCallListeners: function () {
|
1454
|
+
},
|
1455
|
+
_getEffectiveNodes: function () {
|
1456
|
+
return this.domApi.getDistributedNodes();
|
1457
|
+
}
|
1458
|
+
});
|
1459
|
+
if (Settings.useShadow) {
|
1460
|
+
Polymer.Base.extend(DomApi.DistributedNodesObserver.prototype, {
|
1461
|
+
_setup: function () {
|
1462
|
+
if (!this._observer) {
|
1463
|
+
var root = this.domApi.getOwnerRoot();
|
1464
|
+
var host = root && root.host;
|
1465
|
+
if (host) {
|
1466
|
+
this._observer = Polymer.dom(host).observeNodes(this._scheduleNotify.bind(this));
|
1467
|
+
this._observer._isContentListener = true;
|
1468
|
+
if (this._hasAttrSelect()) {
|
1469
|
+
Polymer.dom(host).observer.enableShadowAttributeTracking();
|
1470
|
+
}
|
1471
|
+
}
|
1472
|
+
}
|
1473
|
+
},
|
1474
|
+
_hasAttrSelect: function () {
|
1475
|
+
var select = this.node.getAttribute('select');
|
1476
|
+
return select && select.match(/[[.]+/);
|
1477
|
+
},
|
1478
|
+
_cleanup: function () {
|
1479
|
+
var root = this.domApi.getOwnerRoot();
|
1480
|
+
var host = root && root.host;
|
1481
|
+
if (host) {
|
1482
|
+
Polymer.dom(host).unobserveNodes(this._observer);
|
1483
|
+
}
|
1484
|
+
this._observer = null;
|
1485
|
+
}
|
1486
|
+
});
|
1487
|
+
}
|
1488
|
+
}());
|
1489
|
+
(function () {
|
1490
|
+
var hasDomApi = Polymer.DomApi.hasDomApi;
|
1491
|
+
Polymer.Base._addFeature({
|
1492
|
+
_prepShady: function () {
|
1493
|
+
this._useContent = this._useContent || Boolean(this._template);
|
1494
|
+
},
|
1495
|
+
_poolContent: function () {
|
1496
|
+
if (this._useContent) {
|
1497
|
+
saveLightChildrenIfNeeded(this);
|
1498
|
+
}
|
1499
|
+
},
|
1500
|
+
_setupRoot: function () {
|
1501
|
+
if (this._useContent) {
|
1502
|
+
this._createLocalRoot();
|
1503
|
+
if (!this.dataHost) {
|
1504
|
+
upgradeLightChildren(this._lightChildren);
|
1505
|
+
}
|
1506
|
+
}
|
1507
|
+
},
|
1508
|
+
_createLocalRoot: function () {
|
1509
|
+
this.shadyRoot = this.root;
|
1510
|
+
this.shadyRoot._distributionClean = false;
|
1511
|
+
this.shadyRoot._isShadyRoot = true;
|
1512
|
+
this.shadyRoot._dirtyRoots = [];
|
1513
|
+
var i$ = this.shadyRoot._insertionPoints = !this._notes || this._notes._hasContent ? this.shadyRoot.querySelectorAll('content') : [];
|
1514
|
+
saveLightChildrenIfNeeded(this.shadyRoot);
|
1515
|
+
for (var i = 0, c; i < i$.length; i++) {
|
1516
|
+
c = i$[i];
|
1517
|
+
saveLightChildrenIfNeeded(c);
|
1518
|
+
saveLightChildrenIfNeeded(c.parentNode);
|
1519
|
+
}
|
1520
|
+
this.shadyRoot.host = this;
|
1521
|
+
},
|
1522
|
+
get domHost() {
|
1523
|
+
var root = Polymer.dom(this).getOwnerRoot();
|
1524
|
+
return root && root.host;
|
1525
|
+
},
|
1526
|
+
distributeContent: function (updateInsertionPoints) {
|
1527
|
+
if (this.shadyRoot) {
|
1528
|
+
var dom = Polymer.dom(this);
|
1529
|
+
if (updateInsertionPoints) {
|
1530
|
+
dom._updateInsertionPoints(this);
|
1531
|
+
}
|
1532
|
+
var host = getTopDistributingHost(this);
|
1533
|
+
dom._lazyDistribute(host);
|
1534
|
+
}
|
1535
|
+
},
|
1536
|
+
_distributeContent: function () {
|
1537
|
+
if (this._useContent && !this.shadyRoot._distributionClean) {
|
1538
|
+
this._beginDistribute();
|
1539
|
+
this._distributeDirtyRoots();
|
1540
|
+
this._finishDistribute();
|
1541
|
+
}
|
1542
|
+
},
|
1543
|
+
_beginDistribute: function () {
|
1544
|
+
if (this._useContent && hasInsertionPoint(this.shadyRoot)) {
|
1545
|
+
this._resetDistribution();
|
1546
|
+
this._distributePool(this.shadyRoot, this._collectPool());
|
1547
|
+
}
|
1548
|
+
},
|
1549
|
+
_distributeDirtyRoots: function () {
|
1550
|
+
var c$ = this.shadyRoot._dirtyRoots;
|
1551
|
+
for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
|
1552
|
+
c._distributeContent();
|
1553
|
+
}
|
1554
|
+
this.shadyRoot._dirtyRoots = [];
|
1555
|
+
},
|
1556
|
+
_finishDistribute: function () {
|
1557
|
+
if (this._useContent) {
|
1558
|
+
this.shadyRoot._distributionClean = true;
|
1559
|
+
if (hasInsertionPoint(this.shadyRoot)) {
|
1560
|
+
this._composeTree();
|
1561
|
+
notifyContentObservers(this.shadyRoot);
|
1562
|
+
} else {
|
1563
|
+
if (!this.shadyRoot._hasDistributed) {
|
1564
|
+
this.textContent = '';
|
1565
|
+
this._composedChildren = null;
|
1566
|
+
this.appendChild(this.shadyRoot);
|
1567
|
+
} else {
|
1568
|
+
var children = this._composeNode(this);
|
1569
|
+
this._updateChildNodes(this, children);
|
1570
|
+
}
|
1571
|
+
}
|
1572
|
+
if (!this.shadyRoot._hasDistributed) {
|
1573
|
+
notifyInitialDistribution(this);
|
1574
|
+
}
|
1575
|
+
this.shadyRoot._hasDistributed = true;
|
1576
|
+
}
|
1577
|
+
},
|
1578
|
+
elementMatches: function (selector, node) {
|
1579
|
+
node = node || this;
|
1580
|
+
return matchesSelector.call(node, selector);
|
1581
|
+
},
|
1582
|
+
_resetDistribution: function () {
|
1583
|
+
var children = getLightChildren(this);
|
1584
|
+
for (var i = 0; i < children.length; i++) {
|
1585
|
+
var child = children[i];
|
1586
|
+
if (child._destinationInsertionPoints) {
|
1587
|
+
child._destinationInsertionPoints = undefined;
|
1588
|
+
}
|
1589
|
+
if (isInsertionPoint(child)) {
|
1590
|
+
clearDistributedDestinationInsertionPoints(child);
|
1591
|
+
}
|
1592
|
+
}
|
1593
|
+
var root = this.shadyRoot;
|
1594
|
+
var p$ = root._insertionPoints;
|
1595
|
+
for (var j = 0; j < p$.length; j++) {
|
1596
|
+
p$[j]._distributedNodes = [];
|
1597
|
+
}
|
1598
|
+
},
|
1599
|
+
_collectPool: function () {
|
1600
|
+
var pool = [];
|
1601
|
+
var children = getLightChildren(this);
|
1602
|
+
for (var i = 0; i < children.length; i++) {
|
1603
|
+
var child = children[i];
|
1604
|
+
if (isInsertionPoint(child)) {
|
1605
|
+
pool.push.apply(pool, child._distributedNodes);
|
1606
|
+
} else {
|
1607
|
+
pool.push(child);
|
1608
|
+
}
|
1609
|
+
}
|
1610
|
+
return pool;
|
1611
|
+
},
|
1612
|
+
_distributePool: function (node, pool) {
|
1613
|
+
var p$ = node._insertionPoints;
|
1614
|
+
for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) {
|
1615
|
+
this._distributeInsertionPoint(p, pool);
|
1616
|
+
maybeRedistributeParent(p, this);
|
1617
|
+
}
|
1618
|
+
},
|
1619
|
+
_distributeInsertionPoint: function (content, pool) {
|
1620
|
+
var anyDistributed = false;
|
1621
|
+
for (var i = 0, l = pool.length, node; i < l; i++) {
|
1622
|
+
node = pool[i];
|
1623
|
+
if (!node) {
|
1624
|
+
continue;
|
1625
|
+
}
|
1626
|
+
if (this._matchesContentSelect(node, content)) {
|
1627
|
+
distributeNodeInto(node, content);
|
1628
|
+
pool[i] = undefined;
|
1629
|
+
anyDistributed = true;
|
1630
|
+
}
|
1631
|
+
}
|
1632
|
+
if (!anyDistributed) {
|
1633
|
+
var children = getLightChildren(content);
|
1634
|
+
for (var j = 0; j < children.length; j++) {
|
1635
|
+
distributeNodeInto(children[j], content);
|
1636
|
+
}
|
1637
|
+
}
|
1638
|
+
},
|
1639
|
+
_composeTree: function () {
|
1640
|
+
this._updateChildNodes(this, this._composeNode(this));
|
1641
|
+
var p$ = this.shadyRoot._insertionPoints;
|
1642
|
+
for (var i = 0, l = p$.length, p, parent; i < l && (p = p$[i]); i++) {
|
1643
|
+
parent = p._lightParent || p.parentNode;
|
1644
|
+
if (!parent._useContent && parent !== this && parent !== this.shadyRoot) {
|
1645
|
+
this._updateChildNodes(parent, this._composeNode(parent));
|
1646
|
+
}
|
1647
|
+
}
|
1648
|
+
},
|
1649
|
+
_composeNode: function (node) {
|
1650
|
+
var children = [];
|
1651
|
+
var c$ = getLightChildren(node.shadyRoot || node);
|
1652
|
+
for (var i = 0; i < c$.length; i++) {
|
1653
|
+
var child = c$[i];
|
1654
|
+
if (isInsertionPoint(child)) {
|
1655
|
+
var distributedNodes = child._distributedNodes;
|
1656
|
+
for (var j = 0; j < distributedNodes.length; j++) {
|
1657
|
+
var distributedNode = distributedNodes[j];
|
1658
|
+
if (isFinalDestination(child, distributedNode)) {
|
1659
|
+
children.push(distributedNode);
|
1660
|
+
}
|
1661
|
+
}
|
1662
|
+
} else {
|
1663
|
+
children.push(child);
|
1664
|
+
}
|
1665
|
+
}
|
1666
|
+
return children;
|
1667
|
+
},
|
1668
|
+
_updateChildNodes: function (container, children) {
|
1669
|
+
var composed = getComposedChildren(container);
|
1670
|
+
var splices = Polymer.ArraySplice.calculateSplices(children, composed);
|
1671
|
+
for (var i = 0, d = 0, s; i < splices.length && (s = splices[i]); i++) {
|
1672
|
+
for (var j = 0, n; j < s.removed.length && (n = s.removed[j]); j++) {
|
1673
|
+
if (getComposedParent(n) === container) {
|
1674
|
+
remove(n);
|
1675
|
+
}
|
1676
|
+
composed.splice(s.index + d, 1);
|
1677
|
+
}
|
1678
|
+
d -= s.addedCount;
|
1679
|
+
}
|
1680
|
+
for (var i = 0, s, next; i < splices.length && (s = splices[i]); i++) {
|
1681
|
+
next = composed[s.index];
|
1682
|
+
for (var j = s.index, n; j < s.index + s.addedCount; j++) {
|
1683
|
+
n = children[j];
|
1684
|
+
insertBefore(container, n, next);
|
1685
|
+
composed.splice(j, 0, n);
|
1686
|
+
}
|
1687
|
+
}
|
1688
|
+
ensureComposedParent(container, children);
|
1689
|
+
},
|
1690
|
+
_matchesContentSelect: function (node, contentElement) {
|
1691
|
+
var select = contentElement.getAttribute('select');
|
1692
|
+
if (!select) {
|
1693
|
+
return true;
|
1694
|
+
}
|
1695
|
+
select = select.trim();
|
1696
|
+
if (!select) {
|
1697
|
+
return true;
|
1698
|
+
}
|
1699
|
+
if (!(node instanceof Element)) {
|
1700
|
+
return false;
|
1701
|
+
}
|
1702
|
+
var validSelectors = /^(:not\()?[*.#[a-zA-Z_|]/;
|
1703
|
+
if (!validSelectors.test(select)) {
|
1704
|
+
return false;
|
1705
|
+
}
|
1706
|
+
return this.elementMatches(select, node);
|
1707
|
+
},
|
1708
|
+
_elementAdd: function () {
|
1709
|
+
},
|
1710
|
+
_elementRemove: function () {
|
1711
|
+
}
|
1712
|
+
});
|
1713
|
+
var saveLightChildrenIfNeeded = Polymer.DomApi.saveLightChildrenIfNeeded;
|
1714
|
+
var getLightChildren = Polymer.DomApi.getLightChildren;
|
1715
|
+
var matchesSelector = Polymer.DomApi.matchesSelector;
|
1716
|
+
var hasInsertionPoint = Polymer.DomApi.hasInsertionPoint;
|
1717
|
+
var getComposedChildren = Polymer.DomApi.getComposedChildren;
|
1718
|
+
var getComposedParent = Polymer.DomApi.getComposedParent;
|
1719
|
+
var removeFromComposedParent = Polymer.DomApi.removeFromComposedParent;
|
1720
|
+
function distributeNodeInto(child, insertionPoint) {
|
1721
|
+
insertionPoint._distributedNodes.push(child);
|
1722
|
+
var points = child._destinationInsertionPoints;
|
1723
|
+
if (!points) {
|
1724
|
+
child._destinationInsertionPoints = [insertionPoint];
|
1725
|
+
} else {
|
1726
|
+
points.push(insertionPoint);
|
1727
|
+
}
|
1728
|
+
}
|
1729
|
+
function clearDistributedDestinationInsertionPoints(content) {
|
1730
|
+
var e$ = content._distributedNodes;
|
1731
|
+
if (e$) {
|
1732
|
+
for (var i = 0; i < e$.length; i++) {
|
1733
|
+
var d = e$[i]._destinationInsertionPoints;
|
1734
|
+
if (d) {
|
1735
|
+
d.splice(d.indexOf(content) + 1, d.length);
|
1736
|
+
}
|
1737
|
+
}
|
1738
|
+
}
|
1739
|
+
}
|
1740
|
+
function maybeRedistributeParent(content, host) {
|
1741
|
+
var parent = content._lightParent;
|
1742
|
+
if (parent && parent.shadyRoot && hasInsertionPoint(parent.shadyRoot) && parent.shadyRoot._distributionClean) {
|
1743
|
+
parent.shadyRoot._distributionClean = false;
|
1744
|
+
host.shadyRoot._dirtyRoots.push(parent);
|
1745
|
+
}
|
1746
|
+
}
|
1747
|
+
function isFinalDestination(insertionPoint, node) {
|
1748
|
+
var points = node._destinationInsertionPoints;
|
1749
|
+
return points && points[points.length - 1] === insertionPoint;
|
1750
|
+
}
|
1751
|
+
function isInsertionPoint(node) {
|
1752
|
+
return node.localName == 'content';
|
1753
|
+
}
|
1754
|
+
var nativeInsertBefore = Element.prototype.insertBefore;
|
1755
|
+
var nativeRemoveChild = Element.prototype.removeChild;
|
1756
|
+
function insertBefore(parentNode, newChild, refChild) {
|
1757
|
+
var newChildParent = getComposedParent(newChild);
|
1758
|
+
if (newChildParent !== parentNode) {
|
1759
|
+
removeFromComposedParent(newChildParent, newChild);
|
1760
|
+
}
|
1761
|
+
remove(newChild);
|
1762
|
+
nativeInsertBefore.call(parentNode, newChild, refChild || null);
|
1763
|
+
newChild._composedParent = parentNode;
|
1764
|
+
}
|
1765
|
+
function remove(node) {
|
1766
|
+
var parentNode = getComposedParent(node);
|
1767
|
+
if (parentNode) {
|
1768
|
+
node._composedParent = null;
|
1769
|
+
nativeRemoveChild.call(parentNode, node);
|
1770
|
+
}
|
1771
|
+
}
|
1772
|
+
function ensureComposedParent(parent, children) {
|
1773
|
+
for (var i = 0, n; i < children.length; i++) {
|
1774
|
+
children[i]._composedParent = parent;
|
1775
|
+
}
|
1776
|
+
}
|
1777
|
+
function getTopDistributingHost(host) {
|
1778
|
+
while (host && hostNeedsRedistribution(host)) {
|
1779
|
+
host = host.domHost;
|
1780
|
+
}
|
1781
|
+
return host;
|
1782
|
+
}
|
1783
|
+
function hostNeedsRedistribution(host) {
|
1784
|
+
var c$ = Polymer.dom(host).children;
|
1785
|
+
for (var i = 0, c; i < c$.length; i++) {
|
1786
|
+
c = c$[i];
|
1787
|
+
if (c.localName === 'content') {
|
1788
|
+
return host.domHost;
|
1789
|
+
}
|
1790
|
+
}
|
1791
|
+
}
|
1792
|
+
function notifyContentObservers(root) {
|
1793
|
+
for (var i = 0, c; i < root._insertionPoints.length; i++) {
|
1794
|
+
c = root._insertionPoints[i];
|
1795
|
+
if (hasDomApi(c)) {
|
1796
|
+
Polymer.dom(c).notifyObserver();
|
1797
|
+
}
|
1798
|
+
}
|
1799
|
+
}
|
1800
|
+
function notifyInitialDistribution(host) {
|
1801
|
+
if (hasDomApi(host)) {
|
1802
|
+
Polymer.dom(host).notifyObserver();
|
1803
|
+
}
|
1804
|
+
}
|
1805
|
+
var needsUpgrade = window.CustomElements && !CustomElements.useNative;
|
1806
|
+
function upgradeLightChildren(children) {
|
1807
|
+
if (needsUpgrade && children) {
|
1808
|
+
for (var i = 0; i < children.length; i++) {
|
1809
|
+
CustomElements.upgrade(children[i]);
|
1810
|
+
}
|
1811
|
+
}
|
1812
|
+
}
|
1813
|
+
}());
|
1814
|
+
if (Polymer.Settings.useShadow) {
|
1815
|
+
Polymer.Base._addFeature({
|
1816
|
+
_poolContent: function () {
|
1817
|
+
},
|
1818
|
+
_beginDistribute: function () {
|
1819
|
+
},
|
1820
|
+
distributeContent: function () {
|
1821
|
+
},
|
1822
|
+
_distributeContent: function () {
|
1823
|
+
},
|
1824
|
+
_finishDistribute: function () {
|
1825
|
+
},
|
1826
|
+
_createLocalRoot: function () {
|
1827
|
+
this.createShadowRoot();
|
1828
|
+
this.shadowRoot.appendChild(this.root);
|
1829
|
+
this.root = this.shadowRoot;
|
1830
|
+
}
|
1831
|
+
});
|
1832
|
+
}
|
1833
|
+
Polymer.DomModule = document.createElement('dom-module');
|
1834
|
+
Polymer.Base._addFeature({
|
1835
|
+
_registerFeatures: function () {
|
1836
|
+
this._prepIs();
|
1837
|
+
this._prepAttributes();
|
1838
|
+
this._prepBehaviors();
|
1839
|
+
this._prepConstructor();
|
1840
|
+
this._prepTemplate();
|
1841
|
+
this._prepShady();
|
1842
|
+
},
|
1843
|
+
_prepBehavior: function (b) {
|
1844
|
+
this._addHostAttributes(b.hostAttributes);
|
1845
|
+
},
|
1846
|
+
_initFeatures: function () {
|
1847
|
+
this._poolContent();
|
1848
|
+
this._pushHost();
|
1849
|
+
this._stampTemplate();
|
1850
|
+
this._popHost();
|
1851
|
+
this._marshalHostAttributes();
|
1852
|
+
this._setupDebouncers();
|
1853
|
+
this._marshalBehaviors();
|
1854
|
+
this._tryReady();
|
1855
|
+
},
|
1856
|
+
_marshalBehavior: function (b) {
|
1857
|
+
}
|
1858
|
+
});</script>
|
1859
|
+
|