polymer-rails 1.0.0 → 1.0.3
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/polymer-micro.html +135 -156
- data/app/assets/javascripts/polymer/polymer-mini.html +266 -221
- data/app/assets/javascripts/polymer/polymer.html +780 -791
- data/app/assets/javascripts/webcomponentsjs/webcomponents-lite.js +18 -18
- data/app/assets/javascripts/webcomponentsjs/webcomponents.js +28 -22
- data/lib/polymer-rails/component.rb +18 -4
- data/lib/polymer-rails/processors/components_processor.rb +1 -1
- data/lib/polymer-rails/version.rb +1 -1
- metadata +2 -2
@@ -9,67 +9,67 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|
9
9
|
--><link rel="import" href="polymer-micro.html">
|
10
10
|
|
11
11
|
<script>Polymer.Base._addFeature({
|
12
|
-
_prepTemplate: function() {
|
13
|
-
this._template = this._template || Polymer.DomModule.import(this.is,
|
12
|
+
_prepTemplate: function () {
|
13
|
+
this._template = this._template || Polymer.DomModule.import(this.is, 'template');
|
14
14
|
if (!this._template) {
|
15
15
|
var script = document._currentScript || document.currentScript;
|
16
16
|
var prev = script && script.previousElementSibling;
|
17
|
-
if (prev && prev.localName ===
|
17
|
+
if (prev && prev.localName === 'template') {
|
18
18
|
this._template = prev;
|
19
19
|
}
|
20
20
|
}
|
21
|
-
if (this._template && this._template.hasAttribute(
|
22
|
-
this._warn(this._logf(
|
21
|
+
if (this._template && this._template.hasAttribute('is')) {
|
22
|
+
this._warn(this._logf('_prepTemplate', 'top-level Polymer template ' + 'must not be a type-extension, found', this._template, 'Move inside simple <template>.'));
|
23
23
|
}
|
24
24
|
},
|
25
|
-
_stampTemplate: function() {
|
25
|
+
_stampTemplate: function () {
|
26
26
|
if (this._template) {
|
27
27
|
this.root = this.instanceTemplate(this._template);
|
28
28
|
}
|
29
29
|
},
|
30
|
-
instanceTemplate: function(template) {
|
30
|
+
instanceTemplate: function (template) {
|
31
31
|
var dom = document.importNode(template._content || template.content, true);
|
32
32
|
return dom;
|
33
33
|
}
|
34
34
|
});
|
35
|
-
|
36
|
-
(function() {
|
35
|
+
(function () {
|
37
36
|
var baseAttachedCallback = Polymer.Base.attachedCallback;
|
38
37
|
Polymer.Base._addFeature({
|
39
38
|
_hostStack: [],
|
40
|
-
ready: function() {
|
41
|
-
|
39
|
+
ready: function () {
|
40
|
+
},
|
41
|
+
_pushHost: function (host) {
|
42
42
|
this.dataHost = host = host || Polymer.Base._hostStack[Polymer.Base._hostStack.length - 1];
|
43
43
|
if (host && host._clients) {
|
44
44
|
host._clients.push(this);
|
45
45
|
}
|
46
46
|
this._beginHost();
|
47
47
|
},
|
48
|
-
_beginHost: function() {
|
48
|
+
_beginHost: function () {
|
49
49
|
Polymer.Base._hostStack.push(this);
|
50
50
|
if (!this._clients) {
|
51
51
|
this._clients = [];
|
52
52
|
}
|
53
53
|
},
|
54
|
-
_popHost: function() {
|
54
|
+
_popHost: function () {
|
55
55
|
Polymer.Base._hostStack.pop();
|
56
56
|
},
|
57
|
-
_tryReady: function() {
|
57
|
+
_tryReady: function () {
|
58
58
|
if (this._canReady()) {
|
59
59
|
this._ready();
|
60
60
|
}
|
61
61
|
},
|
62
|
-
_canReady: function() {
|
62
|
+
_canReady: function () {
|
63
63
|
return !this.dataHost || this.dataHost._clientsReadied;
|
64
64
|
},
|
65
|
-
_ready: function() {
|
65
|
+
_ready: function () {
|
66
66
|
this._beforeClientsReady();
|
67
67
|
this._setupRoot();
|
68
68
|
this._readyClients();
|
69
69
|
this._afterClientsReady();
|
70
70
|
this._readySelf();
|
71
71
|
},
|
72
|
-
_readyClients: function() {
|
72
|
+
_readyClients: function () {
|
73
73
|
this._beginDistribute();
|
74
74
|
var c$ = this._clients;
|
75
75
|
for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
|
@@ -79,18 +79,21 @@ this._finishDistribute();
|
|
79
79
|
this._clientsReadied = true;
|
80
80
|
this._clients = null;
|
81
81
|
},
|
82
|
-
_readySelf: function() {
|
83
|
-
this._doBehavior(
|
82
|
+
_readySelf: function () {
|
83
|
+
this._doBehavior('ready');
|
84
84
|
this._readied = true;
|
85
85
|
if (this._attachedPending) {
|
86
86
|
this._attachedPending = false;
|
87
87
|
this.attachedCallback();
|
88
88
|
}
|
89
89
|
},
|
90
|
-
_beforeClientsReady: function() {
|
91
|
-
|
92
|
-
|
93
|
-
|
90
|
+
_beforeClientsReady: function () {
|
91
|
+
},
|
92
|
+
_afterClientsReady: function () {
|
93
|
+
},
|
94
|
+
_beforeAttached: function () {
|
95
|
+
},
|
96
|
+
attachedCallback: function () {
|
94
97
|
if (this._readied) {
|
95
98
|
this._beforeAttached();
|
96
99
|
baseAttachedCallback.call(this);
|
@@ -99,9 +102,8 @@ this._attachedPending = true;
|
|
99
102
|
}
|
100
103
|
}
|
101
104
|
});
|
102
|
-
}
|
103
|
-
|
104
|
-
Polymer.ArraySplice = function() {
|
105
|
+
}());
|
106
|
+
Polymer.ArraySplice = function () {
|
105
107
|
function newSplice(index, removed, addedCount) {
|
106
108
|
return {
|
107
109
|
index: index,
|
@@ -113,9 +115,10 @@ var EDIT_LEAVE = 0;
|
|
113
115
|
var EDIT_UPDATE = 1;
|
114
116
|
var EDIT_ADD = 2;
|
115
117
|
var EDIT_DELETE = 3;
|
116
|
-
function ArraySplice() {
|
118
|
+
function ArraySplice() {
|
119
|
+
}
|
117
120
|
ArraySplice.prototype = {
|
118
|
-
calcEditDistances: function(current, currentStart, currentEnd, old, oldStart, oldEnd) {
|
121
|
+
calcEditDistances: function (current, currentStart, currentEnd, old, oldStart, oldEnd) {
|
119
122
|
var rowCount = oldEnd - oldStart + 1;
|
120
123
|
var columnCount = currentEnd - currentStart + 1;
|
121
124
|
var distances = new Array(rowCount);
|
@@ -123,10 +126,13 @@ for (var i = 0; i < rowCount; i++) {
|
|
123
126
|
distances[i] = new Array(columnCount);
|
124
127
|
distances[i][0] = i;
|
125
128
|
}
|
126
|
-
for (var j = 0; j < columnCount; j++)
|
129
|
+
for (var j = 0; j < columnCount; j++)
|
130
|
+
distances[0][j] = j;
|
127
131
|
for (var i = 1; i < rowCount; i++) {
|
128
132
|
for (var j = 1; j < columnCount; j++) {
|
129
|
-
if (this.equals(current[currentStart + j - 1], old[oldStart + i - 1]))
|
133
|
+
if (this.equals(current[currentStart + j - 1], old[oldStart + i - 1]))
|
134
|
+
distances[i][j] = distances[i - 1][j - 1];
|
135
|
+
else {
|
130
136
|
var north = distances[i - 1][j] + 1;
|
131
137
|
var west = distances[i][j - 1] + 1;
|
132
138
|
distances[i][j] = north < west ? north : west;
|
@@ -135,7 +141,7 @@ distances[i][j] = north < west ? north : west;
|
|
135
141
|
}
|
136
142
|
return distances;
|
137
143
|
},
|
138
|
-
spliceOperationsFromEditDistances: function(distances) {
|
144
|
+
spliceOperationsFromEditDistances: function (distances) {
|
139
145
|
var i = distances.length - 1;
|
140
146
|
var j = distances[0].length - 1;
|
141
147
|
var current = distances[i][j];
|
@@ -155,7 +161,10 @@ var northWest = distances[i - 1][j - 1];
|
|
155
161
|
var west = distances[i - 1][j];
|
156
162
|
var north = distances[i][j - 1];
|
157
163
|
var min;
|
158
|
-
if (west < north)
|
164
|
+
if (west < north)
|
165
|
+
min = west < northWest ? west : northWest;
|
166
|
+
else
|
167
|
+
min = north < northWest ? north : northWest;
|
159
168
|
if (min == northWest) {
|
160
169
|
if (northWest == current) {
|
161
170
|
edits.push(EDIT_LEAVE);
|
@@ -178,22 +187,27 @@ current = north;
|
|
178
187
|
edits.reverse();
|
179
188
|
return edits;
|
180
189
|
},
|
181
|
-
calcSplices: function(current, currentStart, currentEnd, old, oldStart, oldEnd) {
|
190
|
+
calcSplices: function (current, currentStart, currentEnd, old, oldStart, oldEnd) {
|
182
191
|
var prefixCount = 0;
|
183
192
|
var suffixCount = 0;
|
184
193
|
var minLength = Math.min(currentEnd - currentStart, oldEnd - oldStart);
|
185
|
-
if (currentStart == 0 && oldStart == 0)
|
186
|
-
|
194
|
+
if (currentStart == 0 && oldStart == 0)
|
195
|
+
prefixCount = this.sharedPrefix(current, old, minLength);
|
196
|
+
if (currentEnd == current.length && oldEnd == old.length)
|
197
|
+
suffixCount = this.sharedSuffix(current, old, minLength - prefixCount);
|
187
198
|
currentStart += prefixCount;
|
188
199
|
oldStart += prefixCount;
|
189
200
|
currentEnd -= suffixCount;
|
190
201
|
oldEnd -= suffixCount;
|
191
|
-
if (currentEnd - currentStart == 0 && oldEnd - oldStart == 0)
|
202
|
+
if (currentEnd - currentStart == 0 && oldEnd - oldStart == 0)
|
203
|
+
return [];
|
192
204
|
if (currentStart == currentEnd) {
|
193
205
|
var splice = newSplice(currentStart, [], 0);
|
194
|
-
while (oldStart < oldEnd)
|
195
|
-
|
196
|
-
|
206
|
+
while (oldStart < oldEnd)
|
207
|
+
splice.removed.push(old[oldStart++]);
|
208
|
+
return [splice];
|
209
|
+
} else if (oldStart == oldEnd)
|
210
|
+
return [newSplice(currentStart, [], currentEnd - currentStart)];
|
197
211
|
var ops = this.spliceOperationsFromEditDistances(this.calcEditDistances(current, currentStart, currentEnd, old, oldStart, oldEnd));
|
198
212
|
var splice = undefined;
|
199
213
|
var splices = [];
|
@@ -209,23 +223,23 @@ splice = undefined;
|
|
209
223
|
index++;
|
210
224
|
oldIndex++;
|
211
225
|
break;
|
212
|
-
|
213
226
|
case EDIT_UPDATE:
|
214
|
-
if (!splice)
|
227
|
+
if (!splice)
|
228
|
+
splice = newSplice(index, [], 0);
|
215
229
|
splice.addedCount++;
|
216
230
|
index++;
|
217
231
|
splice.removed.push(old[oldIndex]);
|
218
232
|
oldIndex++;
|
219
233
|
break;
|
220
|
-
|
221
234
|
case EDIT_ADD:
|
222
|
-
if (!splice)
|
235
|
+
if (!splice)
|
236
|
+
splice = newSplice(index, [], 0);
|
223
237
|
splice.addedCount++;
|
224
238
|
index++;
|
225
239
|
break;
|
226
|
-
|
227
240
|
case EDIT_DELETE:
|
228
|
-
if (!splice)
|
241
|
+
if (!splice)
|
242
|
+
splice = newSplice(index, [], 0);
|
229
243
|
splice.removed.push(old[oldIndex]);
|
230
244
|
oldIndex++;
|
231
245
|
break;
|
@@ -236,30 +250,32 @@ splices.push(splice);
|
|
236
250
|
}
|
237
251
|
return splices;
|
238
252
|
},
|
239
|
-
sharedPrefix: function(current, old, searchLength) {
|
240
|
-
for (var i = 0; i < searchLength; i++)
|
253
|
+
sharedPrefix: function (current, old, searchLength) {
|
254
|
+
for (var i = 0; i < searchLength; i++)
|
255
|
+
if (!this.equals(current[i], old[i]))
|
256
|
+
return i;
|
241
257
|
return searchLength;
|
242
258
|
},
|
243
|
-
sharedSuffix: function(current, old, searchLength) {
|
259
|
+
sharedSuffix: function (current, old, searchLength) {
|
244
260
|
var index1 = current.length;
|
245
261
|
var index2 = old.length;
|
246
262
|
var count = 0;
|
247
|
-
while (count < searchLength && this.equals(current[--index1], old[--index2]))
|
263
|
+
while (count < searchLength && this.equals(current[--index1], old[--index2]))
|
264
|
+
count++;
|
248
265
|
return count;
|
249
266
|
},
|
250
|
-
calculateSplices: function(current, previous) {
|
267
|
+
calculateSplices: function (current, previous) {
|
251
268
|
return this.calcSplices(current, 0, current.length, previous, 0, previous.length);
|
252
269
|
},
|
253
|
-
equals: function(currentValue, previousValue) {
|
270
|
+
equals: function (currentValue, previousValue) {
|
254
271
|
return currentValue === previousValue;
|
255
272
|
}
|
256
273
|
};
|
257
274
|
return new ArraySplice();
|
258
275
|
}();
|
259
|
-
|
260
|
-
Polymer.EventApi = function() {
|
276
|
+
Polymer.EventApi = function () {
|
261
277
|
var Settings = Polymer.Settings;
|
262
|
-
var EventApi = function(event) {
|
278
|
+
var EventApi = function (event) {
|
263
279
|
this.event = event;
|
264
280
|
};
|
265
281
|
if (Settings.useShadow) {
|
@@ -304,36 +320,29 @@ return this.event._path;
|
|
304
320
|
}
|
305
321
|
};
|
306
322
|
}
|
307
|
-
var factory = function(event) {
|
323
|
+
var factory = function (event) {
|
308
324
|
if (!event.__eventApi) {
|
309
325
|
event.__eventApi = new EventApi(event);
|
310
326
|
}
|
311
327
|
return event.__eventApi;
|
312
328
|
};
|
313
|
-
return {
|
314
|
-
factory: factory
|
315
|
-
};
|
329
|
+
return { factory: factory };
|
316
330
|
}();
|
317
|
-
|
318
|
-
Polymer.domInnerHTML = function() {
|
331
|
+
Polymer.domInnerHTML = function () {
|
319
332
|
var escapeAttrRegExp = /[&\u00A0"]/g;
|
320
333
|
var escapeDataRegExp = /[&\u00A0<>]/g;
|
321
334
|
function escapeReplace(c) {
|
322
335
|
switch (c) {
|
323
|
-
case
|
324
|
-
return
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
case ">":
|
330
|
-
return ">";
|
331
|
-
|
336
|
+
case '&':
|
337
|
+
return '&';
|
338
|
+
case '<':
|
339
|
+
return '<';
|
340
|
+
case '>':
|
341
|
+
return '>';
|
332
342
|
case '"':
|
333
|
-
return
|
334
|
-
|
335
|
-
|
336
|
-
return " ";
|
343
|
+
return '"';
|
344
|
+
case '\xA0':
|
345
|
+
return ' ';
|
337
346
|
}
|
338
347
|
}
|
339
348
|
function escapeAttr(s) {
|
@@ -349,41 +358,65 @@ set[arr[i]] = true;
|
|
349
358
|
}
|
350
359
|
return set;
|
351
360
|
}
|
352
|
-
var voidElements = makeSet([
|
353
|
-
|
361
|
+
var voidElements = makeSet([
|
362
|
+
'area',
|
363
|
+
'base',
|
364
|
+
'br',
|
365
|
+
'col',
|
366
|
+
'command',
|
367
|
+
'embed',
|
368
|
+
'hr',
|
369
|
+
'img',
|
370
|
+
'input',
|
371
|
+
'keygen',
|
372
|
+
'link',
|
373
|
+
'meta',
|
374
|
+
'param',
|
375
|
+
'source',
|
376
|
+
'track',
|
377
|
+
'wbr'
|
378
|
+
]);
|
379
|
+
var plaintextParents = makeSet([
|
380
|
+
'style',
|
381
|
+
'script',
|
382
|
+
'xmp',
|
383
|
+
'iframe',
|
384
|
+
'noembed',
|
385
|
+
'noframes',
|
386
|
+
'plaintext',
|
387
|
+
'noscript'
|
388
|
+
]);
|
354
389
|
function getOuterHTML(node, parentNode, composed) {
|
355
390
|
switch (node.nodeType) {
|
356
391
|
case Node.ELEMENT_NODE:
|
357
392
|
var tagName = node.localName;
|
358
|
-
var s =
|
393
|
+
var s = '<' + tagName;
|
359
394
|
var attrs = node.attributes;
|
360
395
|
for (var i = 0, attr; attr = attrs[i]; i++) {
|
361
|
-
s +=
|
396
|
+
s += ' ' + attr.name + '="' + escapeAttr(attr.value) + '"';
|
362
397
|
}
|
363
|
-
s +=
|
398
|
+
s += '>';
|
364
399
|
if (voidElements[tagName]) {
|
365
400
|
return s;
|
366
401
|
}
|
367
|
-
return s + getInnerHTML(node, composed) +
|
368
|
-
|
402
|
+
return s + getInnerHTML(node, composed) + '</' + tagName + '>';
|
369
403
|
case Node.TEXT_NODE:
|
370
404
|
var data = node.data;
|
371
405
|
if (parentNode && plaintextParents[parentNode.localName]) {
|
372
406
|
return data;
|
373
407
|
}
|
374
408
|
return escapeData(data);
|
375
|
-
|
376
409
|
case Node.COMMENT_NODE:
|
377
|
-
return
|
378
|
-
|
410
|
+
return '<!--' + node.data + '-->';
|
379
411
|
default:
|
380
412
|
console.error(node);
|
381
|
-
throw new Error(
|
413
|
+
throw new Error('not implemented');
|
382
414
|
}
|
383
415
|
}
|
384
416
|
function getInnerHTML(node, composed) {
|
385
|
-
if (node instanceof HTMLTemplateElement)
|
386
|
-
|
417
|
+
if (node instanceof HTMLTemplateElement)
|
418
|
+
node = node.content;
|
419
|
+
var s = '';
|
387
420
|
var c$ = Polymer.dom(node).childNodes;
|
388
421
|
c$ = composed ? node._composedChildren : c$;
|
389
422
|
for (var i = 0, l = c$.length, child; i < l && (child = c$[i]); i++) {
|
@@ -391,41 +424,38 @@ s += getOuterHTML(child, node, composed);
|
|
391
424
|
}
|
392
425
|
return s;
|
393
426
|
}
|
394
|
-
return {
|
395
|
-
getInnerHTML: getInnerHTML
|
396
|
-
};
|
427
|
+
return { getInnerHTML: getInnerHTML };
|
397
428
|
}();
|
398
|
-
|
399
|
-
|
400
|
-
"use strict";
|
429
|
+
Polymer.DomApi = function () {
|
430
|
+
'use strict';
|
401
431
|
var Settings = Polymer.Settings;
|
402
432
|
var getInnerHTML = Polymer.domInnerHTML.getInnerHTML;
|
403
433
|
var nativeInsertBefore = Element.prototype.insertBefore;
|
404
434
|
var nativeRemoveChild = Element.prototype.removeChild;
|
405
435
|
var nativeAppendChild = Element.prototype.appendChild;
|
406
436
|
var dirtyRoots = [];
|
407
|
-
var DomApi = function(node) {
|
437
|
+
var DomApi = function (node) {
|
408
438
|
this.node = node;
|
409
439
|
if (this.patch) {
|
410
440
|
this.patch();
|
411
441
|
}
|
412
442
|
};
|
413
443
|
DomApi.prototype = {
|
414
|
-
flush: function() {
|
444
|
+
flush: function () {
|
415
445
|
for (var i = 0, host; i < dirtyRoots.length; i++) {
|
416
446
|
host = dirtyRoots[i];
|
417
|
-
host.flushDebouncer(
|
447
|
+
host.flushDebouncer('_distribute');
|
418
448
|
}
|
419
449
|
dirtyRoots = [];
|
420
450
|
},
|
421
|
-
_lazyDistribute: function(host) {
|
451
|
+
_lazyDistribute: function (host) {
|
422
452
|
if (host.shadyRoot && host.shadyRoot._distributionClean) {
|
423
453
|
host.shadyRoot._distributionClean = false;
|
424
|
-
host.debounce(
|
454
|
+
host.debounce('_distribute', host._distributeContent);
|
425
455
|
dirtyRoots.push(host);
|
426
456
|
}
|
427
457
|
},
|
428
|
-
appendChild: function(node) {
|
458
|
+
appendChild: function (node) {
|
429
459
|
var distributed;
|
430
460
|
this._removeNodeFromHost(node);
|
431
461
|
if (this._nodeIsInLogicalTree(this.node)) {
|
@@ -443,7 +473,7 @@ addToComposedParent(container, node);
|
|
443
473
|
}
|
444
474
|
return node;
|
445
475
|
},
|
446
|
-
insertBefore: function(node, ref_node) {
|
476
|
+
insertBefore: function (node, ref_node) {
|
447
477
|
if (!ref_node) {
|
448
478
|
return this.appendChild(node);
|
449
479
|
}
|
@@ -454,7 +484,7 @@ saveLightChildrenIfNeeded(this.node);
|
|
454
484
|
var children = this.childNodes;
|
455
485
|
var index = children.indexOf(ref_node);
|
456
486
|
if (index < 0) {
|
457
|
-
throw Error(
|
487
|
+
throw Error('The ref_node to be inserted before is not a child ' + 'of this node');
|
458
488
|
}
|
459
489
|
var host = this._hostForNode(this.node);
|
460
490
|
this._addLogicalInfo(node, this.node, host && host.shadyRoot, index);
|
@@ -471,9 +501,9 @@ addToComposedParent(container, node, ref_node);
|
|
471
501
|
}
|
472
502
|
return node;
|
473
503
|
},
|
474
|
-
removeChild: function(node) {
|
504
|
+
removeChild: function (node) {
|
475
505
|
if (factory(node).parentNode !== this.node) {
|
476
|
-
console.warn(
|
506
|
+
console.warn('The node to be removed is not a child of this node', node);
|
477
507
|
}
|
478
508
|
var distributed;
|
479
509
|
if (this._nodeIsInLogicalTree(this.node)) {
|
@@ -490,15 +520,15 @@ removeFromComposedParent(container, node);
|
|
490
520
|
}
|
491
521
|
return node;
|
492
522
|
},
|
493
|
-
replaceChild: function(node, ref_node) {
|
523
|
+
replaceChild: function (node, ref_node) {
|
494
524
|
this.insertBefore(node, ref_node);
|
495
525
|
this.removeChild(ref_node);
|
496
526
|
return node;
|
497
527
|
},
|
498
|
-
getOwnerRoot: function() {
|
528
|
+
getOwnerRoot: function () {
|
499
529
|
return this._ownerShadyRootForNode(this.node);
|
500
530
|
},
|
501
|
-
_ownerShadyRootForNode: function(node) {
|
531
|
+
_ownerShadyRootForNode: function (node) {
|
502
532
|
if (!node) {
|
503
533
|
return;
|
504
534
|
}
|
@@ -518,7 +548,7 @@ node._ownerShadyRoot = root;
|
|
518
548
|
}
|
519
549
|
return node._ownerShadyRoot;
|
520
550
|
},
|
521
|
-
_maybeDistribute: function(node, parent, host) {
|
551
|
+
_maybeDistribute: function (node, parent, host) {
|
522
552
|
var nodeNeedsDistribute = this._nodeNeedsDistribution(node);
|
523
553
|
var distribute = this._parentNeedsDistribution(parent) || nodeNeedsDistribute;
|
524
554
|
if (nodeNeedsDistribute) {
|
@@ -529,7 +559,7 @@ this._lazyDistribute(host);
|
|
529
559
|
}
|
530
560
|
return distribute;
|
531
561
|
},
|
532
|
-
_tryRemoveUndistributedNode: function(node) {
|
562
|
+
_tryRemoveUndistributedNode: function (node) {
|
533
563
|
if (this.node.shadyRoot) {
|
534
564
|
if (node.parentNode) {
|
535
565
|
nativeRemoveChild.call(node.parentNode, node);
|
@@ -537,23 +567,23 @@ nativeRemoveChild.call(node.parentNode, node);
|
|
537
567
|
return true;
|
538
568
|
}
|
539
569
|
},
|
540
|
-
_updateInsertionPoints: function(host) {
|
570
|
+
_updateInsertionPoints: function (host) {
|
541
571
|
host.shadyRoot._insertionPoints = factory(host.shadyRoot).querySelectorAll(CONTENT);
|
542
572
|
},
|
543
|
-
_nodeIsInLogicalTree: function(node) {
|
573
|
+
_nodeIsInLogicalTree: function (node) {
|
544
574
|
return Boolean(node._lightParent || node._isShadyRoot || this._ownerShadyRootForNode(node) || node.shadyRoot);
|
545
575
|
},
|
546
|
-
_hostForNode: function(node) {
|
576
|
+
_hostForNode: function (node) {
|
547
577
|
var root = node.shadyRoot || (node._isShadyRoot ? node : this._ownerShadyRootForNode(node));
|
548
578
|
return root && root.host;
|
549
579
|
},
|
550
|
-
_parentNeedsDistribution: function(parent) {
|
580
|
+
_parentNeedsDistribution: function (parent) {
|
551
581
|
return parent && parent.shadyRoot && hasInsertionPoint(parent.shadyRoot);
|
552
582
|
},
|
553
|
-
_nodeNeedsDistribution: function(node) {
|
583
|
+
_nodeNeedsDistribution: function (node) {
|
554
584
|
return node.localName === CONTENT || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && node.querySelector(CONTENT);
|
555
585
|
},
|
556
|
-
_removeNodeFromHost: function(node) {
|
586
|
+
_removeNodeFromHost: function (node) {
|
557
587
|
if (node._lightParent) {
|
558
588
|
var root = this._ownerShadyRootForNode(node);
|
559
589
|
if (root) {
|
@@ -563,14 +593,14 @@ this._removeLogicalInfo(node, node._lightParent);
|
|
563
593
|
}
|
564
594
|
this._removeOwnerShadyRoot(node);
|
565
595
|
},
|
566
|
-
_addNodeToHost: function(node) {
|
596
|
+
_addNodeToHost: function (node) {
|
567
597
|
var checkNode = node.nodeType === Node.DOCUMENT_FRAGMENT_NODE ? node.firstChild : node;
|
568
598
|
var root = this._ownerShadyRootForNode(checkNode);
|
569
599
|
if (root) {
|
570
600
|
root.host._elementAdd(node);
|
571
601
|
}
|
572
602
|
},
|
573
|
-
_addLogicalInfo: function(node, container, root, index) {
|
603
|
+
_addLogicalInfo: function (node, container, root, index) {
|
574
604
|
saveLightChildrenIfNeeded(container);
|
575
605
|
var children = factory(container).childNodes;
|
576
606
|
index = index === undefined ? children.length : index;
|
@@ -585,16 +615,16 @@ children.splice(index, 0, node);
|
|
585
615
|
node._lightParent = container;
|
586
616
|
}
|
587
617
|
},
|
588
|
-
_removeLogicalInfo: function(node, container) {
|
618
|
+
_removeLogicalInfo: function (node, container) {
|
589
619
|
var children = factory(container).childNodes;
|
590
620
|
var index = children.indexOf(node);
|
591
621
|
if (index < 0 || container !== node._lightParent) {
|
592
|
-
throw Error(
|
622
|
+
throw Error('The node to be removed is not a child of this node');
|
593
623
|
}
|
594
624
|
children.splice(index, 1);
|
595
625
|
node._lightParent = null;
|
596
626
|
},
|
597
|
-
_removeOwnerShadyRoot: function(node) {
|
627
|
+
_removeOwnerShadyRoot: function (node) {
|
598
628
|
var hasCachedRoot = factory(node).getOwnerRoot() !== undefined;
|
599
629
|
if (hasCachedRoot) {
|
600
630
|
var c$ = factory(node).childNodes;
|
@@ -604,7 +634,7 @@ this._removeOwnerShadyRoot(n);
|
|
604
634
|
}
|
605
635
|
node._ownerShadyRoot = undefined;
|
606
636
|
},
|
607
|
-
_firstComposedNode: function(content) {
|
637
|
+
_firstComposedNode: function (content) {
|
608
638
|
var n$ = factory(content).getDistributedNodes();
|
609
639
|
for (var i = 0, l = n$.length, n, p$; i < l && (n = n$[i]); i++) {
|
610
640
|
p$ = factory(n).getDestinationInsertionPoints();
|
@@ -613,40 +643,40 @@ return n;
|
|
613
643
|
}
|
614
644
|
}
|
615
645
|
},
|
616
|
-
querySelector: function(selector) {
|
646
|
+
querySelector: function (selector) {
|
617
647
|
return this.querySelectorAll(selector)[0];
|
618
648
|
},
|
619
|
-
querySelectorAll: function(selector) {
|
620
|
-
return this._query(function(n) {
|
649
|
+
querySelectorAll: function (selector) {
|
650
|
+
return this._query(function (n) {
|
621
651
|
return matchesSelector.call(n, selector);
|
622
652
|
}, this.node);
|
623
653
|
},
|
624
|
-
_query: function(matcher, node) {
|
654
|
+
_query: function (matcher, node) {
|
625
655
|
node = node || this.node;
|
626
656
|
var list = [];
|
627
657
|
this._queryElements(factory(node).childNodes, matcher, list);
|
628
658
|
return list;
|
629
659
|
},
|
630
|
-
_queryElements: function(elements, matcher, list) {
|
660
|
+
_queryElements: function (elements, matcher, list) {
|
631
661
|
for (var i = 0, l = elements.length, c; i < l && (c = elements[i]); i++) {
|
632
662
|
if (c.nodeType === Node.ELEMENT_NODE) {
|
633
663
|
this._queryElement(c, matcher, list);
|
634
664
|
}
|
635
665
|
}
|
636
666
|
},
|
637
|
-
_queryElement: function(node, matcher, list) {
|
667
|
+
_queryElement: function (node, matcher, list) {
|
638
668
|
if (matcher(node)) {
|
639
669
|
list.push(node);
|
640
670
|
}
|
641
671
|
this._queryElements(factory(node).childNodes, matcher, list);
|
642
672
|
},
|
643
|
-
getDestinationInsertionPoints: function() {
|
673
|
+
getDestinationInsertionPoints: function () {
|
644
674
|
return this.node._destinationInsertionPoints || [];
|
645
675
|
},
|
646
|
-
getDistributedNodes: function() {
|
676
|
+
getDistributedNodes: function () {
|
647
677
|
return this.node._distributedNodes || [];
|
648
678
|
},
|
649
|
-
queryDistributedElements: function(selector) {
|
679
|
+
queryDistributedElements: function (selector) {
|
650
680
|
var c$ = this.childNodes;
|
651
681
|
var list = [];
|
652
682
|
this._distributedFilter(selector, c$, list);
|
@@ -657,7 +687,7 @@ this._distributedFilter(selector, factory(c).getDistributedNodes(), list);
|
|
657
687
|
}
|
658
688
|
return list;
|
659
689
|
},
|
660
|
-
_distributedFilter: function(selector, list, results) {
|
690
|
+
_distributedFilter: function (selector, list, results) {
|
661
691
|
results = results || [];
|
662
692
|
for (var i = 0, l = list.length, d; i < l && (d = list[i]); i++) {
|
663
693
|
if (d.nodeType === Node.ELEMENT_NODE && d.localName !== CONTENT && matchesSelector.call(d, selector)) {
|
@@ -666,27 +696,27 @@ results.push(d);
|
|
666
696
|
}
|
667
697
|
return results;
|
668
698
|
},
|
669
|
-
_clear: function() {
|
699
|
+
_clear: function () {
|
670
700
|
while (this.childNodes.length) {
|
671
701
|
this.removeChild(this.childNodes[0]);
|
672
702
|
}
|
673
703
|
},
|
674
|
-
setAttribute: function(name, value) {
|
704
|
+
setAttribute: function (name, value) {
|
675
705
|
this.node.setAttribute(name, value);
|
676
706
|
this._distributeParent();
|
677
707
|
},
|
678
|
-
removeAttribute: function(name) {
|
708
|
+
removeAttribute: function (name) {
|
679
709
|
this.node.removeAttribute(name);
|
680
710
|
this._distributeParent();
|
681
711
|
},
|
682
|
-
_distributeParent: function() {
|
712
|
+
_distributeParent: function () {
|
683
713
|
if (this._parentNeedsDistribution(this.parentNode)) {
|
684
714
|
this._lazyDistribute(this.parentNode);
|
685
715
|
}
|
686
716
|
}
|
687
717
|
};
|
688
|
-
Object.defineProperty(DomApi.prototype,
|
689
|
-
get: function() {
|
718
|
+
Object.defineProperty(DomApi.prototype, 'classList', {
|
719
|
+
get: function () {
|
690
720
|
if (!this._classList) {
|
691
721
|
this._classList = new DomApi.ClassList(this);
|
692
722
|
}
|
@@ -694,20 +724,20 @@ return this._classList;
|
|
694
724
|
},
|
695
725
|
configurable: true
|
696
726
|
});
|
697
|
-
DomApi.ClassList = function(host) {
|
727
|
+
DomApi.ClassList = function (host) {
|
698
728
|
this.domApi = host;
|
699
729
|
this.node = host.node;
|
700
730
|
};
|
701
731
|
DomApi.ClassList.prototype = {
|
702
|
-
add: function() {
|
732
|
+
add: function () {
|
703
733
|
this.node.classList.add.apply(this.node.classList, arguments);
|
704
734
|
this.domApi._distributeParent();
|
705
735
|
},
|
706
|
-
remove: function() {
|
736
|
+
remove: function () {
|
707
737
|
this.node.classList.remove.apply(this.node.classList, arguments);
|
708
738
|
this.domApi._distributeParent();
|
709
739
|
},
|
710
|
-
toggle: function() {
|
740
|
+
toggle: function () {
|
711
741
|
this.node.classList.toggle.apply(this.node.classList, arguments);
|
712
742
|
this.domApi._distributeParent();
|
713
743
|
}
|
@@ -715,41 +745,41 @@ this.domApi._distributeParent();
|
|
715
745
|
if (!Settings.useShadow) {
|
716
746
|
Object.defineProperties(DomApi.prototype, {
|
717
747
|
childNodes: {
|
718
|
-
get: function() {
|
748
|
+
get: function () {
|
719
749
|
var c$ = getLightChildren(this.node);
|
720
750
|
return Array.isArray(c$) ? c$ : Array.prototype.slice.call(c$);
|
721
751
|
},
|
722
752
|
configurable: true
|
723
753
|
},
|
724
754
|
children: {
|
725
|
-
get: function() {
|
726
|
-
return Array.prototype.filter.call(this.childNodes, function(n) {
|
755
|
+
get: function () {
|
756
|
+
return Array.prototype.filter.call(this.childNodes, function (n) {
|
727
757
|
return n.nodeType === Node.ELEMENT_NODE;
|
728
758
|
});
|
729
759
|
},
|
730
760
|
configurable: true
|
731
761
|
},
|
732
762
|
parentNode: {
|
733
|
-
get: function() {
|
763
|
+
get: function () {
|
734
764
|
return this.node._lightParent || (this.node.__patched ? this.node._composedParent : this.node.parentNode);
|
735
765
|
},
|
736
766
|
configurable: true
|
737
767
|
},
|
738
768
|
firstChild: {
|
739
|
-
get: function() {
|
769
|
+
get: function () {
|
740
770
|
return this.childNodes[0];
|
741
771
|
},
|
742
772
|
configurable: true
|
743
773
|
},
|
744
774
|
lastChild: {
|
745
|
-
get: function() {
|
775
|
+
get: function () {
|
746
776
|
var c$ = this.childNodes;
|
747
777
|
return c$[c$.length - 1];
|
748
778
|
},
|
749
779
|
configurable: true
|
750
780
|
},
|
751
781
|
nextSibling: {
|
752
|
-
get: function() {
|
782
|
+
get: function () {
|
753
783
|
var c$ = this.parentNode && factory(this.parentNode).childNodes;
|
754
784
|
if (c$) {
|
755
785
|
return c$[Array.prototype.indexOf.call(c$, this.node) + 1];
|
@@ -758,7 +788,7 @@ return c$[Array.prototype.indexOf.call(c$, this.node) + 1];
|
|
758
788
|
configurable: true
|
759
789
|
},
|
760
790
|
previousSibling: {
|
761
|
-
get: function() {
|
791
|
+
get: function () {
|
762
792
|
var c$ = this.parentNode && factory(this.parentNode).childNodes;
|
763
793
|
if (c$) {
|
764
794
|
return c$[Array.prototype.indexOf.call(c$, this.node) - 1];
|
@@ -767,20 +797,20 @@ return c$[Array.prototype.indexOf.call(c$, this.node) - 1];
|
|
767
797
|
configurable: true
|
768
798
|
},
|
769
799
|
firstElementChild: {
|
770
|
-
get: function() {
|
800
|
+
get: function () {
|
771
801
|
return this.children[0];
|
772
802
|
},
|
773
803
|
configurable: true
|
774
804
|
},
|
775
805
|
lastElementChild: {
|
776
|
-
get: function() {
|
806
|
+
get: function () {
|
777
807
|
var c$ = this.children;
|
778
808
|
return c$[c$.length - 1];
|
779
809
|
},
|
780
810
|
configurable: true
|
781
811
|
},
|
782
812
|
nextElementSibling: {
|
783
|
-
get: function() {
|
813
|
+
get: function () {
|
784
814
|
var c$ = this.parentNode && factory(this.parentNode).children;
|
785
815
|
if (c$) {
|
786
816
|
return c$[Array.prototype.indexOf.call(c$, this.node) + 1];
|
@@ -789,7 +819,7 @@ return c$[Array.prototype.indexOf.call(c$, this.node) + 1];
|
|
789
819
|
configurable: true
|
790
820
|
},
|
791
821
|
previousElementSibling: {
|
792
|
-
get: function() {
|
822
|
+
get: function () {
|
793
823
|
var c$ = this.parentNode && factory(this.parentNode).children;
|
794
824
|
if (c$) {
|
795
825
|
return c$[Array.prototype.indexOf.call(c$, this.node) - 1];
|
@@ -798,16 +828,16 @@ return c$[Array.prototype.indexOf.call(c$, this.node) - 1];
|
|
798
828
|
configurable: true
|
799
829
|
},
|
800
830
|
textContent: {
|
801
|
-
get: function() {
|
831
|
+
get: function () {
|
802
832
|
if (this.node.nodeType === Node.TEXT_NODE) {
|
803
833
|
return this.node.textContent;
|
804
834
|
} else {
|
805
|
-
return Array.prototype.map.call(this.childNodes, function(c) {
|
835
|
+
return Array.prototype.map.call(this.childNodes, function (c) {
|
806
836
|
return c.textContent;
|
807
|
-
}).join(
|
837
|
+
}).join('');
|
808
838
|
}
|
809
839
|
},
|
810
|
-
set: function(text) {
|
840
|
+
set: function (text) {
|
811
841
|
this._clear();
|
812
842
|
if (text) {
|
813
843
|
this.appendChild(document.createTextNode(text));
|
@@ -816,17 +846,17 @@ this.appendChild(document.createTextNode(text));
|
|
816
846
|
configurable: true
|
817
847
|
},
|
818
848
|
innerHTML: {
|
819
|
-
get: function() {
|
849
|
+
get: function () {
|
820
850
|
if (this.node.nodeType === Node.TEXT_NODE) {
|
821
851
|
return null;
|
822
852
|
} else {
|
823
853
|
return getInnerHTML(this.node);
|
824
854
|
}
|
825
855
|
},
|
826
|
-
set: function(text) {
|
856
|
+
set: function (text) {
|
827
857
|
if (this.node.nodeType !== Node.TEXT_NODE) {
|
828
858
|
this._clear();
|
829
|
-
var d = document.createElement(
|
859
|
+
var d = document.createElement('div');
|
830
860
|
d.innerHTML = text;
|
831
861
|
for (var e = d.firstChild; e; e = e.nextSibling) {
|
832
862
|
this.appendChild(e);
|
@@ -836,14 +866,14 @@ this.appendChild(e);
|
|
836
866
|
configurable: true
|
837
867
|
}
|
838
868
|
});
|
839
|
-
DomApi.prototype._getComposedInnerHTML = function() {
|
869
|
+
DomApi.prototype._getComposedInnerHTML = function () {
|
840
870
|
return getInnerHTML(this.node, true);
|
841
871
|
};
|
842
872
|
} else {
|
843
|
-
DomApi.prototype.querySelectorAll = function(selector) {
|
873
|
+
DomApi.prototype.querySelectorAll = function (selector) {
|
844
874
|
return Array.prototype.slice.call(this.node.querySelectorAll(selector));
|
845
875
|
};
|
846
|
-
DomApi.prototype.getOwnerRoot = function() {
|
876
|
+
DomApi.prototype.getOwnerRoot = function () {
|
847
877
|
var n = this.node;
|
848
878
|
while (n) {
|
849
879
|
if (n.nodeType === Node.DOCUMENT_FRAGMENT_NODE && n.host) {
|
@@ -852,66 +882,77 @@ return n;
|
|
852
882
|
n = n.parentNode;
|
853
883
|
}
|
854
884
|
};
|
855
|
-
DomApi.prototype.getDestinationInsertionPoints = function() {
|
885
|
+
DomApi.prototype.getDestinationInsertionPoints = function () {
|
856
886
|
var n$ = this.node.getDestinationInsertionPoints();
|
857
887
|
return n$ ? Array.prototype.slice.call(n$) : [];
|
858
888
|
};
|
859
|
-
DomApi.prototype.getDistributedNodes = function() {
|
889
|
+
DomApi.prototype.getDistributedNodes = function () {
|
860
890
|
var n$ = this.node.getDistributedNodes();
|
861
891
|
return n$ ? Array.prototype.slice.call(n$) : [];
|
862
892
|
};
|
863
|
-
DomApi.prototype._distributeParent = function() {
|
893
|
+
DomApi.prototype._distributeParent = function () {
|
894
|
+
};
|
864
895
|
Object.defineProperties(DomApi.prototype, {
|
865
896
|
childNodes: {
|
866
|
-
get: function() {
|
897
|
+
get: function () {
|
867
898
|
return Array.prototype.slice.call(this.node.childNodes);
|
868
899
|
},
|
869
900
|
configurable: true
|
870
901
|
},
|
871
902
|
children: {
|
872
|
-
get: function() {
|
903
|
+
get: function () {
|
873
904
|
return Array.prototype.slice.call(this.node.children);
|
874
905
|
},
|
875
906
|
configurable: true
|
876
907
|
},
|
877
908
|
textContent: {
|
878
|
-
get: function() {
|
909
|
+
get: function () {
|
879
910
|
return this.node.textContent;
|
880
911
|
},
|
881
|
-
set: function(value) {
|
912
|
+
set: function (value) {
|
882
913
|
return this.node.textContent = value;
|
883
914
|
},
|
884
915
|
configurable: true
|
885
916
|
},
|
886
917
|
innerHTML: {
|
887
|
-
get: function() {
|
918
|
+
get: function () {
|
888
919
|
return this.node.innerHTML;
|
889
920
|
},
|
890
|
-
set: function(value) {
|
921
|
+
set: function (value) {
|
891
922
|
return this.node.innerHTML = value;
|
892
923
|
},
|
893
924
|
configurable: true
|
894
925
|
}
|
895
926
|
});
|
896
|
-
var forwards = [
|
897
|
-
|
927
|
+
var forwards = [
|
928
|
+
'parentNode',
|
929
|
+
'firstChild',
|
930
|
+
'lastChild',
|
931
|
+
'nextSibling',
|
932
|
+
'previousSibling',
|
933
|
+
'firstElementChild',
|
934
|
+
'lastElementChild',
|
935
|
+
'nextElementSibling',
|
936
|
+
'previousElementSibling'
|
937
|
+
];
|
938
|
+
forwards.forEach(function (name) {
|
898
939
|
Object.defineProperty(DomApi.prototype, name, {
|
899
|
-
get: function() {
|
940
|
+
get: function () {
|
900
941
|
return this.node[name];
|
901
942
|
},
|
902
943
|
configurable: true
|
903
944
|
});
|
904
945
|
});
|
905
946
|
}
|
906
|
-
var CONTENT =
|
907
|
-
var factory = function(node, patch) {
|
947
|
+
var CONTENT = 'content';
|
948
|
+
var factory = function (node, patch) {
|
908
949
|
node = node || document;
|
909
950
|
if (!node.__domApi) {
|
910
951
|
node.__domApi = new DomApi(node, patch);
|
911
952
|
}
|
912
953
|
return node.__domApi;
|
913
954
|
};
|
914
|
-
Polymer.dom = function(obj, patch) {
|
955
|
+
Polymer.dom = function (obj, patch) {
|
915
956
|
if (obj instanceof Event) {
|
916
957
|
return Polymer.EventApi.factory(obj);
|
917
958
|
} else {
|
@@ -934,7 +975,7 @@ var children = getComposedChildren(parent);
|
|
934
975
|
var i = ref_node ? children.indexOf(ref_node) : -1;
|
935
976
|
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
936
977
|
var fragChildren = getComposedChildren(node);
|
937
|
-
fragChildren.forEach(function(c) {
|
978
|
+
fragChildren.forEach(function (c) {
|
938
979
|
addNodeToComposedChildren(c, parent, children, i);
|
939
980
|
});
|
940
981
|
} else {
|
@@ -984,21 +1025,20 @@ ctor: DomApi,
|
|
984
1025
|
factory: factory
|
985
1026
|
};
|
986
1027
|
}();
|
987
|
-
|
988
|
-
(function() {
|
1028
|
+
(function () {
|
989
1029
|
Polymer.Base._addFeature({
|
990
|
-
_prepShady: function() {
|
1030
|
+
_prepShady: function () {
|
991
1031
|
this._useContent = this._useContent || Boolean(this._template);
|
992
1032
|
if (this._useContent) {
|
993
|
-
this._template._hasInsertionPoint = this._template.content.querySelector(
|
1033
|
+
this._template._hasInsertionPoint = this._template.content.querySelector('content');
|
994
1034
|
}
|
995
1035
|
},
|
996
|
-
_poolContent: function() {
|
1036
|
+
_poolContent: function () {
|
997
1037
|
if (this._useContent) {
|
998
1038
|
saveLightChildrenIfNeeded(this);
|
999
1039
|
}
|
1000
1040
|
},
|
1001
|
-
_setupRoot: function() {
|
1041
|
+
_setupRoot: function () {
|
1002
1042
|
if (this._useContent) {
|
1003
1043
|
this._createLocalRoot();
|
1004
1044
|
if (!this.dataHost) {
|
@@ -1006,12 +1046,12 @@ upgradeLightChildren(this._lightChildren);
|
|
1006
1046
|
}
|
1007
1047
|
}
|
1008
1048
|
},
|
1009
|
-
_createLocalRoot: function() {
|
1049
|
+
_createLocalRoot: function () {
|
1010
1050
|
this.shadyRoot = this.root;
|
1011
1051
|
this.shadyRoot._distributionClean = false;
|
1012
1052
|
this.shadyRoot._isShadyRoot = true;
|
1013
1053
|
this.shadyRoot._dirtyRoots = [];
|
1014
|
-
this.shadyRoot._insertionPoints = this._template._hasInsertionPoint ? this.shadyRoot.querySelectorAll(
|
1054
|
+
this.shadyRoot._insertionPoints = this._template._hasInsertionPoint ? this.shadyRoot.querySelectorAll('content') : [];
|
1015
1055
|
saveLightChildrenIfNeeded(this.shadyRoot);
|
1016
1056
|
this.shadyRoot.host = this;
|
1017
1057
|
},
|
@@ -1019,39 +1059,39 @@ get domHost() {
|
|
1019
1059
|
var root = Polymer.dom(this).getOwnerRoot();
|
1020
1060
|
return root && root.host;
|
1021
1061
|
},
|
1022
|
-
distributeContent: function() {
|
1062
|
+
distributeContent: function () {
|
1023
1063
|
if (this.shadyRoot) {
|
1024
1064
|
var host = getTopDistributingHost(this);
|
1025
1065
|
Polymer.dom(this)._lazyDistribute(host);
|
1026
1066
|
}
|
1027
1067
|
},
|
1028
|
-
_distributeContent: function() {
|
1068
|
+
_distributeContent: function () {
|
1029
1069
|
if (this._useContent && !this.shadyRoot._distributionClean) {
|
1030
1070
|
this._beginDistribute();
|
1031
1071
|
this._distributeDirtyRoots();
|
1032
1072
|
this._finishDistribute();
|
1033
1073
|
}
|
1034
1074
|
},
|
1035
|
-
_beginDistribute: function() {
|
1075
|
+
_beginDistribute: function () {
|
1036
1076
|
if (this._useContent && hasInsertionPoint(this.shadyRoot)) {
|
1037
1077
|
this._resetDistribution();
|
1038
1078
|
this._distributePool(this.shadyRoot, this._collectPool());
|
1039
1079
|
}
|
1040
1080
|
},
|
1041
|
-
_distributeDirtyRoots: function() {
|
1081
|
+
_distributeDirtyRoots: function () {
|
1042
1082
|
var c$ = this.shadyRoot._dirtyRoots;
|
1043
1083
|
for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
|
1044
1084
|
c._distributeContent();
|
1045
1085
|
}
|
1046
1086
|
this.shadyRoot._dirtyRoots = [];
|
1047
1087
|
},
|
1048
|
-
_finishDistribute: function() {
|
1088
|
+
_finishDistribute: function () {
|
1049
1089
|
if (this._useContent) {
|
1050
1090
|
if (hasInsertionPoint(this.shadyRoot)) {
|
1051
1091
|
this._composeTree();
|
1052
1092
|
} else {
|
1053
1093
|
if (!this.shadyRoot._hasDistributed) {
|
1054
|
-
this.textContent =
|
1094
|
+
this.textContent = '';
|
1055
1095
|
this.appendChild(this.shadyRoot);
|
1056
1096
|
} else {
|
1057
1097
|
var children = this._composeNode(this);
|
@@ -1062,11 +1102,11 @@ this.shadyRoot._hasDistributed = true;
|
|
1062
1102
|
this.shadyRoot._distributionClean = true;
|
1063
1103
|
}
|
1064
1104
|
},
|
1065
|
-
elementMatches: function(selector, node) {
|
1105
|
+
elementMatches: function (selector, node) {
|
1066
1106
|
node = node || this;
|
1067
1107
|
return matchesSelector.call(node, selector);
|
1068
1108
|
},
|
1069
|
-
_resetDistribution: function() {
|
1109
|
+
_resetDistribution: function () {
|
1070
1110
|
var children = getLightChildren(this);
|
1071
1111
|
for (var i = 0; i < children.length; i++) {
|
1072
1112
|
var child = children[i];
|
@@ -1083,7 +1123,7 @@ for (var j = 0; j < p$.length; j++) {
|
|
1083
1123
|
p$[j]._distributedNodes = [];
|
1084
1124
|
}
|
1085
1125
|
},
|
1086
|
-
_collectPool: function() {
|
1126
|
+
_collectPool: function () {
|
1087
1127
|
var pool = [];
|
1088
1128
|
var children = getLightChildren(this);
|
1089
1129
|
for (var i = 0; i < children.length; i++) {
|
@@ -1096,14 +1136,14 @@ pool.push(child);
|
|
1096
1136
|
}
|
1097
1137
|
return pool;
|
1098
1138
|
},
|
1099
|
-
_distributePool: function(node, pool) {
|
1139
|
+
_distributePool: function (node, pool) {
|
1100
1140
|
var p$ = node._insertionPoints;
|
1101
1141
|
for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) {
|
1102
1142
|
this._distributeInsertionPoint(p, pool);
|
1103
1143
|
maybeRedistributeParent(p, this);
|
1104
1144
|
}
|
1105
1145
|
},
|
1106
|
-
_distributeInsertionPoint: function(content, pool) {
|
1146
|
+
_distributeInsertionPoint: function (content, pool) {
|
1107
1147
|
var anyDistributed = false;
|
1108
1148
|
for (var i = 0, l = pool.length, node; i < l; i++) {
|
1109
1149
|
node = pool[i];
|
@@ -1123,7 +1163,7 @@ distributeNodeInto(children[j], content);
|
|
1123
1163
|
}
|
1124
1164
|
}
|
1125
1165
|
},
|
1126
|
-
_composeTree: function() {
|
1166
|
+
_composeTree: function () {
|
1127
1167
|
this._updateChildNodes(this, this._composeNode(this));
|
1128
1168
|
var p$ = this.shadyRoot._insertionPoints;
|
1129
1169
|
for (var i = 0, l = p$.length, p, parent; i < l && (p = p$[i]); i++) {
|
@@ -1133,7 +1173,7 @@ this._updateChildNodes(parent, this._composeNode(parent));
|
|
1133
1173
|
}
|
1134
1174
|
}
|
1135
1175
|
},
|
1136
|
-
_composeNode: function(node) {
|
1176
|
+
_composeNode: function (node) {
|
1137
1177
|
var children = [];
|
1138
1178
|
var c$ = getLightChildren(node.shadyRoot || node);
|
1139
1179
|
for (var i = 0; i < c$.length; i++) {
|
@@ -1152,7 +1192,7 @@ children.push(child);
|
|
1152
1192
|
}
|
1153
1193
|
return children;
|
1154
1194
|
},
|
1155
|
-
_updateChildNodes: function(container, children) {
|
1195
|
+
_updateChildNodes: function (container, children) {
|
1156
1196
|
var composed = getComposedChildren(container);
|
1157
1197
|
var splices = Polymer.ArraySplice.calculateSplices(children, composed);
|
1158
1198
|
for (var i = 0, d = 0, s; i < splices.length && (s = splices[i]); i++) {
|
@@ -1171,8 +1211,8 @@ composed.splice(j, 0, n);
|
|
1171
1211
|
}
|
1172
1212
|
}
|
1173
1213
|
},
|
1174
|
-
_matchesContentSelect: function(node, contentElement) {
|
1175
|
-
var select = contentElement.getAttribute(
|
1214
|
+
_matchesContentSelect: function (node, contentElement) {
|
1215
|
+
var select = contentElement.getAttribute('select');
|
1176
1216
|
if (!select) {
|
1177
1217
|
return true;
|
1178
1218
|
}
|
@@ -1189,8 +1229,10 @@ return false;
|
|
1189
1229
|
}
|
1190
1230
|
return this.elementMatches(select, node);
|
1191
1231
|
},
|
1192
|
-
_elementAdd: function() {
|
1193
|
-
|
1232
|
+
_elementAdd: function () {
|
1233
|
+
},
|
1234
|
+
_elementRemove: function () {
|
1235
|
+
}
|
1194
1236
|
});
|
1195
1237
|
var saveLightChildrenIfNeeded = Polymer.DomApi.saveLightChildrenIfNeeded;
|
1196
1238
|
var getLightChildren = Polymer.DomApi.getLightChildren;
|
@@ -1202,7 +1244,7 @@ function distributeNodeInto(child, insertionPoint) {
|
|
1202
1244
|
insertionPoint._distributedNodes.push(child);
|
1203
1245
|
var points = child._destinationInsertionPoints;
|
1204
1246
|
if (!points) {
|
1205
|
-
child._destinationInsertionPoints = [
|
1247
|
+
child._destinationInsertionPoints = [insertionPoint];
|
1206
1248
|
} else {
|
1207
1249
|
points.push(insertionPoint);
|
1208
1250
|
}
|
@@ -1228,7 +1270,7 @@ var points = node._destinationInsertionPoints;
|
|
1228
1270
|
return points && points[points.length - 1] === insertionPoint;
|
1229
1271
|
}
|
1230
1272
|
function isInsertionPoint(node) {
|
1231
|
-
return node.localName ==
|
1273
|
+
return node.localName == 'content';
|
1232
1274
|
}
|
1233
1275
|
var nativeInsertBefore = Element.prototype.insertBefore;
|
1234
1276
|
var nativeRemoveChild = Element.prototype.removeChild;
|
@@ -1263,7 +1305,7 @@ function hostNeedsRedistribution(host) {
|
|
1263
1305
|
var c$ = Polymer.dom(host).children;
|
1264
1306
|
for (var i = 0, c; i < c$.length; i++) {
|
1265
1307
|
c = c$[i];
|
1266
|
-
if (c.localName ===
|
1308
|
+
if (c.localName === 'content') {
|
1267
1309
|
return host.domHost;
|
1268
1310
|
}
|
1269
1311
|
}
|
@@ -1276,27 +1318,29 @@ CustomElements.upgrade(children[i]);
|
|
1276
1318
|
}
|
1277
1319
|
}
|
1278
1320
|
}
|
1279
|
-
}
|
1280
|
-
|
1321
|
+
}());
|
1281
1322
|
if (Polymer.Settings.useShadow) {
|
1282
1323
|
Polymer.Base._addFeature({
|
1283
|
-
_poolContent: function() {
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1324
|
+
_poolContent: function () {
|
1325
|
+
},
|
1326
|
+
_beginDistribute: function () {
|
1327
|
+
},
|
1328
|
+
distributeContent: function () {
|
1329
|
+
},
|
1330
|
+
_distributeContent: function () {
|
1331
|
+
},
|
1332
|
+
_finishDistribute: function () {
|
1333
|
+
},
|
1334
|
+
_createLocalRoot: function () {
|
1289
1335
|
this.createShadowRoot();
|
1290
1336
|
this.shadowRoot.appendChild(this.root);
|
1291
1337
|
this.root = this.shadowRoot;
|
1292
1338
|
}
|
1293
1339
|
});
|
1294
1340
|
}
|
1295
|
-
|
1296
|
-
Polymer.DomModule = document.createElement("dom-module");
|
1297
|
-
|
1341
|
+
Polymer.DomModule = document.createElement('dom-module');
|
1298
1342
|
Polymer.Base._addFeature({
|
1299
|
-
_registerFeatures: function() {
|
1343
|
+
_registerFeatures: function () {
|
1300
1344
|
this._prepIs();
|
1301
1345
|
this._prepAttributes();
|
1302
1346
|
this._prepBehaviors();
|
@@ -1305,10 +1349,10 @@ this._prepConstructor();
|
|
1305
1349
|
this._prepTemplate();
|
1306
1350
|
this._prepShady();
|
1307
1351
|
},
|
1308
|
-
_prepBehavior: function(b) {
|
1352
|
+
_prepBehavior: function (b) {
|
1309
1353
|
this._addHostAttributes(b.hostAttributes);
|
1310
1354
|
},
|
1311
|
-
_initFeatures: function() {
|
1355
|
+
_initFeatures: function () {
|
1312
1356
|
this._poolContent();
|
1313
1357
|
this._pushHost();
|
1314
1358
|
this._stampTemplate();
|
@@ -1318,5 +1362,6 @@ this._setupDebouncers();
|
|
1318
1362
|
this._marshalBehaviors();
|
1319
1363
|
this._tryReady();
|
1320
1364
|
},
|
1321
|
-
_marshalBehavior: function(b) {
|
1365
|
+
_marshalBehavior: function (b) {
|
1366
|
+
}
|
1322
1367
|
});</script>
|