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
@@ -17,40 +17,39 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|
17
17
|
--><link rel="import" href="polymer-mini.html">
|
18
18
|
|
19
19
|
<script>Polymer.nar = [];
|
20
|
-
|
21
20
|
Polymer.Annotations = {
|
22
|
-
parseAnnotations: function(template) {
|
21
|
+
parseAnnotations: function (template) {
|
23
22
|
var list = [];
|
24
23
|
var content = template._content || template.content;
|
25
24
|
this._parseNodeAnnotations(content, list);
|
26
25
|
return list;
|
27
26
|
},
|
28
|
-
_parseNodeAnnotations: function(node, list) {
|
27
|
+
_parseNodeAnnotations: function (node, list) {
|
29
28
|
return node.nodeType === Node.TEXT_NODE ? this._parseTextNodeAnnotation(node, list) : this._parseElementAnnotations(node, list);
|
30
29
|
},
|
31
|
-
_testEscape: function(value) {
|
30
|
+
_testEscape: function (value) {
|
32
31
|
var escape = value.slice(0, 2);
|
33
|
-
if (escape ===
|
32
|
+
if (escape === '{{' || escape === '[[') {
|
34
33
|
return escape;
|
35
34
|
}
|
36
35
|
},
|
37
|
-
_parseTextNodeAnnotation: function(node, list) {
|
36
|
+
_parseTextNodeAnnotation: function (node, list) {
|
38
37
|
var v = node.textContent;
|
39
38
|
var escape = this._testEscape(v);
|
40
39
|
if (escape) {
|
41
|
-
node.textContent =
|
40
|
+
node.textContent = ' ';
|
42
41
|
var annote = {
|
43
|
-
bindings: [
|
44
|
-
kind:
|
42
|
+
bindings: [{
|
43
|
+
kind: 'text',
|
45
44
|
mode: escape[0],
|
46
45
|
value: v.slice(2, -2).trim()
|
47
|
-
}
|
46
|
+
}]
|
48
47
|
};
|
49
48
|
list.push(annote);
|
50
49
|
return annote;
|
51
50
|
}
|
52
51
|
},
|
53
|
-
_parseElementAnnotations: function(element, list) {
|
52
|
+
_parseElementAnnotations: function (element, list) {
|
54
53
|
var annote = {
|
55
54
|
bindings: [],
|
56
55
|
events: []
|
@@ -67,10 +66,10 @@ list.push(annote);
|
|
67
66
|
}
|
68
67
|
return annote;
|
69
68
|
},
|
70
|
-
_parseChildNodesAnnotations: function(root, annote, list, callback) {
|
69
|
+
_parseChildNodesAnnotations: function (root, annote, list, callback) {
|
71
70
|
if (root.firstChild) {
|
72
71
|
for (var i = 0, node = root.firstChild; node; node = node.nextSibling, i++) {
|
73
|
-
if (node.localName ===
|
72
|
+
if (node.localName === 'template' && !node.hasAttribute('preserve-content')) {
|
74
73
|
this._parseTemplate(node, i, list, annote);
|
75
74
|
}
|
76
75
|
var childAnnotation = this._parseNodeAnnotations(node, list, callback);
|
@@ -81,7 +80,7 @@ childAnnotation.index = i;
|
|
81
80
|
}
|
82
81
|
}
|
83
82
|
},
|
84
|
-
_parseTemplate: function(node, index, list, parent) {
|
83
|
+
_parseTemplate: function (node, index, list, parent) {
|
85
84
|
var content = document.createDocumentFragment();
|
86
85
|
content._notes = this.parseAnnotations(node);
|
87
86
|
content.appendChild(node.content);
|
@@ -93,12 +92,12 @@ parent: parent,
|
|
93
92
|
index: index
|
94
93
|
});
|
95
94
|
},
|
96
|
-
_parseNodeAttributeAnnotations: function(node, annotation) {
|
95
|
+
_parseNodeAttributeAnnotations: function (node, annotation) {
|
97
96
|
for (var i = node.attributes.length - 1, a; a = node.attributes[i]; i--) {
|
98
97
|
var n = a.name, v = a.value;
|
99
|
-
if (n ===
|
98
|
+
if (n === 'id' && !this._testEscape(v)) {
|
100
99
|
annotation.id = v;
|
101
|
-
} else if (n.slice(0, 3) ===
|
100
|
+
} else if (n.slice(0, 3) === 'on-') {
|
102
101
|
node.removeAttribute(n);
|
103
102
|
annotation.events.push({
|
104
103
|
name: n.slice(3),
|
@@ -112,7 +111,7 @@ annotation.bindings.push(b);
|
|
112
111
|
}
|
113
112
|
}
|
114
113
|
},
|
115
|
-
_parseNodeAttributeAnnotation: function(node, n, v) {
|
114
|
+
_parseNodeAttributeAnnotation: function (node, n, v) {
|
116
115
|
var escape = this._testEscape(v);
|
117
116
|
if (escape) {
|
118
117
|
var customEvent;
|
@@ -120,26 +119,26 @@ var name = n;
|
|
120
119
|
var mode = escape[0];
|
121
120
|
v = v.slice(2, -2).trim();
|
122
121
|
var not = false;
|
123
|
-
if (v[0] ==
|
122
|
+
if (v[0] == '!') {
|
124
123
|
v = v.substring(1);
|
125
124
|
not = true;
|
126
125
|
}
|
127
|
-
var kind =
|
128
|
-
if (n[n.length - 1] ==
|
126
|
+
var kind = 'property';
|
127
|
+
if (n[n.length - 1] == '$') {
|
129
128
|
name = n.slice(0, -1);
|
130
|
-
kind =
|
129
|
+
kind = 'attribute';
|
131
130
|
}
|
132
131
|
var notifyEvent, colon;
|
133
|
-
if (mode ==
|
132
|
+
if (mode == '{' && (colon = v.indexOf('::')) > 0) {
|
134
133
|
notifyEvent = v.substring(colon + 2);
|
135
134
|
v = v.substring(0, colon);
|
136
135
|
customEvent = true;
|
137
136
|
}
|
138
|
-
if (node.localName ==
|
139
|
-
node.setAttribute(n,
|
137
|
+
if (node.localName == 'input' && n == 'value') {
|
138
|
+
node.setAttribute(n, '');
|
140
139
|
}
|
141
140
|
node.removeAttribute(n);
|
142
|
-
if (kind ===
|
141
|
+
if (kind === 'property') {
|
143
142
|
name = Polymer.CaseMap.dashToCamelCase(name);
|
144
143
|
}
|
145
144
|
return {
|
@@ -153,30 +152,29 @@ customEvent: customEvent
|
|
153
152
|
};
|
154
153
|
}
|
155
154
|
},
|
156
|
-
_localSubTree: function(node, host) {
|
155
|
+
_localSubTree: function (node, host) {
|
157
156
|
return node === host ? node.childNodes : node._lightChildren || node.childNodes;
|
158
157
|
},
|
159
|
-
findAnnotatedNode: function(root, annote) {
|
158
|
+
findAnnotatedNode: function (root, annote) {
|
160
159
|
var parent = annote.parent && Polymer.Annotations.findAnnotatedNode(root, annote.parent);
|
161
160
|
return !parent ? root : Polymer.Annotations._localSubTree(parent, root)[annote.index];
|
162
161
|
}
|
163
162
|
};
|
164
|
-
|
165
|
-
(function() {
|
163
|
+
(function () {
|
166
164
|
function resolveCss(cssText, ownerDocument) {
|
167
|
-
return cssText.replace(CSS_URL_RX, function(m, pre, url, post) {
|
168
|
-
return pre +
|
165
|
+
return cssText.replace(CSS_URL_RX, function (m, pre, url, post) {
|
166
|
+
return pre + '\'' + resolve(url.replace(/["']/g, ''), ownerDocument) + '\'' + post;
|
169
167
|
});
|
170
168
|
}
|
171
169
|
function resolveAttrs(element, ownerDocument) {
|
172
170
|
for (var name in URL_ATTRS) {
|
173
171
|
var a$ = URL_ATTRS[name];
|
174
172
|
for (var i = 0, l = a$.length, a, at, v; i < l && (a = a$[i]); i++) {
|
175
|
-
if (name ===
|
173
|
+
if (name === '*' || element.localName === name) {
|
176
174
|
at = element.attributes[a];
|
177
175
|
v = at && at.value;
|
178
176
|
if (v && v.search(BINDING_RX) < 0) {
|
179
|
-
at.value = a ===
|
177
|
+
at.value = a === 'style' ? resolveCss(v, ownerDocument) : resolve(v, ownerDocument);
|
180
178
|
}
|
181
179
|
}
|
182
180
|
}
|
@@ -191,20 +189,25 @@ var tempDoc;
|
|
191
189
|
var tempDocBase;
|
192
190
|
function resolveUrl(url, baseUri) {
|
193
191
|
if (!tempDoc) {
|
194
|
-
tempDoc = document.implementation.createHTMLDocument(
|
195
|
-
tempDocBase = tempDoc.createElement(
|
192
|
+
tempDoc = document.implementation.createHTMLDocument('temp');
|
193
|
+
tempDocBase = tempDoc.createElement('base');
|
196
194
|
tempDoc.head.appendChild(tempDocBase);
|
197
195
|
}
|
198
196
|
tempDocBase.href = baseUri;
|
199
197
|
return resolve(url, tempDoc);
|
200
198
|
}
|
201
199
|
function getUrlResolver(ownerDocument) {
|
202
|
-
return ownerDocument.__urlResolver || (ownerDocument.__urlResolver = ownerDocument.createElement(
|
200
|
+
return ownerDocument.__urlResolver || (ownerDocument.__urlResolver = ownerDocument.createElement('a'));
|
203
201
|
}
|
204
202
|
var CSS_URL_RX = /(url\()([^)]*)(\))/g;
|
205
203
|
var URL_ATTRS = {
|
206
|
-
|
207
|
-
|
204
|
+
'*': [
|
205
|
+
'href',
|
206
|
+
'src',
|
207
|
+
'style',
|
208
|
+
'url'
|
209
|
+
],
|
210
|
+
form: ['action']
|
208
211
|
};
|
209
212
|
var BINDING_RX = /\{\{|\[\[/;
|
210
213
|
Polymer.ResolveUrl = {
|
@@ -212,10 +215,9 @@ resolveCss: resolveCss,
|
|
212
215
|
resolveAttrs: resolveAttrs,
|
213
216
|
resolveUrl: resolveUrl
|
214
217
|
};
|
215
|
-
}
|
216
|
-
|
218
|
+
}());
|
217
219
|
Polymer.Base._addFeature({
|
218
|
-
_prepAnnotations: function() {
|
220
|
+
_prepAnnotations: function () {
|
219
221
|
if (!this._template) {
|
220
222
|
this._notes = [];
|
221
223
|
} else {
|
@@ -225,7 +227,7 @@ this._processAnnotations(this._notes);
|
|
225
227
|
Polymer.Annotations.prepElement = null;
|
226
228
|
}
|
227
229
|
},
|
228
|
-
_processAnnotations: function(notes) {
|
230
|
+
_processAnnotations: function (notes) {
|
229
231
|
for (var i = 0; i < notes.length; i++) {
|
230
232
|
var note = notes[i];
|
231
233
|
for (var j = 0; j < note.bindings.length; j++) {
|
@@ -242,9 +244,9 @@ var bindings = [];
|
|
242
244
|
for (var prop in pp) {
|
243
245
|
bindings.push({
|
244
246
|
index: note.index,
|
245
|
-
kind:
|
246
|
-
mode:
|
247
|
-
name:
|
247
|
+
kind: 'property',
|
248
|
+
mode: '{',
|
249
|
+
name: '_parent_' + prop,
|
248
250
|
model: prop,
|
249
251
|
value: prop
|
250
252
|
});
|
@@ -253,10 +255,10 @@ note.bindings = note.bindings.concat(bindings);
|
|
253
255
|
}
|
254
256
|
}
|
255
257
|
},
|
256
|
-
_discoverTemplateParentProps: function(notes) {
|
258
|
+
_discoverTemplateParentProps: function (notes) {
|
257
259
|
var pp = {};
|
258
|
-
notes.forEach(function(n) {
|
259
|
-
n.bindings.forEach(function(b) {
|
260
|
+
notes.forEach(function (n) {
|
261
|
+
n.bindings.forEach(function (b) {
|
260
262
|
if (b.signature) {
|
261
263
|
var args = b.signature.args;
|
262
264
|
for (var k = 0; k < args.length; k++) {
|
@@ -273,104 +275,105 @@ Polymer.Base.mixin(pp, tpp);
|
|
273
275
|
});
|
274
276
|
return pp;
|
275
277
|
},
|
276
|
-
_prepElement: function(element) {
|
278
|
+
_prepElement: function (element) {
|
277
279
|
Polymer.ResolveUrl.resolveAttrs(element, this._template.ownerDocument);
|
278
280
|
},
|
279
281
|
_findAnnotatedNode: Polymer.Annotations.findAnnotatedNode,
|
280
|
-
_marshalAnnotationReferences: function() {
|
282
|
+
_marshalAnnotationReferences: function () {
|
281
283
|
if (this._template) {
|
282
284
|
this._marshalIdNodes();
|
283
285
|
this._marshalAnnotatedNodes();
|
284
286
|
this._marshalAnnotatedListeners();
|
285
287
|
}
|
286
288
|
},
|
287
|
-
_configureAnnotationReferences: function() {
|
289
|
+
_configureAnnotationReferences: function () {
|
288
290
|
this._configureTemplateContent();
|
289
291
|
},
|
290
|
-
_configureTemplateContent: function() {
|
291
|
-
this._notes.forEach(function(note, i) {
|
292
|
+
_configureTemplateContent: function () {
|
293
|
+
this._notes.forEach(function (note, i) {
|
292
294
|
if (note.templateContent) {
|
293
295
|
this._nodes[i]._content = note.templateContent;
|
294
296
|
}
|
295
297
|
}, this);
|
296
298
|
},
|
297
|
-
_marshalIdNodes: function() {
|
299
|
+
_marshalIdNodes: function () {
|
298
300
|
this.$ = {};
|
299
|
-
this._notes.forEach(function(a) {
|
301
|
+
this._notes.forEach(function (a) {
|
300
302
|
if (a.id) {
|
301
303
|
this.$[a.id] = this._findAnnotatedNode(this.root, a);
|
302
304
|
}
|
303
305
|
}, this);
|
304
306
|
},
|
305
|
-
_marshalAnnotatedNodes: function() {
|
307
|
+
_marshalAnnotatedNodes: function () {
|
306
308
|
if (this._nodes) {
|
307
|
-
this._nodes = this._nodes.map(function(a) {
|
309
|
+
this._nodes = this._nodes.map(function (a) {
|
308
310
|
return this._findAnnotatedNode(this.root, a);
|
309
311
|
}, this);
|
310
312
|
}
|
311
313
|
},
|
312
|
-
_marshalAnnotatedListeners: function() {
|
313
|
-
this._notes.forEach(function(a) {
|
314
|
+
_marshalAnnotatedListeners: function () {
|
315
|
+
this._notes.forEach(function (a) {
|
314
316
|
if (a.events && a.events.length) {
|
315
317
|
var node = this._findAnnotatedNode(this.root, a);
|
316
|
-
a.events.forEach(function(e) {
|
318
|
+
a.events.forEach(function (e) {
|
317
319
|
this.listen(node, e.name, e.value);
|
318
320
|
}, this);
|
319
321
|
}
|
320
322
|
}, this);
|
321
323
|
}
|
322
324
|
});
|
323
|
-
|
324
325
|
Polymer.Base._addFeature({
|
325
326
|
listeners: {},
|
326
|
-
_listenListeners: function(listeners) {
|
327
|
+
_listenListeners: function (listeners) {
|
327
328
|
var node, name, key;
|
328
329
|
for (key in listeners) {
|
329
|
-
if (key.indexOf(
|
330
|
+
if (key.indexOf('.') < 0) {
|
330
331
|
node = this;
|
331
332
|
name = key;
|
332
333
|
} else {
|
333
|
-
name = key.split(
|
334
|
+
name = key.split('.');
|
334
335
|
node = this.$[name[0]];
|
335
336
|
name = name[1];
|
336
337
|
}
|
337
338
|
this.listen(node, name, listeners[key]);
|
338
339
|
}
|
339
340
|
},
|
340
|
-
listen: function(node, eventName, methodName) {
|
341
|
+
listen: function (node, eventName, methodName) {
|
341
342
|
this._listen(node, eventName, this._createEventHandler(node, eventName, methodName));
|
342
343
|
},
|
343
|
-
_createEventHandler: function(node, eventName, methodName) {
|
344
|
+
_createEventHandler: function (node, eventName, methodName) {
|
344
345
|
var host = this;
|
345
|
-
return function(e) {
|
346
|
+
return function (e) {
|
346
347
|
if (host[methodName]) {
|
347
348
|
host[methodName](e, e.detail);
|
348
349
|
} else {
|
349
|
-
host._warn(host._logf(
|
350
|
+
host._warn(host._logf('_createEventHandler', 'listener method `' + methodName + '` not defined'));
|
350
351
|
}
|
351
352
|
};
|
352
353
|
},
|
353
|
-
_listen: function(node, eventName, handler) {
|
354
|
+
_listen: function (node, eventName, handler) {
|
354
355
|
node.addEventListener(eventName, handler);
|
355
356
|
}
|
356
357
|
});
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
var
|
361
|
-
var
|
362
|
-
var
|
363
|
-
var TOUCH_ACTION = "__polymerGesturesTouchAction";
|
358
|
+
(function () {
|
359
|
+
'use strict';
|
360
|
+
var HAS_NATIVE_TA = typeof document.head.style.touchAction === 'string';
|
361
|
+
var GESTURE_KEY = '__polymerGestures';
|
362
|
+
var HANDLED_OBJ = '__polymerGesturesHandled';
|
363
|
+
var TOUCH_ACTION = '__polymerGesturesTouchAction';
|
364
364
|
var TAP_DISTANCE = 25;
|
365
365
|
var TRACK_DISTANCE = 5;
|
366
366
|
var TRACK_LENGTH = 2;
|
367
367
|
var MOUSE_TIMEOUT = 2500;
|
368
|
-
var MOUSE_EVENTS = [
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
368
|
+
var MOUSE_EVENTS = [
|
369
|
+
'mousedown',
|
370
|
+
'mousemove',
|
371
|
+
'mouseup',
|
372
|
+
'click'
|
373
|
+
];
|
374
|
+
var mouseCanceller = function (mouseEvent) {
|
375
|
+
mouseEvent[HANDLED_OBJ] = { skip: true };
|
376
|
+
if (mouseEvent.type === 'click') {
|
374
377
|
var path = Polymer.dom(mouseEvent).path;
|
375
378
|
for (var i = 0; i < path.length; i++) {
|
376
379
|
if (path[i] === POINTERSTATE.mouse.target) {
|
@@ -395,7 +398,7 @@ function ignoreMouse() {
|
|
395
398
|
if (!POINTERSTATE.mouse.mouseIgnoreJob) {
|
396
399
|
setupTeardownMouseCanceller(true);
|
397
400
|
}
|
398
|
-
var unset = function() {
|
401
|
+
var unset = function () {
|
399
402
|
setupTeardownMouseCanceller();
|
400
403
|
POINTERSTATE.mouse.target = null;
|
401
404
|
POINTERSTATE.mouse.mouseIgnoreJob = null;
|
@@ -417,7 +420,7 @@ scrollDecided: false
|
|
417
420
|
};
|
418
421
|
function firstTouchAction(ev) {
|
419
422
|
var path = Polymer.dom(ev).path;
|
420
|
-
var ta =
|
423
|
+
var ta = 'auto';
|
421
424
|
for (var i = 0, n; i < path.length; i++) {
|
422
425
|
n = path[i];
|
423
426
|
if (n[TOUCH_ACTION]) {
|
@@ -430,7 +433,7 @@ return ta;
|
|
430
433
|
var Gestures = {
|
431
434
|
gestures: {},
|
432
435
|
recognizers: [],
|
433
|
-
deepTargetFind: function(x, y) {
|
436
|
+
deepTargetFind: function (x, y) {
|
434
437
|
var node = document.elementFromPoint(x, y);
|
435
438
|
var next = node;
|
436
439
|
while (next && next.shadowRoot) {
|
@@ -441,7 +444,7 @@ node = next;
|
|
441
444
|
}
|
442
445
|
return node;
|
443
446
|
},
|
444
|
-
handleNative: function(ev) {
|
447
|
+
handleNative: function (ev) {
|
445
448
|
var handled;
|
446
449
|
var type = ev.type;
|
447
450
|
var node = ev.currentTarget;
|
@@ -452,9 +455,9 @@ return;
|
|
452
455
|
}
|
453
456
|
if (!ev[HANDLED_OBJ]) {
|
454
457
|
ev[HANDLED_OBJ] = {};
|
455
|
-
if (type.slice(0, 5) ===
|
458
|
+
if (type.slice(0, 5) === 'touch') {
|
456
459
|
var t = ev.changedTouches[0];
|
457
|
-
if (type ===
|
460
|
+
if (type === 'touchstart') {
|
458
461
|
if (ev.touches.length === 1) {
|
459
462
|
POINTERSTATE.touch.id = t.identifier;
|
460
463
|
}
|
@@ -463,11 +466,11 @@ if (POINTERSTATE.touch.id !== t.identifier) {
|
|
463
466
|
return;
|
464
467
|
}
|
465
468
|
if (!HAS_NATIVE_TA) {
|
466
|
-
if (type ===
|
469
|
+
if (type === 'touchstart' || type === 'touchmove') {
|
467
470
|
Gestures.handleTouchAction(ev);
|
468
471
|
}
|
469
472
|
}
|
470
|
-
if (type ===
|
473
|
+
if (type === 'touchend') {
|
471
474
|
POINTERSTATE.mouse.target = Polymer.dom(ev).rootTarget;
|
472
475
|
ignoreMouse(true);
|
473
476
|
}
|
@@ -486,14 +489,14 @@ r[type](ev);
|
|
486
489
|
}
|
487
490
|
}
|
488
491
|
},
|
489
|
-
handleTouchAction: function(ev) {
|
492
|
+
handleTouchAction: function (ev) {
|
490
493
|
var t = ev.changedTouches[0];
|
491
494
|
var type = ev.type;
|
492
|
-
if (type ===
|
495
|
+
if (type === 'touchstart') {
|
493
496
|
POINTERSTATE.touch.x = t.clientX;
|
494
497
|
POINTERSTATE.touch.y = t.clientY;
|
495
498
|
POINTERSTATE.touch.scrollDecided = false;
|
496
|
-
} else if (type ===
|
499
|
+
} else if (type === 'touchmove') {
|
497
500
|
if (POINTERSTATE.touch.scrollDecided) {
|
498
501
|
return;
|
499
502
|
}
|
@@ -502,11 +505,12 @@ var ta = firstTouchAction(ev);
|
|
502
505
|
var prevent = false;
|
503
506
|
var dx = Math.abs(POINTERSTATE.touch.x - t.clientX);
|
504
507
|
var dy = Math.abs(POINTERSTATE.touch.y - t.clientY);
|
505
|
-
if (!ev.cancelable) {
|
508
|
+
if (!ev.cancelable) {
|
509
|
+
} else if (ta === 'none') {
|
506
510
|
prevent = true;
|
507
|
-
} else if (ta ===
|
511
|
+
} else if (ta === 'pan-x') {
|
508
512
|
prevent = dy > dx;
|
509
|
-
} else if (ta ===
|
513
|
+
} else if (ta === 'pan-y') {
|
510
514
|
prevent = dx > dy;
|
511
515
|
}
|
512
516
|
if (prevent) {
|
@@ -514,7 +518,7 @@ ev.preventDefault();
|
|
514
518
|
}
|
515
519
|
}
|
516
520
|
},
|
517
|
-
add: function(node, evType, handler) {
|
521
|
+
add: function (node, evType, handler) {
|
518
522
|
var recognizer = this.gestures[evType];
|
519
523
|
var deps = recognizer.deps;
|
520
524
|
var name = recognizer.name;
|
@@ -536,19 +540,19 @@ if (recognizer.touchAction) {
|
|
536
540
|
this.setTouchAction(node, recognizer.touchAction);
|
537
541
|
}
|
538
542
|
},
|
539
|
-
register: function(recog) {
|
543
|
+
register: function (recog) {
|
540
544
|
this.recognizers.push(recog);
|
541
545
|
for (var i = 0; i < recog.emits.length; i++) {
|
542
546
|
this.gestures[recog.emits[i]] = recog;
|
543
547
|
}
|
544
548
|
},
|
545
|
-
setTouchAction: function(node, value) {
|
549
|
+
setTouchAction: function (node, value) {
|
546
550
|
if (HAS_NATIVE_TA) {
|
547
551
|
node.style.touchAction = value;
|
548
552
|
}
|
549
553
|
node[TOUCH_ACTION] = value;
|
550
554
|
},
|
551
|
-
fire: function(target, type, detail) {
|
555
|
+
fire: function (target, type, detail) {
|
552
556
|
var ev = new CustomEvent(type, {
|
553
557
|
detail: detail,
|
554
558
|
bubbles: true,
|
@@ -558,26 +562,33 @@ target.dispatchEvent(ev);
|
|
558
562
|
}
|
559
563
|
};
|
560
564
|
Gestures.register({
|
561
|
-
name:
|
562
|
-
deps: [
|
563
|
-
|
564
|
-
|
565
|
+
name: 'downup',
|
566
|
+
deps: [
|
567
|
+
'mousedown',
|
568
|
+
'touchstart',
|
569
|
+
'touchend'
|
570
|
+
],
|
571
|
+
emits: [
|
572
|
+
'down',
|
573
|
+
'up'
|
574
|
+
],
|
575
|
+
mousedown: function (e) {
|
565
576
|
var t = e.currentTarget;
|
566
577
|
var self = this;
|
567
578
|
var upfn = function upfn(e) {
|
568
|
-
self.fire(
|
569
|
-
document.removeEventListener(
|
579
|
+
self.fire('up', t, e);
|
580
|
+
document.removeEventListener('mouseup', upfn);
|
570
581
|
};
|
571
|
-
document.addEventListener(
|
572
|
-
this.fire(
|
582
|
+
document.addEventListener('mouseup', upfn);
|
583
|
+
this.fire('down', t, e);
|
573
584
|
},
|
574
|
-
touchstart: function(e) {
|
575
|
-
this.fire(
|
585
|
+
touchstart: function (e) {
|
586
|
+
this.fire('down', e.currentTarget, e.changedTouches[0]);
|
576
587
|
},
|
577
|
-
touchend: function(e) {
|
578
|
-
this.fire(
|
588
|
+
touchend: function (e) {
|
589
|
+
this.fire('up', e.currentTarget, e.changedTouches[0]);
|
579
590
|
},
|
580
|
-
fire: function(type, target, event) {
|
591
|
+
fire: function (type, target, event) {
|
581
592
|
Gestures.fire(target, type, {
|
582
593
|
x: event.clientX,
|
583
594
|
y: event.clientY,
|
@@ -586,31 +597,36 @@ sourceEvent: event
|
|
586
597
|
}
|
587
598
|
});
|
588
599
|
Gestures.register({
|
589
|
-
name:
|
590
|
-
touchAction:
|
591
|
-
deps: [
|
592
|
-
|
600
|
+
name: 'track',
|
601
|
+
touchAction: 'none',
|
602
|
+
deps: [
|
603
|
+
'mousedown',
|
604
|
+
'touchstart',
|
605
|
+
'touchmove',
|
606
|
+
'touchend'
|
607
|
+
],
|
608
|
+
emits: ['track'],
|
593
609
|
info: {
|
594
610
|
x: 0,
|
595
611
|
y: 0,
|
596
|
-
state:
|
612
|
+
state: 'start',
|
597
613
|
started: false,
|
598
614
|
moves: [],
|
599
|
-
addMove: function(move) {
|
615
|
+
addMove: function (move) {
|
600
616
|
if (this.moves.length > TRACK_LENGTH) {
|
601
617
|
this.moves.shift();
|
602
618
|
}
|
603
619
|
this.moves.push(move);
|
604
620
|
}
|
605
621
|
},
|
606
|
-
clearInfo: function() {
|
607
|
-
this.info.state =
|
622
|
+
clearInfo: function () {
|
623
|
+
this.info.state = 'start';
|
608
624
|
this.info.started = false;
|
609
625
|
this.info.moves = [];
|
610
626
|
this.info.x = 0;
|
611
627
|
this.info.y = 0;
|
612
628
|
},
|
613
|
-
hasMovedEnough: function(x, y) {
|
629
|
+
hasMovedEnough: function (x, y) {
|
614
630
|
if (this.info.started) {
|
615
631
|
return true;
|
616
632
|
}
|
@@ -618,13 +634,13 @@ var dx = Math.abs(this.info.x - x);
|
|
618
634
|
var dy = Math.abs(this.info.y - y);
|
619
635
|
return dx >= TRACK_DISTANCE || dy >= TRACK_DISTANCE;
|
620
636
|
},
|
621
|
-
mousedown: function(e) {
|
637
|
+
mousedown: function (e) {
|
622
638
|
var t = e.currentTarget;
|
623
639
|
var self = this;
|
624
640
|
var movefn = function movefn(e) {
|
625
641
|
var x = e.clientX, y = e.clientY;
|
626
642
|
if (self.hasMovedEnough(x, y)) {
|
627
|
-
self.info.state = self.info.started ? e.type ===
|
643
|
+
self.info.state = self.info.started ? e.type === 'mouseup' ? 'end' : 'track' : 'start';
|
628
644
|
self.info.addMove({
|
629
645
|
x: x,
|
630
646
|
y: y
|
@@ -640,20 +656,20 @@ POINTERSTATE.tapPrevented = true;
|
|
640
656
|
movefn(e);
|
641
657
|
}
|
642
658
|
self.clearInfo();
|
643
|
-
document.removeEventListener(
|
644
|
-
document.removeEventListener(
|
659
|
+
document.removeEventListener('mousemove', movefn);
|
660
|
+
document.removeEventListener('mouseup', upfn);
|
645
661
|
};
|
646
|
-
document.addEventListener(
|
647
|
-
document.addEventListener(
|
662
|
+
document.addEventListener('mousemove', movefn);
|
663
|
+
document.addEventListener('mouseup', upfn);
|
648
664
|
this.info.x = e.clientX;
|
649
665
|
this.info.y = e.clientY;
|
650
666
|
},
|
651
|
-
touchstart: function(e) {
|
667
|
+
touchstart: function (e) {
|
652
668
|
var ct = e.changedTouches[0];
|
653
669
|
this.info.x = ct.clientX;
|
654
670
|
this.info.y = ct.clientY;
|
655
671
|
},
|
656
|
-
touchmove: function(e) {
|
672
|
+
touchmove: function (e) {
|
657
673
|
var t = e.currentTarget;
|
658
674
|
var ct = e.changedTouches[0];
|
659
675
|
var x = ct.clientX, y = ct.clientY;
|
@@ -663,16 +679,16 @@ x: x,
|
|
663
679
|
y: y
|
664
680
|
});
|
665
681
|
this.fire(t, ct);
|
666
|
-
this.info.state =
|
682
|
+
this.info.state = 'track';
|
667
683
|
this.info.started = true;
|
668
684
|
}
|
669
685
|
},
|
670
|
-
touchend: function(e) {
|
686
|
+
touchend: function (e) {
|
671
687
|
var t = e.currentTarget;
|
672
688
|
var ct = e.changedTouches[0];
|
673
689
|
if (this.info.started) {
|
674
690
|
POINTERSTATE.tapPrevented = true;
|
675
|
-
this.info.state =
|
691
|
+
this.info.state = 'end';
|
676
692
|
this.info.addMove({
|
677
693
|
x: ct.clientX,
|
678
694
|
y: ct.clientY
|
@@ -681,7 +697,7 @@ this.fire(t, ct);
|
|
681
697
|
}
|
682
698
|
this.clearInfo();
|
683
699
|
},
|
684
|
-
fire: function(target, touch) {
|
700
|
+
fire: function (target, touch) {
|
685
701
|
var secondlast = this.info.moves[this.info.moves.length - 2];
|
686
702
|
var lastmove = this.info.moves[this.info.moves.length - 1];
|
687
703
|
var dx = lastmove.x - this.info.x;
|
@@ -691,7 +707,7 @@ if (secondlast) {
|
|
691
707
|
ddx = lastmove.x - secondlast.x;
|
692
708
|
ddy = lastmove.y - secondlast.y;
|
693
709
|
}
|
694
|
-
return Gestures.fire(target,
|
710
|
+
return Gestures.fire(target, 'track', {
|
695
711
|
state: this.info.state,
|
696
712
|
x: touch.clientX,
|
697
713
|
y: touch.clientY,
|
@@ -700,48 +716,53 @@ dy: dy,
|
|
700
716
|
ddx: ddx,
|
701
717
|
ddy: ddy,
|
702
718
|
sourceEvent: touch,
|
703
|
-
hover: function() {
|
719
|
+
hover: function () {
|
704
720
|
return Gestures.deepTargetFind(touch.clientX, touch.clientY);
|
705
721
|
}
|
706
722
|
});
|
707
723
|
}
|
708
724
|
});
|
709
725
|
Gestures.register({
|
710
|
-
name:
|
711
|
-
deps: [
|
712
|
-
|
726
|
+
name: 'tap',
|
727
|
+
deps: [
|
728
|
+
'mousedown',
|
729
|
+
'click',
|
730
|
+
'touchstart',
|
731
|
+
'touchend'
|
732
|
+
],
|
733
|
+
emits: ['tap'],
|
713
734
|
start: {
|
714
735
|
x: NaN,
|
715
736
|
y: NaN
|
716
737
|
},
|
717
|
-
reset: function() {
|
738
|
+
reset: function () {
|
718
739
|
this.start.x = NaN;
|
719
740
|
this.start.y = NaN;
|
720
741
|
},
|
721
|
-
save: function(e) {
|
742
|
+
save: function (e) {
|
722
743
|
this.start.x = e.clientX;
|
723
744
|
this.start.y = e.clientY;
|
724
745
|
},
|
725
|
-
mousedown: function(e) {
|
746
|
+
mousedown: function (e) {
|
726
747
|
POINTERSTATE.tapPrevented = false;
|
727
748
|
this.save(e);
|
728
749
|
},
|
729
|
-
click: function(e) {
|
750
|
+
click: function (e) {
|
730
751
|
this.forward(e);
|
731
752
|
},
|
732
|
-
touchstart: function(e) {
|
753
|
+
touchstart: function (e) {
|
733
754
|
POINTERSTATE.tapPrevented = false;
|
734
755
|
this.save(e.changedTouches[0]);
|
735
756
|
},
|
736
|
-
touchend: function(e) {
|
757
|
+
touchend: function (e) {
|
737
758
|
this.forward(e.changedTouches[0]);
|
738
759
|
},
|
739
|
-
forward: function(e) {
|
760
|
+
forward: function (e) {
|
740
761
|
var dx = Math.abs(e.clientX - this.start.x);
|
741
762
|
var dy = Math.abs(e.clientY - this.start.y);
|
742
763
|
if (isNaN(dx) || isNaN(dy) || dx <= TAP_DISTANCE && dy <= TAP_DISTANCE) {
|
743
764
|
if (!POINTERSTATE.tapPrevented) {
|
744
|
-
Gestures.fire(e.target,
|
765
|
+
Gestures.fire(e.target, 'tap', {
|
745
766
|
x: e.clientX,
|
746
767
|
y: e.clientY,
|
747
768
|
sourceEvent: e
|
@@ -752,32 +773,31 @@ this.reset();
|
|
752
773
|
}
|
753
774
|
});
|
754
775
|
var DIRECTION_MAP = {
|
755
|
-
x:
|
756
|
-
y:
|
757
|
-
none:
|
758
|
-
all:
|
776
|
+
x: 'pan-x',
|
777
|
+
y: 'pan-y',
|
778
|
+
none: 'none',
|
779
|
+
all: 'auto'
|
759
780
|
};
|
760
781
|
Polymer.Base._addFeature({
|
761
|
-
_listen: function(node, eventName, handler) {
|
782
|
+
_listen: function (node, eventName, handler) {
|
762
783
|
if (Gestures.gestures[eventName]) {
|
763
784
|
Gestures.add(node, eventName, handler);
|
764
785
|
} else {
|
765
786
|
node.addEventListener(eventName, handler);
|
766
787
|
}
|
767
788
|
},
|
768
|
-
setScrollDirection: function(direction, node) {
|
789
|
+
setScrollDirection: function (direction, node) {
|
769
790
|
node = node || this;
|
770
|
-
Gestures.setTouchAction(node, DIRECTION_MAP[direction] ||
|
791
|
+
Gestures.setTouchAction(node, DIRECTION_MAP[direction] || 'auto');
|
771
792
|
}
|
772
793
|
});
|
773
794
|
Polymer.Gestures = Gestures;
|
774
|
-
}
|
775
|
-
|
776
|
-
Polymer.Async = function() {
|
795
|
+
}());
|
796
|
+
Polymer.Async = function () {
|
777
797
|
var currVal = 0;
|
778
798
|
var lastVal = 0;
|
779
799
|
var callbacks = [];
|
780
|
-
var twiddle = document.createTextNode(
|
800
|
+
var twiddle = document.createTextNode('');
|
781
801
|
function runAsync(callback, waitTime) {
|
782
802
|
if (waitTime > 0) {
|
783
803
|
return ~setTimeout(callback, waitTime);
|
@@ -794,7 +814,7 @@ clearTimeout(~handle);
|
|
794
814
|
var idx = handle - lastVal;
|
795
815
|
if (idx >= 0) {
|
796
816
|
if (!callbacks[idx]) {
|
797
|
-
throw
|
817
|
+
throw 'invalid async handle: ' + handle;
|
798
818
|
}
|
799
819
|
callbacks[idx] = null;
|
800
820
|
}
|
@@ -811,37 +831,34 @@ cb();
|
|
811
831
|
callbacks.splice(0, len);
|
812
832
|
lastVal += len;
|
813
833
|
}
|
814
|
-
new (window.MutationObserver || JsMutationObserver)(atEndOfMicrotask).observe(twiddle, {
|
815
|
-
characterData: true
|
816
|
-
});
|
834
|
+
new (window.MutationObserver || JsMutationObserver)(atEndOfMicrotask).observe(twiddle, { characterData: true });
|
817
835
|
return {
|
818
836
|
run: runAsync,
|
819
837
|
cancel: cancelAsync
|
820
838
|
};
|
821
839
|
}();
|
822
|
-
|
823
|
-
Polymer.Debounce = function() {
|
840
|
+
Polymer.Debounce = function () {
|
824
841
|
var Async = Polymer.Async;
|
825
|
-
var Debouncer = function(context) {
|
842
|
+
var Debouncer = function (context) {
|
826
843
|
this.context = context;
|
827
844
|
this.boundComplete = this.complete.bind(this);
|
828
845
|
};
|
829
846
|
Debouncer.prototype = {
|
830
|
-
go: function(callback, wait) {
|
847
|
+
go: function (callback, wait) {
|
831
848
|
var h;
|
832
|
-
this.finish = function() {
|
849
|
+
this.finish = function () {
|
833
850
|
Async.cancel(h);
|
834
851
|
};
|
835
852
|
h = Async.run(this.boundComplete, wait);
|
836
853
|
this.callback = callback;
|
837
854
|
},
|
838
|
-
stop: function() {
|
855
|
+
stop: function () {
|
839
856
|
if (this.finish) {
|
840
857
|
this.finish();
|
841
858
|
this.finish = null;
|
842
859
|
}
|
843
860
|
},
|
844
|
-
complete: function() {
|
861
|
+
complete: function () {
|
845
862
|
if (this.finish) {
|
846
863
|
this.stop();
|
847
864
|
this.callback.call(this.context);
|
@@ -859,12 +876,11 @@ return debouncer;
|
|
859
876
|
}
|
860
877
|
return debounce;
|
861
878
|
}();
|
862
|
-
|
863
879
|
Polymer.Base._addFeature({
|
864
|
-
$$: function(slctr) {
|
880
|
+
$$: function (slctr) {
|
865
881
|
return Polymer.dom(this.root).querySelector(slctr);
|
866
882
|
},
|
867
|
-
toggleClass: function(name, bool, node) {
|
883
|
+
toggleClass: function (name, bool, node) {
|
868
884
|
node = node || this;
|
869
885
|
if (arguments.length == 1) {
|
870
886
|
bool = !node.classList.contains(name);
|
@@ -875,18 +891,18 @@ Polymer.dom(node).classList.add(name);
|
|
875
891
|
Polymer.dom(node).classList.remove(name);
|
876
892
|
}
|
877
893
|
},
|
878
|
-
toggleAttribute: function(name, bool, node) {
|
894
|
+
toggleAttribute: function (name, bool, node) {
|
879
895
|
node = node || this;
|
880
896
|
if (arguments.length == 1) {
|
881
897
|
bool = !node.hasAttribute(name);
|
882
898
|
}
|
883
899
|
if (bool) {
|
884
|
-
Polymer.dom(node).setAttribute(name,
|
900
|
+
Polymer.dom(node).setAttribute(name, '');
|
885
901
|
} else {
|
886
902
|
Polymer.dom(node).removeAttribute(name);
|
887
903
|
}
|
888
904
|
},
|
889
|
-
classFollows: function(name, toElement, fromElement) {
|
905
|
+
classFollows: function (name, toElement, fromElement) {
|
890
906
|
if (fromElement) {
|
891
907
|
Polymer.dom(fromElement).classList.remove(name);
|
892
908
|
}
|
@@ -894,23 +910,23 @@ if (toElement) {
|
|
894
910
|
Polymer.dom(toElement).classList.add(name);
|
895
911
|
}
|
896
912
|
},
|
897
|
-
attributeFollows: function(name, toElement, fromElement) {
|
913
|
+
attributeFollows: function (name, toElement, fromElement) {
|
898
914
|
if (fromElement) {
|
899
915
|
Polymer.dom(fromElement).removeAttribute(name);
|
900
916
|
}
|
901
917
|
if (toElement) {
|
902
|
-
Polymer.dom(toElement).setAttribute(name,
|
918
|
+
Polymer.dom(toElement).setAttribute(name, '');
|
903
919
|
}
|
904
920
|
},
|
905
|
-
getContentChildNodes: function(slctr) {
|
906
|
-
return Polymer.dom(Polymer.dom(this.root).querySelector(slctr ||
|
921
|
+
getContentChildNodes: function (slctr) {
|
922
|
+
return Polymer.dom(Polymer.dom(this.root).querySelector(slctr || 'content')).getDistributedNodes();
|
907
923
|
},
|
908
|
-
getContentChildren: function(slctr) {
|
909
|
-
return this.getContentChildNodes(slctr).filter(function(n) {
|
924
|
+
getContentChildren: function (slctr) {
|
925
|
+
return this.getContentChildNodes(slctr).filter(function (n) {
|
910
926
|
return n.nodeType === Node.ELEMENT_NODE;
|
911
927
|
});
|
912
928
|
},
|
913
|
-
fire: function(type, detail, options) {
|
929
|
+
fire: function (type, detail, options) {
|
914
930
|
options = options || Polymer.nob;
|
915
931
|
var node = options.node || this;
|
916
932
|
var detail = detail === null || detail === undefined ? Polymer.nob : detail;
|
@@ -923,13 +939,13 @@ detail: detail
|
|
923
939
|
node.dispatchEvent(event);
|
924
940
|
return event;
|
925
941
|
},
|
926
|
-
async: function(callback, waitTime) {
|
942
|
+
async: function (callback, waitTime) {
|
927
943
|
return Polymer.Async.run(callback.bind(this), waitTime);
|
928
944
|
},
|
929
|
-
cancelAsync: function(handle) {
|
945
|
+
cancelAsync: function (handle) {
|
930
946
|
Polymer.Async.cancel(handle);
|
931
947
|
},
|
932
|
-
arrayDelete: function(path, item) {
|
948
|
+
arrayDelete: function (path, item) {
|
933
949
|
var index;
|
934
950
|
if (Array.isArray(path)) {
|
935
951
|
index = path.indexOf(item);
|
@@ -944,18 +960,18 @@ return this.splice(path, index, 1);
|
|
944
960
|
}
|
945
961
|
}
|
946
962
|
},
|
947
|
-
transform: function(transform, node) {
|
963
|
+
transform: function (transform, node) {
|
948
964
|
node = node || this;
|
949
965
|
node.style.webkitTransform = transform;
|
950
966
|
node.style.transform = transform;
|
951
967
|
},
|
952
|
-
translate3d: function(x, y, z, node) {
|
968
|
+
translate3d: function (x, y, z, node) {
|
953
969
|
node = node || this;
|
954
|
-
this.transform(
|
970
|
+
this.transform('translate3d(' + x + ',' + y + ',' + z + ')', node);
|
955
971
|
},
|
956
|
-
importHref: function(href, onload, onerror) {
|
957
|
-
var l = document.createElement(
|
958
|
-
l.rel =
|
972
|
+
importHref: function (href, onload, onerror) {
|
973
|
+
var l = document.createElement('link');
|
974
|
+
l.rel = 'import';
|
959
975
|
l.href = href;
|
960
976
|
if (onload) {
|
961
977
|
l.onload = onload.bind(this);
|
@@ -966,7 +982,7 @@ l.onerror = onerror.bind(this);
|
|
966
982
|
document.head.appendChild(l);
|
967
983
|
return l;
|
968
984
|
},
|
969
|
-
create: function(tag, props) {
|
985
|
+
create: function (tag, props) {
|
970
986
|
var elt = document.createElement(tag);
|
971
987
|
if (props) {
|
972
988
|
for (var n in props) {
|
@@ -975,15 +991,14 @@ elt[n] = props[n];
|
|
975
991
|
}
|
976
992
|
return elt;
|
977
993
|
},
|
978
|
-
mixin: function(target, source) {
|
994
|
+
mixin: function (target, source) {
|
979
995
|
for (var i in source) {
|
980
996
|
target[i] = source[i];
|
981
997
|
}
|
982
998
|
}
|
983
999
|
});
|
984
|
-
|
985
1000
|
Polymer.Bind = {
|
986
|
-
prepareModel: function(model) {
|
1001
|
+
prepareModel: function (model) {
|
987
1002
|
model._propertyEffects = {};
|
988
1003
|
model._bindListeners = [];
|
989
1004
|
var api = this._modelApi;
|
@@ -992,19 +1007,15 @@ model[n] = api[n];
|
|
992
1007
|
}
|
993
1008
|
},
|
994
1009
|
_modelApi: {
|
995
|
-
_notifyChange: function(property) {
|
996
|
-
var eventName = Polymer.CaseMap.camelToDashCase(property) +
|
997
|
-
this.fire(eventName, {
|
998
|
-
value: this[property]
|
999
|
-
}, {
|
1000
|
-
bubbles: false
|
1001
|
-
});
|
1010
|
+
_notifyChange: function (property) {
|
1011
|
+
var eventName = Polymer.CaseMap.camelToDashCase(property) + '-changed';
|
1012
|
+
this.fire(eventName, { value: this[property] }, { bubbles: false });
|
1002
1013
|
},
|
1003
|
-
_propertySet: function(property, value, effects) {
|
1014
|
+
_propertySet: function (property, value, effects) {
|
1004
1015
|
var old = this.__data__[property];
|
1005
1016
|
if (old !== value) {
|
1006
1017
|
this.__data__[property] = value;
|
1007
|
-
if (typeof value ==
|
1018
|
+
if (typeof value == 'object') {
|
1008
1019
|
this._clearPath(property);
|
1009
1020
|
}
|
1010
1021
|
if (this._propertyChanged) {
|
@@ -1016,37 +1027,37 @@ this._effectEffects(property, value, effects, old);
|
|
1016
1027
|
}
|
1017
1028
|
return old;
|
1018
1029
|
},
|
1019
|
-
_effectEffects: function(property, value, effects, old) {
|
1020
|
-
effects.forEach(function(fx) {
|
1021
|
-
var fn = Polymer.Bind[
|
1030
|
+
_effectEffects: function (property, value, effects, old) {
|
1031
|
+
effects.forEach(function (fx) {
|
1032
|
+
var fn = Polymer.Bind['_' + fx.kind + 'Effect'];
|
1022
1033
|
if (fn) {
|
1023
1034
|
fn.call(this, property, value, fx.effect, old);
|
1024
1035
|
}
|
1025
1036
|
}, this);
|
1026
1037
|
},
|
1027
|
-
_clearPath: function(path) {
|
1038
|
+
_clearPath: function (path) {
|
1028
1039
|
for (var prop in this.__data__) {
|
1029
|
-
if (prop.indexOf(path +
|
1040
|
+
if (prop.indexOf(path + '.') === 0) {
|
1030
1041
|
this.__data__[prop] = undefined;
|
1031
1042
|
}
|
1032
1043
|
}
|
1033
1044
|
}
|
1034
1045
|
},
|
1035
|
-
ensurePropertyEffects: function(model, property) {
|
1046
|
+
ensurePropertyEffects: function (model, property) {
|
1036
1047
|
var fx = model._propertyEffects[property];
|
1037
1048
|
if (!fx) {
|
1038
1049
|
fx = model._propertyEffects[property] = [];
|
1039
1050
|
}
|
1040
1051
|
return fx;
|
1041
1052
|
},
|
1042
|
-
addPropertyEffect: function(model, property, kind, effect) {
|
1053
|
+
addPropertyEffect: function (model, property, kind, effect) {
|
1043
1054
|
var fx = this.ensurePropertyEffects(model, property);
|
1044
1055
|
fx.push({
|
1045
1056
|
kind: kind,
|
1046
1057
|
effect: effect
|
1047
1058
|
});
|
1048
1059
|
},
|
1049
|
-
createBindings: function(model) {
|
1060
|
+
createBindings: function (model) {
|
1050
1061
|
var fx$ = model._propertyEffects;
|
1051
1062
|
if (fx$) {
|
1052
1063
|
for (var n in fx$) {
|
@@ -1056,43 +1067,43 @@ this._createAccessors(model, n, fx);
|
|
1056
1067
|
}
|
1057
1068
|
}
|
1058
1069
|
},
|
1059
|
-
_sortPropertyEffects: function() {
|
1070
|
+
_sortPropertyEffects: function () {
|
1060
1071
|
var EFFECT_ORDER = {
|
1061
|
-
compute: 0,
|
1062
|
-
annotation: 1,
|
1063
|
-
computedAnnotation: 2,
|
1064
|
-
reflect: 3,
|
1065
|
-
notify: 4,
|
1066
|
-
observer: 5,
|
1067
|
-
complexObserver: 6,
|
1068
|
-
|
1072
|
+
'compute': 0,
|
1073
|
+
'annotation': 1,
|
1074
|
+
'computedAnnotation': 2,
|
1075
|
+
'reflect': 3,
|
1076
|
+
'notify': 4,
|
1077
|
+
'observer': 5,
|
1078
|
+
'complexObserver': 6,
|
1079
|
+
'function': 7
|
1069
1080
|
};
|
1070
|
-
return function(a, b) {
|
1081
|
+
return function (a, b) {
|
1071
1082
|
return EFFECT_ORDER[a.kind] - EFFECT_ORDER[b.kind];
|
1072
1083
|
};
|
1073
1084
|
}(),
|
1074
|
-
_createAccessors: function(model, property, effects) {
|
1085
|
+
_createAccessors: function (model, property, effects) {
|
1075
1086
|
var defun = {
|
1076
|
-
get: function() {
|
1087
|
+
get: function () {
|
1077
1088
|
return this.__data__[property];
|
1078
1089
|
}
|
1079
1090
|
};
|
1080
|
-
var setter = function(value) {
|
1091
|
+
var setter = function (value) {
|
1081
1092
|
this._propertySet(property, value, effects);
|
1082
1093
|
};
|
1083
1094
|
if (model.getPropertyInfo && model.getPropertyInfo(property).readOnly) {
|
1084
|
-
model[
|
1095
|
+
model['_set' + this.upper(property)] = setter;
|
1085
1096
|
} else {
|
1086
1097
|
defun.set = setter;
|
1087
1098
|
}
|
1088
1099
|
Object.defineProperty(model, property, defun);
|
1089
1100
|
},
|
1090
|
-
upper: function(name) {
|
1101
|
+
upper: function (name) {
|
1091
1102
|
return name[0].toUpperCase() + name.substring(1);
|
1092
1103
|
},
|
1093
|
-
_addAnnotatedListener: function(model, index, property, path, event) {
|
1104
|
+
_addAnnotatedListener: function (model, index, property, path, event) {
|
1094
1105
|
var fn = this._notedListenerFactory(property, path, this._isStructured(path), this._isEventBogus);
|
1095
|
-
var eventName = event || Polymer.CaseMap.camelToDashCase(property) +
|
1106
|
+
var eventName = event || Polymer.CaseMap.camelToDashCase(property) + '-changed';
|
1096
1107
|
model._bindListeners.push({
|
1097
1108
|
index: index,
|
1098
1109
|
property: property,
|
@@ -1101,14 +1112,14 @@ changedFn: fn,
|
|
1101
1112
|
event: eventName
|
1102
1113
|
});
|
1103
1114
|
},
|
1104
|
-
_isStructured: function(path) {
|
1105
|
-
return path.indexOf(
|
1115
|
+
_isStructured: function (path) {
|
1116
|
+
return path.indexOf('.') > 0;
|
1106
1117
|
},
|
1107
|
-
_isEventBogus: function(e, target) {
|
1118
|
+
_isEventBogus: function (e, target) {
|
1108
1119
|
return e.path && e.path[0] !== target;
|
1109
1120
|
},
|
1110
|
-
_notedListenerFactory: function(property, path, isStructured, bogusTest) {
|
1111
|
-
return function(e, target) {
|
1121
|
+
_notedListenerFactory: function (property, path, isStructured, bogusTest) {
|
1122
|
+
return function (e, target) {
|
1112
1123
|
if (!bogusTest(e, target)) {
|
1113
1124
|
if (e.detail && e.detail.path) {
|
1114
1125
|
this.notifyPath(this._fixPath(path, property, e.detail.path), e.detail.value);
|
@@ -1125,22 +1136,21 @@ this.set(path, value);
|
|
1125
1136
|
}
|
1126
1137
|
};
|
1127
1138
|
},
|
1128
|
-
prepareInstance: function(inst) {
|
1139
|
+
prepareInstance: function (inst) {
|
1129
1140
|
inst.__data__ = Object.create(null);
|
1130
1141
|
},
|
1131
|
-
setupBindListeners: function(inst) {
|
1132
|
-
inst._bindListeners.forEach(function(info) {
|
1142
|
+
setupBindListeners: function (inst) {
|
1143
|
+
inst._bindListeners.forEach(function (info) {
|
1133
1144
|
var node = inst._nodes[info.index];
|
1134
1145
|
node.addEventListener(info.event, inst._notifyListener.bind(inst, info.changedFn));
|
1135
1146
|
});
|
1136
1147
|
}
|
1137
1148
|
};
|
1138
|
-
|
1139
1149
|
Polymer.Base.extend(Polymer.Bind, {
|
1140
|
-
_shouldAddListener: function(effect) {
|
1141
|
-
return effect.name && effect.mode ===
|
1150
|
+
_shouldAddListener: function (effect) {
|
1151
|
+
return effect.name && effect.mode === '{' && !effect.negate && effect.kind != 'attribute';
|
1142
1152
|
},
|
1143
|
-
_annotationEffect: function(source, value, effect) {
|
1153
|
+
_annotationEffect: function (source, value, effect) {
|
1144
1154
|
if (source != effect.value) {
|
1145
1155
|
value = this.get(effect.value);
|
1146
1156
|
this.__data__[effect.value] = value;
|
@@ -1150,24 +1160,24 @@ if (!effect.customEvent || this._nodes[effect.index][effect.name] !== calc) {
|
|
1150
1160
|
return this._applyEffectValue(calc, effect);
|
1151
1161
|
}
|
1152
1162
|
},
|
1153
|
-
_reflectEffect: function(source) {
|
1163
|
+
_reflectEffect: function (source) {
|
1154
1164
|
this.reflectPropertyToAttribute(source);
|
1155
1165
|
},
|
1156
|
-
_notifyEffect: function(source) {
|
1166
|
+
_notifyEffect: function (source) {
|
1157
1167
|
this._notifyChange(source);
|
1158
1168
|
},
|
1159
|
-
_functionEffect: function(source, value, fn, old) {
|
1169
|
+
_functionEffect: function (source, value, fn, old) {
|
1160
1170
|
fn.call(this, source, value, old);
|
1161
1171
|
},
|
1162
|
-
_observerEffect: function(source, value, effect, old) {
|
1172
|
+
_observerEffect: function (source, value, effect, old) {
|
1163
1173
|
var fn = this[effect.method];
|
1164
1174
|
if (fn) {
|
1165
1175
|
fn.call(this, value, old);
|
1166
1176
|
} else {
|
1167
|
-
this._warn(this._logf(
|
1177
|
+
this._warn(this._logf('_observerEffect', 'observer method `' + effect.method + '` not defined'));
|
1168
1178
|
}
|
1169
1179
|
},
|
1170
|
-
_complexObserverEffect: function(source, value, effect) {
|
1180
|
+
_complexObserverEffect: function (source, value, effect) {
|
1171
1181
|
var fn = this[effect.method];
|
1172
1182
|
if (fn) {
|
1173
1183
|
var args = Polymer.Bind._marshalArgs(this.__data__, effect, source, value);
|
@@ -1175,21 +1185,21 @@ if (args) {
|
|
1175
1185
|
fn.apply(this, args);
|
1176
1186
|
}
|
1177
1187
|
} else {
|
1178
|
-
this._warn(this._logf(
|
1188
|
+
this._warn(this._logf('_complexObserverEffect', 'observer method `' + effect.method + '` not defined'));
|
1179
1189
|
}
|
1180
1190
|
},
|
1181
|
-
_computeEffect: function(source, value, effect) {
|
1191
|
+
_computeEffect: function (source, value, effect) {
|
1182
1192
|
var args = Polymer.Bind._marshalArgs(this.__data__, effect, source, value);
|
1183
1193
|
if (args) {
|
1184
1194
|
var fn = this[effect.method];
|
1185
1195
|
if (fn) {
|
1186
1196
|
this[effect.property] = fn.apply(this, args);
|
1187
1197
|
} else {
|
1188
|
-
this._warn(this._logf(
|
1198
|
+
this._warn(this._logf('_computeEffect', 'compute method `' + effect.method + '` not defined'));
|
1189
1199
|
}
|
1190
1200
|
}
|
1191
1201
|
},
|
1192
|
-
_annotatedComputationEffect: function(source, value, effect) {
|
1202
|
+
_annotatedComputationEffect: function (source, value, effect) {
|
1193
1203
|
var computedHost = this._rootDataHost || this;
|
1194
1204
|
var fn = computedHost[effect.method];
|
1195
1205
|
if (fn) {
|
@@ -1202,15 +1212,16 @@ computedvalue = !computedvalue;
|
|
1202
1212
|
this._applyEffectValue(computedvalue, effect);
|
1203
1213
|
}
|
1204
1214
|
} else {
|
1205
|
-
computedHost._warn(computedHost._logf(
|
1215
|
+
computedHost._warn(computedHost._logf('_annotatedComputationEffect', 'compute method `' + effect.method + '` not defined'));
|
1206
1216
|
}
|
1207
1217
|
},
|
1208
|
-
_marshalArgs: function(model, effect, path, value) {
|
1218
|
+
_marshalArgs: function (model, effect, path, value) {
|
1209
1219
|
var values = [];
|
1210
1220
|
var args = effect.args;
|
1211
1221
|
for (var i = 0, l = args.length; i < l; i++) {
|
1212
1222
|
var arg = args[i];
|
1213
1223
|
var name = arg.name;
|
1224
|
+
var v;
|
1214
1225
|
if (arg.literal) {
|
1215
1226
|
v = arg.value;
|
1216
1227
|
} else if (arg.structured) {
|
@@ -1222,7 +1233,7 @@ if (args.length > 1 && v === undefined) {
|
|
1222
1233
|
return;
|
1223
1234
|
}
|
1224
1235
|
if (arg.wildcard) {
|
1225
|
-
var baseChanged = name.indexOf(path +
|
1236
|
+
var baseChanged = name.indexOf(path + '.') === 0;
|
1226
1237
|
var matches = effect.trigger.name.indexOf(name) === 0 && !baseChanged;
|
1227
1238
|
values[i] = {
|
1228
1239
|
path: matches ? path : name,
|
@@ -1236,19 +1247,18 @@ values[i] = v;
|
|
1236
1247
|
return values;
|
1237
1248
|
}
|
1238
1249
|
});
|
1239
|
-
|
1240
1250
|
Polymer.Base._addFeature({
|
1241
|
-
_addPropertyEffect: function(property, kind, effect) {
|
1251
|
+
_addPropertyEffect: function (property, kind, effect) {
|
1242
1252
|
Polymer.Bind.addPropertyEffect(this, property, kind, effect);
|
1243
1253
|
},
|
1244
|
-
_prepEffects: function() {
|
1254
|
+
_prepEffects: function () {
|
1245
1255
|
Polymer.Bind.prepareModel(this);
|
1246
1256
|
this._addAnnotationEffects(this._notes);
|
1247
1257
|
},
|
1248
|
-
_prepBindings: function() {
|
1258
|
+
_prepBindings: function () {
|
1249
1259
|
Polymer.Bind.createBindings(this);
|
1250
1260
|
},
|
1251
|
-
_addPropertyEffects: function(properties) {
|
1261
|
+
_addPropertyEffects: function (properties) {
|
1252
1262
|
if (properties) {
|
1253
1263
|
for (var p in properties) {
|
1254
1264
|
var prop = properties[p];
|
@@ -1259,10 +1269,10 @@ if (prop.computed) {
|
|
1259
1269
|
this._addComputedEffect(p, prop.computed);
|
1260
1270
|
}
|
1261
1271
|
if (prop.notify) {
|
1262
|
-
this._addPropertyEffect(p,
|
1272
|
+
this._addPropertyEffect(p, 'notify');
|
1263
1273
|
}
|
1264
1274
|
if (prop.reflectToAttribute) {
|
1265
|
-
this._addPropertyEffect(p,
|
1275
|
+
this._addPropertyEffect(p, 'reflect');
|
1266
1276
|
}
|
1267
1277
|
if (prop.readOnly) {
|
1268
1278
|
Polymer.Bind.ensurePropertyEffects(this, p);
|
@@ -1270,10 +1280,10 @@ Polymer.Bind.ensurePropertyEffects(this, p);
|
|
1270
1280
|
}
|
1271
1281
|
}
|
1272
1282
|
},
|
1273
|
-
_addComputedEffect: function(name, expression) {
|
1283
|
+
_addComputedEffect: function (name, expression) {
|
1274
1284
|
var sig = this._parseMethod(expression);
|
1275
|
-
sig.args.forEach(function(arg) {
|
1276
|
-
this._addPropertyEffect(arg.model,
|
1285
|
+
sig.args.forEach(function (arg) {
|
1286
|
+
this._addPropertyEffect(arg.model, 'compute', {
|
1277
1287
|
method: sig.method,
|
1278
1288
|
args: sig.args,
|
1279
1289
|
trigger: arg,
|
@@ -1281,39 +1291,39 @@ property: name
|
|
1281
1291
|
});
|
1282
1292
|
}, this);
|
1283
1293
|
},
|
1284
|
-
_addObserverEffect: function(property, observer) {
|
1285
|
-
this._addPropertyEffect(property,
|
1294
|
+
_addObserverEffect: function (property, observer) {
|
1295
|
+
this._addPropertyEffect(property, 'observer', {
|
1286
1296
|
method: observer,
|
1287
1297
|
property: property
|
1288
1298
|
});
|
1289
1299
|
},
|
1290
|
-
_addComplexObserverEffects: function(observers) {
|
1300
|
+
_addComplexObserverEffects: function (observers) {
|
1291
1301
|
if (observers) {
|
1292
|
-
observers.forEach(function(observer) {
|
1302
|
+
observers.forEach(function (observer) {
|
1293
1303
|
this._addComplexObserverEffect(observer);
|
1294
1304
|
}, this);
|
1295
1305
|
}
|
1296
1306
|
},
|
1297
|
-
_addComplexObserverEffect: function(observer) {
|
1307
|
+
_addComplexObserverEffect: function (observer) {
|
1298
1308
|
var sig = this._parseMethod(observer);
|
1299
|
-
sig.args.forEach(function(arg) {
|
1300
|
-
this._addPropertyEffect(arg.model,
|
1309
|
+
sig.args.forEach(function (arg) {
|
1310
|
+
this._addPropertyEffect(arg.model, 'complexObserver', {
|
1301
1311
|
method: sig.method,
|
1302
1312
|
args: sig.args,
|
1303
1313
|
trigger: arg
|
1304
1314
|
});
|
1305
1315
|
}, this);
|
1306
1316
|
},
|
1307
|
-
_addAnnotationEffects: function(notes) {
|
1317
|
+
_addAnnotationEffects: function (notes) {
|
1308
1318
|
this._nodes = [];
|
1309
|
-
notes.forEach(function(note) {
|
1319
|
+
notes.forEach(function (note) {
|
1310
1320
|
var index = this._nodes.push(note) - 1;
|
1311
|
-
note.bindings.forEach(function(binding) {
|
1321
|
+
note.bindings.forEach(function (binding) {
|
1312
1322
|
this._addAnnotationEffect(binding, index);
|
1313
1323
|
}, this);
|
1314
1324
|
}, this);
|
1315
1325
|
},
|
1316
|
-
_addAnnotationEffect: function(note, index) {
|
1326
|
+
_addAnnotationEffect: function (note, index) {
|
1317
1327
|
if (Polymer.Bind._shouldAddListener(note)) {
|
1318
1328
|
Polymer.Bind._addAnnotatedListener(this, index, note.name, note.value, note.event);
|
1319
1329
|
}
|
@@ -1321,23 +1331,23 @@ if (note.signature) {
|
|
1321
1331
|
this._addAnnotatedComputationEffect(note, index);
|
1322
1332
|
} else {
|
1323
1333
|
note.index = index;
|
1324
|
-
this._addPropertyEffect(note.model,
|
1334
|
+
this._addPropertyEffect(note.model, 'annotation', note);
|
1325
1335
|
}
|
1326
1336
|
},
|
1327
|
-
_addAnnotatedComputationEffect: function(note, index) {
|
1337
|
+
_addAnnotatedComputationEffect: function (note, index) {
|
1328
1338
|
var sig = note.signature;
|
1329
1339
|
if (sig.static) {
|
1330
|
-
this.__addAnnotatedComputationEffect(
|
1340
|
+
this.__addAnnotatedComputationEffect('__static__', index, note, sig, null);
|
1331
1341
|
} else {
|
1332
|
-
sig.args.forEach(function(arg) {
|
1342
|
+
sig.args.forEach(function (arg) {
|
1333
1343
|
if (!arg.literal) {
|
1334
1344
|
this.__addAnnotatedComputationEffect(arg.model, index, note, sig, arg);
|
1335
1345
|
}
|
1336
1346
|
}, this);
|
1337
1347
|
}
|
1338
1348
|
},
|
1339
|
-
__addAnnotatedComputationEffect: function(property, index, note, sig, trigger) {
|
1340
|
-
this._addPropertyEffect(property,
|
1349
|
+
__addAnnotatedComputationEffect: function (property, index, note, sig, trigger) {
|
1350
|
+
this._addPropertyEffect(property, 'annotatedComputation', {
|
1341
1351
|
index: index,
|
1342
1352
|
kind: note.kind,
|
1343
1353
|
property: note.name,
|
@@ -1347,15 +1357,15 @@ args: sig.args,
|
|
1347
1357
|
trigger: trigger
|
1348
1358
|
});
|
1349
1359
|
},
|
1350
|
-
_parseMethod: function(expression) {
|
1360
|
+
_parseMethod: function (expression) {
|
1351
1361
|
var m = expression.match(/(\w*)\((.*)\)/);
|
1352
1362
|
if (m) {
|
1353
1363
|
var sig = {
|
1354
1364
|
method: m[1],
|
1355
|
-
|
1365
|
+
static: true
|
1356
1366
|
};
|
1357
1367
|
if (m[2].trim()) {
|
1358
|
-
var args = m[2].replace(/\\,/g,
|
1368
|
+
var args = m[2].replace(/\\,/g, ',').split(',');
|
1359
1369
|
return this._parseArgs(args, sig);
|
1360
1370
|
} else {
|
1361
1371
|
sig.args = Polymer.nar;
|
@@ -1363,8 +1373,8 @@ return sig;
|
|
1363
1373
|
}
|
1364
1374
|
}
|
1365
1375
|
},
|
1366
|
-
_parseArgs: function(argList, sig) {
|
1367
|
-
sig.args = argList.map(function(rawArg) {
|
1376
|
+
_parseArgs: function (argList, sig) {
|
1377
|
+
sig.args = argList.map(function (rawArg) {
|
1368
1378
|
var arg = this._parseArg(rawArg);
|
1369
1379
|
if (!arg.literal) {
|
1370
1380
|
sig.static = false;
|
@@ -1373,32 +1383,31 @@ return arg;
|
|
1373
1383
|
}, this);
|
1374
1384
|
return sig;
|
1375
1385
|
},
|
1376
|
-
_parseArg: function(rawArg) {
|
1377
|
-
var arg = rawArg.trim().replace(/,/g,
|
1386
|
+
_parseArg: function (rawArg) {
|
1387
|
+
var arg = rawArg.trim().replace(/,/g, ',').replace(/\\(.)/g, '$1');
|
1378
1388
|
var a = {
|
1379
1389
|
name: arg,
|
1380
1390
|
model: this._modelForPath(arg)
|
1381
1391
|
};
|
1382
1392
|
var fc = arg[0];
|
1383
|
-
if (fc >=
|
1384
|
-
fc =
|
1393
|
+
if (fc >= '0' && fc <= '9') {
|
1394
|
+
fc = '#';
|
1385
1395
|
}
|
1386
1396
|
switch (fc) {
|
1387
|
-
case
|
1397
|
+
case '\'':
|
1388
1398
|
case '"':
|
1389
1399
|
a.value = arg.slice(1, -1);
|
1390
1400
|
a.literal = true;
|
1391
1401
|
break;
|
1392
|
-
|
1393
|
-
case "#":
|
1402
|
+
case '#':
|
1394
1403
|
a.value = Number(arg);
|
1395
1404
|
a.literal = true;
|
1396
1405
|
break;
|
1397
1406
|
}
|
1398
1407
|
if (!a.literal) {
|
1399
|
-
a.structured = arg.indexOf(
|
1408
|
+
a.structured = arg.indexOf('.') > 0;
|
1400
1409
|
if (a.structured) {
|
1401
|
-
a.wildcard = arg.slice(-2) ==
|
1410
|
+
a.wildcard = arg.slice(-2) == '.*';
|
1402
1411
|
if (a.wildcard) {
|
1403
1412
|
a.name = arg.slice(0, -2);
|
1404
1413
|
}
|
@@ -1406,50 +1415,49 @@ a.name = arg.slice(0, -2);
|
|
1406
1415
|
}
|
1407
1416
|
return a;
|
1408
1417
|
},
|
1409
|
-
_marshalInstanceEffects: function() {
|
1418
|
+
_marshalInstanceEffects: function () {
|
1410
1419
|
Polymer.Bind.prepareInstance(this);
|
1411
1420
|
Polymer.Bind.setupBindListeners(this);
|
1412
1421
|
},
|
1413
|
-
_applyEffectValue: function(value, info) {
|
1422
|
+
_applyEffectValue: function (value, info) {
|
1414
1423
|
var node = this._nodes[info.index];
|
1415
|
-
var property = info.property || info.name ||
|
1416
|
-
if (info.kind ==
|
1424
|
+
var property = info.property || info.name || 'textContent';
|
1425
|
+
if (info.kind == 'attribute') {
|
1417
1426
|
this.serializeValueToAttribute(value, property, node);
|
1418
1427
|
} else {
|
1419
|
-
if (property ===
|
1428
|
+
if (property === 'className') {
|
1420
1429
|
value = this._scopeElementClass(node, value);
|
1421
1430
|
}
|
1422
|
-
if (property ===
|
1423
|
-
value = value == undefined ?
|
1431
|
+
if (property === 'textContent' || node.localName == 'input' && property == 'value') {
|
1432
|
+
value = value == undefined ? '' : value;
|
1424
1433
|
}
|
1425
1434
|
return node[property] = value;
|
1426
1435
|
}
|
1427
1436
|
},
|
1428
|
-
_executeStaticEffects: function() {
|
1437
|
+
_executeStaticEffects: function () {
|
1429
1438
|
if (this._propertyEffects.__static__) {
|
1430
|
-
this._effectEffects(
|
1439
|
+
this._effectEffects('__static__', null, this._propertyEffects.__static__);
|
1431
1440
|
}
|
1432
1441
|
}
|
1433
1442
|
});
|
1434
|
-
|
1435
1443
|
Polymer.Base._addFeature({
|
1436
|
-
_setupConfigure: function(initialConfig) {
|
1444
|
+
_setupConfigure: function (initialConfig) {
|
1437
1445
|
this._config = initialConfig || {};
|
1438
1446
|
this._handlers = [];
|
1439
1447
|
},
|
1440
|
-
_marshalAttributes: function() {
|
1448
|
+
_marshalAttributes: function () {
|
1441
1449
|
this._takeAttributesToModel(this._config);
|
1442
1450
|
},
|
1443
|
-
_configValue: function(name, value) {
|
1451
|
+
_configValue: function (name, value) {
|
1444
1452
|
this._config[name] = value;
|
1445
1453
|
},
|
1446
|
-
_beforeClientsReady: function() {
|
1454
|
+
_beforeClientsReady: function () {
|
1447
1455
|
this._configure();
|
1448
1456
|
},
|
1449
|
-
_configure: function() {
|
1457
|
+
_configure: function () {
|
1450
1458
|
this._configureAnnotationReferences();
|
1451
1459
|
var config = {};
|
1452
|
-
this.behaviors.forEach(function(b) {
|
1460
|
+
this.behaviors.forEach(function (b) {
|
1453
1461
|
this._configureProperties(b.properties, config);
|
1454
1462
|
}, this);
|
1455
1463
|
this._configureProperties(this.properties, config);
|
@@ -1457,33 +1465,33 @@ this._mixinConfigure(config, this._config);
|
|
1457
1465
|
this._config = config;
|
1458
1466
|
this._distributeConfig(this._config);
|
1459
1467
|
},
|
1460
|
-
_configureProperties: function(properties, config) {
|
1468
|
+
_configureProperties: function (properties, config) {
|
1461
1469
|
for (var i in properties) {
|
1462
1470
|
var c = properties[i];
|
1463
1471
|
if (c.value !== undefined) {
|
1464
1472
|
var value = c.value;
|
1465
|
-
if (typeof value ==
|
1473
|
+
if (typeof value == 'function') {
|
1466
1474
|
value = value.call(this, this._config);
|
1467
1475
|
}
|
1468
1476
|
config[i] = value;
|
1469
1477
|
}
|
1470
1478
|
}
|
1471
1479
|
},
|
1472
|
-
_mixinConfigure: function(a, b) {
|
1480
|
+
_mixinConfigure: function (a, b) {
|
1473
1481
|
for (var prop in b) {
|
1474
1482
|
if (!this.getPropertyInfo(prop).readOnly) {
|
1475
1483
|
a[prop] = b[prop];
|
1476
1484
|
}
|
1477
1485
|
}
|
1478
1486
|
},
|
1479
|
-
_distributeConfig: function(config) {
|
1487
|
+
_distributeConfig: function (config) {
|
1480
1488
|
var fx$ = this._propertyEffects;
|
1481
1489
|
if (fx$) {
|
1482
1490
|
for (var p in config) {
|
1483
1491
|
var fx = fx$[p];
|
1484
1492
|
if (fx) {
|
1485
1493
|
for (var i = 0, l = fx.length, x; i < l && (x = fx[i]); i++) {
|
1486
|
-
if (x.kind ===
|
1494
|
+
if (x.kind === 'annotation') {
|
1487
1495
|
var node = this._nodes[x.effect.index];
|
1488
1496
|
if (node._configValue) {
|
1489
1497
|
var value = p === x.effect.value ? config[p] : this.get(x.effect.value, config);
|
@@ -1495,12 +1503,12 @@ node._configValue(x.effect.name, value);
|
|
1495
1503
|
}
|
1496
1504
|
}
|
1497
1505
|
},
|
1498
|
-
_afterClientsReady: function() {
|
1506
|
+
_afterClientsReady: function () {
|
1499
1507
|
this._executeStaticEffects();
|
1500
1508
|
this._applyConfig(this._config);
|
1501
1509
|
this._flushHandlers();
|
1502
1510
|
},
|
1503
|
-
_applyConfig: function(config) {
|
1511
|
+
_applyConfig: function (config) {
|
1504
1512
|
for (var n in config) {
|
1505
1513
|
if (this[n] === undefined) {
|
1506
1514
|
var effects = this._propertyEffects[n];
|
@@ -1512,28 +1520,31 @@ this[n] = config[n];
|
|
1512
1520
|
}
|
1513
1521
|
}
|
1514
1522
|
},
|
1515
|
-
_notifyListener: function(fn, e) {
|
1523
|
+
_notifyListener: function (fn, e) {
|
1516
1524
|
if (!this._clientsReadied) {
|
1517
|
-
this._queueHandler([
|
1525
|
+
this._queueHandler([
|
1526
|
+
fn,
|
1527
|
+
e,
|
1528
|
+
e.target
|
1529
|
+
]);
|
1518
1530
|
} else {
|
1519
1531
|
return fn.call(this, e, e.target);
|
1520
1532
|
}
|
1521
1533
|
},
|
1522
|
-
_queueHandler: function(args) {
|
1534
|
+
_queueHandler: function (args) {
|
1523
1535
|
this._handlers.push(args);
|
1524
1536
|
},
|
1525
|
-
_flushHandlers: function() {
|
1537
|
+
_flushHandlers: function () {
|
1526
1538
|
var h$ = this._handlers;
|
1527
1539
|
for (var i = 0, l = h$.length, h; i < l && (h = h$[i]); i++) {
|
1528
1540
|
h[0].call(this, h[1], h[2]);
|
1529
1541
|
}
|
1530
1542
|
}
|
1531
1543
|
});
|
1532
|
-
|
1533
|
-
|
1534
|
-
"use strict";
|
1544
|
+
(function () {
|
1545
|
+
'use strict';
|
1535
1546
|
Polymer.Base._addFeature({
|
1536
|
-
notifyPath: function(path, value, fromAbove) {
|
1547
|
+
notifyPath: function (path, value, fromAbove) {
|
1537
1548
|
var old = this._propertySet(path, value);
|
1538
1549
|
if (old !== value) {
|
1539
1550
|
this._pathEffector(path, value);
|
@@ -1542,21 +1553,21 @@ this._notifyPath(path, value);
|
|
1542
1553
|
}
|
1543
1554
|
}
|
1544
1555
|
},
|
1545
|
-
_getPathParts: function(path) {
|
1556
|
+
_getPathParts: function (path) {
|
1546
1557
|
if (Array.isArray(path)) {
|
1547
1558
|
var parts = [];
|
1548
1559
|
for (var i = 0; i < path.length; i++) {
|
1549
|
-
var args = path[i].toString().split(
|
1560
|
+
var args = path[i].toString().split('.');
|
1550
1561
|
for (var j = 0; j < args.length; j++) {
|
1551
1562
|
parts.push(args[j]);
|
1552
1563
|
}
|
1553
1564
|
}
|
1554
1565
|
return parts;
|
1555
1566
|
} else {
|
1556
|
-
return path.toString().split(
|
1567
|
+
return path.toString().split('.');
|
1557
1568
|
}
|
1558
1569
|
},
|
1559
|
-
set: function(path, value, root) {
|
1570
|
+
set: function (path, value, root) {
|
1560
1571
|
var prop = root || this;
|
1561
1572
|
var parts = this._getPathParts(path);
|
1562
1573
|
var array;
|
@@ -1574,13 +1585,13 @@ array = Array.isArray(prop) ? prop : null;
|
|
1574
1585
|
}
|
1575
1586
|
prop[last] = value;
|
1576
1587
|
if (!root) {
|
1577
|
-
this.notifyPath(parts.join(
|
1588
|
+
this.notifyPath(parts.join('.'), value);
|
1578
1589
|
}
|
1579
1590
|
} else {
|
1580
1591
|
prop[path] = value;
|
1581
1592
|
}
|
1582
1593
|
},
|
1583
|
-
get: function(path, root) {
|
1594
|
+
get: function (path, root) {
|
1584
1595
|
var prop = root || this;
|
1585
1596
|
var parts = this._getPathParts(path);
|
1586
1597
|
var last = parts.pop();
|
@@ -1592,12 +1603,12 @@ return;
|
|
1592
1603
|
}
|
1593
1604
|
return prop[last];
|
1594
1605
|
},
|
1595
|
-
_pathEffector: function(path, value) {
|
1606
|
+
_pathEffector: function (path, value) {
|
1596
1607
|
var model = this._modelForPath(path);
|
1597
1608
|
var fx$ = this._propertyEffects[model];
|
1598
1609
|
if (fx$) {
|
1599
|
-
fx$.forEach(function(fx) {
|
1600
|
-
var fxFn = this[
|
1610
|
+
fx$.forEach(function (fx) {
|
1611
|
+
var fxFn = this['_' + fx.kind + 'PathEffect'];
|
1601
1612
|
if (fxFn) {
|
1602
1613
|
fxFn.call(this, path, value, fx.effect);
|
1603
1614
|
}
|
@@ -1607,10 +1618,10 @@ if (this._boundPaths) {
|
|
1607
1618
|
this._notifyBoundPaths(path, value);
|
1608
1619
|
}
|
1609
1620
|
},
|
1610
|
-
_annotationPathEffect: function(path, value, effect) {
|
1611
|
-
if (effect.value === path || effect.value.indexOf(path +
|
1621
|
+
_annotationPathEffect: function (path, value, effect) {
|
1622
|
+
if (effect.value === path || effect.value.indexOf(path + '.') === 0) {
|
1612
1623
|
Polymer.Bind._annotationEffect.call(this, path, value, effect);
|
1613
|
-
} else if (path.indexOf(effect.value +
|
1624
|
+
} else if (path.indexOf(effect.value + '.') === 0 && !effect.negate) {
|
1614
1625
|
var node = this._nodes[effect.index];
|
1615
1626
|
if (node && node.notifyPath) {
|
1616
1627
|
var p = this._fixPath(effect.name, effect.value, path);
|
@@ -1618,26 +1629,26 @@ node.notifyPath(p, value, true);
|
|
1618
1629
|
}
|
1619
1630
|
}
|
1620
1631
|
},
|
1621
|
-
_complexObserverPathEffect: function(path, value, effect) {
|
1632
|
+
_complexObserverPathEffect: function (path, value, effect) {
|
1622
1633
|
if (this._pathMatchesEffect(path, effect)) {
|
1623
1634
|
Polymer.Bind._complexObserverEffect.call(this, path, value, effect);
|
1624
1635
|
}
|
1625
1636
|
},
|
1626
|
-
_computePathEffect: function(path, value, effect) {
|
1637
|
+
_computePathEffect: function (path, value, effect) {
|
1627
1638
|
if (this._pathMatchesEffect(path, effect)) {
|
1628
1639
|
Polymer.Bind._computeEffect.call(this, path, value, effect);
|
1629
1640
|
}
|
1630
1641
|
},
|
1631
|
-
_annotatedComputationPathEffect: function(path, value, effect) {
|
1642
|
+
_annotatedComputationPathEffect: function (path, value, effect) {
|
1632
1643
|
if (this._pathMatchesEffect(path, effect)) {
|
1633
1644
|
Polymer.Bind._annotatedComputationEffect.call(this, path, value, effect);
|
1634
1645
|
}
|
1635
1646
|
},
|
1636
|
-
_pathMatchesEffect: function(path, effect) {
|
1647
|
+
_pathMatchesEffect: function (path, effect) {
|
1637
1648
|
var effectArg = effect.trigger.name;
|
1638
|
-
return effectArg == path || effectArg.indexOf(path +
|
1649
|
+
return effectArg == path || effectArg.indexOf(path + '.') === 0 || effect.trigger.wildcard && path.indexOf(effectArg) === 0;
|
1639
1650
|
},
|
1640
|
-
linkPaths: function(to, from) {
|
1651
|
+
linkPaths: function (to, from) {
|
1641
1652
|
this._boundPaths = this._boundPaths || {};
|
1642
1653
|
if (from) {
|
1643
1654
|
this._boundPaths[to] = from;
|
@@ -1645,21 +1656,21 @@ this._boundPaths[to] = from;
|
|
1645
1656
|
this.unbindPath(to);
|
1646
1657
|
}
|
1647
1658
|
},
|
1648
|
-
unlinkPaths: function(path) {
|
1659
|
+
unlinkPaths: function (path) {
|
1649
1660
|
if (this._boundPaths) {
|
1650
1661
|
delete this._boundPaths[path];
|
1651
1662
|
}
|
1652
1663
|
},
|
1653
|
-
_notifyBoundPaths: function(path, value) {
|
1664
|
+
_notifyBoundPaths: function (path, value) {
|
1654
1665
|
var from, to;
|
1655
1666
|
for (var a in this._boundPaths) {
|
1656
1667
|
var b = this._boundPaths[a];
|
1657
|
-
if (path.indexOf(a +
|
1668
|
+
if (path.indexOf(a + '.') == 0) {
|
1658
1669
|
from = a;
|
1659
1670
|
to = b;
|
1660
1671
|
break;
|
1661
1672
|
}
|
1662
|
-
if (path.indexOf(b +
|
1673
|
+
if (path.indexOf(b + '.') == 0) {
|
1663
1674
|
from = b;
|
1664
1675
|
to = a;
|
1665
1676
|
break;
|
@@ -1670,45 +1681,43 @@ var p = this._fixPath(to, from, path);
|
|
1670
1681
|
this.notifyPath(p, value);
|
1671
1682
|
}
|
1672
1683
|
},
|
1673
|
-
_fixPath: function(property, root, path) {
|
1684
|
+
_fixPath: function (property, root, path) {
|
1674
1685
|
return property + path.slice(root.length);
|
1675
1686
|
},
|
1676
|
-
_notifyPath: function(path, value) {
|
1687
|
+
_notifyPath: function (path, value) {
|
1677
1688
|
var rootName = this._modelForPath(path);
|
1678
1689
|
var dashCaseName = Polymer.CaseMap.camelToDashCase(rootName);
|
1679
1690
|
var eventName = dashCaseName + this._EVENT_CHANGED;
|
1680
1691
|
this.fire(eventName, {
|
1681
1692
|
path: path,
|
1682
1693
|
value: value
|
1683
|
-
}, {
|
1684
|
-
bubbles: false
|
1685
|
-
});
|
1694
|
+
}, { bubbles: false });
|
1686
1695
|
},
|
1687
|
-
_modelForPath: function(path) {
|
1688
|
-
var dot = path.indexOf(
|
1696
|
+
_modelForPath: function (path) {
|
1697
|
+
var dot = path.indexOf('.');
|
1689
1698
|
return dot < 0 ? path : path.slice(0, dot);
|
1690
1699
|
},
|
1691
|
-
_EVENT_CHANGED:
|
1692
|
-
_notifySplice: function(array, path, index, added, removed) {
|
1693
|
-
var splices = [
|
1700
|
+
_EVENT_CHANGED: '-changed',
|
1701
|
+
_notifySplice: function (array, path, index, added, removed) {
|
1702
|
+
var splices = [{
|
1694
1703
|
index: index,
|
1695
1704
|
addedCount: added,
|
1696
1705
|
removed: removed,
|
1697
1706
|
object: array,
|
1698
|
-
type:
|
1699
|
-
}
|
1707
|
+
type: 'splice'
|
1708
|
+
}];
|
1700
1709
|
var change = {
|
1701
1710
|
keySplices: Polymer.Collection.get(array).applySplices(splices),
|
1702
1711
|
indexSplices: splices
|
1703
1712
|
};
|
1704
|
-
this.set(path +
|
1713
|
+
this.set(path + '.splices', change);
|
1705
1714
|
if (added != removed.length) {
|
1706
|
-
this.notifyPath(path +
|
1715
|
+
this.notifyPath(path + '.length', array.length);
|
1707
1716
|
}
|
1708
1717
|
change.keySplices = null;
|
1709
1718
|
change.indexSplices = null;
|
1710
1719
|
},
|
1711
|
-
push: function(path) {
|
1720
|
+
push: function (path) {
|
1712
1721
|
var array = this.get(path);
|
1713
1722
|
var args = Array.prototype.slice.call(arguments, 1);
|
1714
1723
|
var len = array.length;
|
@@ -1716,7 +1725,7 @@ var ret = array.push.apply(array, args);
|
|
1716
1725
|
this._notifySplice(array, path, len, args.length, []);
|
1717
1726
|
return ret;
|
1718
1727
|
},
|
1719
|
-
pop: function(path) {
|
1728
|
+
pop: function (path) {
|
1720
1729
|
var array = this.get(path);
|
1721
1730
|
var args = Array.prototype.slice.call(arguments, 1);
|
1722
1731
|
var rem = array.slice(-1);
|
@@ -1724,7 +1733,7 @@ var ret = array.pop.apply(array, args);
|
|
1724
1733
|
this._notifySplice(array, path, array.length, 0, rem);
|
1725
1734
|
return ret;
|
1726
1735
|
},
|
1727
|
-
splice: function(path, start, deleteCount) {
|
1736
|
+
splice: function (path, start, deleteCount) {
|
1728
1737
|
var array = this.get(path);
|
1729
1738
|
var args = Array.prototype.slice.call(arguments, 1);
|
1730
1739
|
var rem = array.slice(start, start + deleteCount);
|
@@ -1732,14 +1741,14 @@ var ret = array.splice.apply(array, args);
|
|
1732
1741
|
this._notifySplice(array, path, start, args.length - 2, rem);
|
1733
1742
|
return ret;
|
1734
1743
|
},
|
1735
|
-
shift: function(path) {
|
1744
|
+
shift: function (path) {
|
1736
1745
|
var array = this.get(path);
|
1737
1746
|
var args = Array.prototype.slice.call(arguments, 1);
|
1738
1747
|
var ret = array.shift.apply(array, args);
|
1739
|
-
this._notifySplice(array, path, 0, 0, [
|
1748
|
+
this._notifySplice(array, path, 0, 0, [ret]);
|
1740
1749
|
return ret;
|
1741
1750
|
},
|
1742
|
-
unshift: function(path) {
|
1751
|
+
unshift: function (path) {
|
1743
1752
|
var array = this.get(path);
|
1744
1753
|
var args = Array.prototype.slice.call(arguments, 1);
|
1745
1754
|
var ret = array.unshift.apply(array, args);
|
@@ -1747,30 +1756,28 @@ this._notifySplice(array, path, 0, args.length, []);
|
|
1747
1756
|
return ret;
|
1748
1757
|
}
|
1749
1758
|
});
|
1750
|
-
}
|
1751
|
-
|
1759
|
+
}());
|
1752
1760
|
Polymer.Base._addFeature({
|
1753
|
-
resolveUrl: function(url) {
|
1761
|
+
resolveUrl: function (url) {
|
1754
1762
|
var module = Polymer.DomModule.import(this.is);
|
1755
|
-
var root =
|
1763
|
+
var root = '';
|
1756
1764
|
if (module) {
|
1757
|
-
var assetPath = module.getAttribute(
|
1765
|
+
var assetPath = module.getAttribute('assetpath') || '';
|
1758
1766
|
root = Polymer.ResolveUrl.resolveUrl(assetPath, module.ownerDocument.baseURI);
|
1759
1767
|
}
|
1760
1768
|
return Polymer.ResolveUrl.resolveUrl(url, root);
|
1761
1769
|
}
|
1762
1770
|
});
|
1763
|
-
|
1764
|
-
Polymer.CssParse = function() {
|
1771
|
+
Polymer.CssParse = function () {
|
1765
1772
|
var api = {
|
1766
|
-
parse: function(text) {
|
1773
|
+
parse: function (text) {
|
1767
1774
|
text = this._clean(text);
|
1768
1775
|
return this._parseCss(this._lex(text), text);
|
1769
1776
|
},
|
1770
|
-
_clean: function(cssText) {
|
1771
|
-
return cssText.replace(rx.comments,
|
1777
|
+
_clean: function (cssText) {
|
1778
|
+
return cssText.replace(rx.comments, '').replace(rx.port, '');
|
1772
1779
|
},
|
1773
|
-
_lex: function(text) {
|
1780
|
+
_lex: function (text) {
|
1774
1781
|
var root = {
|
1775
1782
|
start: 0,
|
1776
1783
|
end: text.length
|
@@ -1791,7 +1798,6 @@ previous: previous
|
|
1791
1798
|
};
|
1792
1799
|
p.rules.push(n);
|
1793
1800
|
break;
|
1794
|
-
|
1795
1801
|
case this.CLOSE_BRACE:
|
1796
1802
|
n.end = i + 1;
|
1797
1803
|
n = n.parent || root;
|
@@ -1800,13 +1806,13 @@ break;
|
|
1800
1806
|
}
|
1801
1807
|
return root;
|
1802
1808
|
},
|
1803
|
-
_parseCss: function(node, text) {
|
1809
|
+
_parseCss: function (node, text) {
|
1804
1810
|
var t = text.substring(node.start, node.end - 1);
|
1805
1811
|
node.parsedCssText = node.cssText = t.trim();
|
1806
1812
|
if (node.parent) {
|
1807
1813
|
var ss = node.previous ? node.previous.end : node.parent.start;
|
1808
1814
|
t = text.substring(ss, node.start - 1);
|
1809
|
-
t = t.substring(t.lastIndexOf(
|
1815
|
+
t = t.substring(t.lastIndexOf(';') + 1);
|
1810
1816
|
var s = node.parsedSelector = node.selector = t.trim();
|
1811
1817
|
node.atRule = s.indexOf(AT_START) === 0;
|
1812
1818
|
if (node.atRule) {
|
@@ -1831,9 +1837,9 @@ this._parseCss(r, text);
|
|
1831
1837
|
}
|
1832
1838
|
return node;
|
1833
1839
|
},
|
1834
|
-
stringify: function(node, preserveProperties, text) {
|
1835
|
-
text = text ||
|
1836
|
-
var cssText =
|
1840
|
+
stringify: function (node, preserveProperties, text) {
|
1841
|
+
text = text || '';
|
1842
|
+
var cssText = '';
|
1837
1843
|
if (node.cssText || node.rules) {
|
1838
1844
|
var r$ = node.rules;
|
1839
1845
|
if (r$ && (preserveProperties || !hasMixinRules(r$))) {
|
@@ -1844,17 +1850,17 @@ cssText = this.stringify(r, preserveProperties, cssText);
|
|
1844
1850
|
cssText = preserveProperties ? node.cssText : removeCustomProps(node.cssText);
|
1845
1851
|
cssText = cssText.trim();
|
1846
1852
|
if (cssText) {
|
1847
|
-
cssText =
|
1853
|
+
cssText = ' ' + cssText + '\n';
|
1848
1854
|
}
|
1849
1855
|
}
|
1850
1856
|
}
|
1851
1857
|
if (cssText) {
|
1852
1858
|
if (node.selector) {
|
1853
|
-
text += node.selector +
|
1859
|
+
text += node.selector + ' ' + this.OPEN_BRACE + '\n';
|
1854
1860
|
}
|
1855
1861
|
text += cssText;
|
1856
1862
|
if (node.selector) {
|
1857
|
-
text += this.CLOSE_BRACE +
|
1863
|
+
text += this.CLOSE_BRACE + '\n\n';
|
1858
1864
|
}
|
1859
1865
|
}
|
1860
1866
|
return text;
|
@@ -1863,20 +1869,20 @@ types: {
|
|
1863
1869
|
STYLE_RULE: 1,
|
1864
1870
|
KEYFRAMES_RULE: 7,
|
1865
1871
|
MEDIA_RULE: 4,
|
1866
|
-
MIXIN_RULE:
|
1872
|
+
MIXIN_RULE: 1000
|
1867
1873
|
},
|
1868
|
-
OPEN_BRACE:
|
1869
|
-
CLOSE_BRACE:
|
1874
|
+
OPEN_BRACE: '{',
|
1875
|
+
CLOSE_BRACE: '}'
|
1870
1876
|
};
|
1871
1877
|
function hasMixinRules(rules) {
|
1872
1878
|
return rules[0].selector.indexOf(VAR_START) >= 0;
|
1873
1879
|
}
|
1874
1880
|
function removeCustomProps(cssText) {
|
1875
|
-
return cssText.replace(rx.customProp,
|
1881
|
+
return cssText.replace(rx.customProp, '').replace(rx.mixinProp, '').replace(rx.mixinApply, '').replace(rx.varApply, '');
|
1876
1882
|
}
|
1877
|
-
var VAR_START =
|
1878
|
-
var MEDIA_START =
|
1879
|
-
var AT_START =
|
1883
|
+
var VAR_START = '--';
|
1884
|
+
var MEDIA_START = '@media';
|
1885
|
+
var AT_START = '@';
|
1880
1886
|
var rx = {
|
1881
1887
|
comments: /\/\*[^*]*\*+([^\/*][^*]*\*+)*\//gim,
|
1882
1888
|
port: /@import[^;]*;/gim,
|
@@ -1888,12 +1894,11 @@ keyframesRule: /^@[^\s]*keyframes/
|
|
1888
1894
|
};
|
1889
1895
|
return api;
|
1890
1896
|
}();
|
1891
|
-
|
1892
|
-
Polymer.StyleUtil = function() {
|
1897
|
+
Polymer.StyleUtil = function () {
|
1893
1898
|
return {
|
1894
|
-
MODULE_STYLES_SELECTOR:
|
1895
|
-
toCssText: function(rules, callback, preserveProperties) {
|
1896
|
-
if (typeof rules ===
|
1899
|
+
MODULE_STYLES_SELECTOR: 'style, link[rel=import][type~=css]',
|
1900
|
+
toCssText: function (rules, callback, preserveProperties) {
|
1901
|
+
if (typeof rules === 'string') {
|
1897
1902
|
rules = this.parser.parse(rules);
|
1898
1903
|
}
|
1899
1904
|
if (callback) {
|
@@ -1901,21 +1906,21 @@ this.forEachStyleRule(rules, callback);
|
|
1901
1906
|
}
|
1902
1907
|
return this.parser.stringify(rules, preserveProperties);
|
1903
1908
|
},
|
1904
|
-
forRulesInStyles: function(styles, callback) {
|
1909
|
+
forRulesInStyles: function (styles, callback) {
|
1905
1910
|
for (var i = 0, l = styles.length, s; i < l && (s = styles[i]); i++) {
|
1906
1911
|
this.forEachStyleRule(this.rulesForStyle(s), callback);
|
1907
1912
|
}
|
1908
1913
|
},
|
1909
|
-
rulesForStyle: function(style) {
|
1914
|
+
rulesForStyle: function (style) {
|
1910
1915
|
if (!style.__cssRules) {
|
1911
1916
|
style.__cssRules = this.parser.parse(style.textContent);
|
1912
1917
|
}
|
1913
1918
|
return style.__cssRules;
|
1914
1919
|
},
|
1915
|
-
clearStyleRules: function(style) {
|
1920
|
+
clearStyleRules: function (style) {
|
1916
1921
|
style.__cssRules = null;
|
1917
1922
|
},
|
1918
|
-
forEachStyleRule: function(node, callback) {
|
1923
|
+
forEachStyleRule: function (node, callback) {
|
1919
1924
|
var s = node.selector;
|
1920
1925
|
var skipRules = false;
|
1921
1926
|
if (node.type === this.ruleTypes.STYLE_RULE) {
|
@@ -1930,28 +1935,28 @@ this.forEachStyleRule(r, callback);
|
|
1930
1935
|
}
|
1931
1936
|
}
|
1932
1937
|
},
|
1933
|
-
applyCss: function(cssText, moniker, target, afterNode) {
|
1934
|
-
var style = document.createElement(
|
1938
|
+
applyCss: function (cssText, moniker, target, afterNode) {
|
1939
|
+
var style = document.createElement('style');
|
1935
1940
|
if (moniker) {
|
1936
|
-
style.setAttribute(
|
1941
|
+
style.setAttribute('scope', moniker);
|
1937
1942
|
}
|
1938
1943
|
style.textContent = cssText;
|
1939
1944
|
target = target || document.head;
|
1940
1945
|
if (!afterNode) {
|
1941
|
-
var n$ = target.querySelectorAll(
|
1946
|
+
var n$ = target.querySelectorAll('style[scope]');
|
1942
1947
|
afterNode = n$[n$.length - 1];
|
1943
1948
|
}
|
1944
1949
|
target.insertBefore(style, afterNode && afterNode.nextSibling || target.firstChild);
|
1945
1950
|
return style;
|
1946
1951
|
},
|
1947
|
-
cssFromModule: function(moduleId) {
|
1952
|
+
cssFromModule: function (moduleId) {
|
1948
1953
|
var m = Polymer.DomModule.import(moduleId);
|
1949
1954
|
if (m && !m._cssText) {
|
1950
|
-
var cssText =
|
1955
|
+
var cssText = '';
|
1951
1956
|
var e$ = Array.prototype.slice.call(m.querySelectorAll(this.MODULE_STYLES_SELECTOR));
|
1952
1957
|
for (var i = 0, e; i < e$.length; i++) {
|
1953
1958
|
e = e$[i];
|
1954
|
-
if (e.localName ===
|
1959
|
+
if (e.localName === 'style') {
|
1955
1960
|
e = e.__appliedElement || e;
|
1956
1961
|
e.parentNode.removeChild(e);
|
1957
1962
|
} else {
|
@@ -1963,21 +1968,20 @@ cssText += Polymer.ResolveUrl.resolveCss(e.textContent, e.ownerDocument);
|
|
1963
1968
|
}
|
1964
1969
|
m._cssText = cssText;
|
1965
1970
|
}
|
1966
|
-
return m && m._cssText ||
|
1971
|
+
return m && m._cssText || '';
|
1967
1972
|
},
|
1968
1973
|
parser: Polymer.CssParse,
|
1969
1974
|
ruleTypes: Polymer.CssParse.types
|
1970
1975
|
};
|
1971
1976
|
}();
|
1972
|
-
|
1973
|
-
Polymer.StyleTransformer = function() {
|
1977
|
+
Polymer.StyleTransformer = function () {
|
1974
1978
|
var nativeShadow = Polymer.Settings.useNativeShadow;
|
1975
1979
|
var styleUtil = Polymer.StyleUtil;
|
1976
1980
|
var api = {
|
1977
|
-
dom: function(node, scope, useAttr, shouldRemoveScope) {
|
1978
|
-
this._transformDom(node, scope ||
|
1981
|
+
dom: function (node, scope, useAttr, shouldRemoveScope) {
|
1982
|
+
this._transformDom(node, scope || '', useAttr, shouldRemoveScope);
|
1979
1983
|
},
|
1980
|
-
_transformDom: function(node, selector, useAttr, shouldRemoveScope) {
|
1984
|
+
_transformDom: function (node, selector, useAttr, shouldRemoveScope) {
|
1981
1985
|
if (node.setAttribute) {
|
1982
1986
|
this.element(node, selector, useAttr, shouldRemoveScope);
|
1983
1987
|
}
|
@@ -1986,7 +1990,7 @@ for (var i = 0; i < c$.length; i++) {
|
|
1986
1990
|
this._transformDom(c$[i], selector, useAttr, shouldRemoveScope);
|
1987
1991
|
}
|
1988
1992
|
},
|
1989
|
-
element: function(element, scope, useAttr, shouldRemoveScope) {
|
1993
|
+
element: function (element, scope, useAttr, shouldRemoveScope) {
|
1990
1994
|
if (useAttr) {
|
1991
1995
|
if (shouldRemoveScope) {
|
1992
1996
|
element.removeAttribute(SCOPE_NAME);
|
@@ -2007,29 +2011,29 @@ element.classList.add(scope);
|
|
2007
2011
|
var c = element.getAttribute(CLASS);
|
2008
2012
|
if (shouldRemoveScope) {
|
2009
2013
|
if (c) {
|
2010
|
-
element.setAttribute(CLASS, c.replace(SCOPE_NAME,
|
2014
|
+
element.setAttribute(CLASS, c.replace(SCOPE_NAME, '').replace(scope, ''));
|
2011
2015
|
}
|
2012
2016
|
} else {
|
2013
|
-
element.setAttribute(CLASS, c + (c ?
|
2017
|
+
element.setAttribute(CLASS, c + (c ? ' ' : '') + SCOPE_NAME + ' ' + scope);
|
2014
2018
|
}
|
2015
2019
|
}
|
2016
2020
|
}
|
2017
2021
|
}
|
2018
2022
|
},
|
2019
|
-
elementStyles: function(element, callback) {
|
2023
|
+
elementStyles: function (element, callback) {
|
2020
2024
|
var styles = element._styles;
|
2021
|
-
var cssText =
|
2025
|
+
var cssText = '';
|
2022
2026
|
for (var i = 0, l = styles.length, s, text; i < l && (s = styles[i]); i++) {
|
2023
2027
|
var rules = styleUtil.rulesForStyle(s);
|
2024
|
-
cssText += nativeShadow ? styleUtil.toCssText(rules, callback) : this.css(rules, element.is, element.extends, callback, element._scopeCssViaAttr) +
|
2028
|
+
cssText += nativeShadow ? styleUtil.toCssText(rules, callback) : this.css(rules, element.is, element.extends, callback, element._scopeCssViaAttr) + '\n\n';
|
2025
2029
|
}
|
2026
2030
|
return cssText.trim();
|
2027
2031
|
},
|
2028
|
-
css: function(rules, scope, ext, callback, useAttr) {
|
2032
|
+
css: function (rules, scope, ext, callback, useAttr) {
|
2029
2033
|
var hostScope = this._calcHostScope(scope, ext);
|
2030
2034
|
scope = this._calcElementScope(scope, useAttr);
|
2031
2035
|
var self = this;
|
2032
|
-
return styleUtil.toCssText(rules, function(rule) {
|
2036
|
+
return styleUtil.toCssText(rules, function (rule) {
|
2033
2037
|
if (!rule.isScoped) {
|
2034
2038
|
self.rule(rule, scope, hostScope);
|
2035
2039
|
rule.isScoped = true;
|
@@ -2039,30 +2043,30 @@ callback(rule, scope, hostScope);
|
|
2039
2043
|
}
|
2040
2044
|
});
|
2041
2045
|
},
|
2042
|
-
_calcElementScope: function(scope, useAttr) {
|
2046
|
+
_calcElementScope: function (scope, useAttr) {
|
2043
2047
|
if (scope) {
|
2044
2048
|
return useAttr ? CSS_ATTR_PREFIX + scope + CSS_ATTR_SUFFIX : CSS_CLASS_PREFIX + scope;
|
2045
2049
|
} else {
|
2046
|
-
return
|
2050
|
+
return '';
|
2047
2051
|
}
|
2048
2052
|
},
|
2049
|
-
_calcHostScope: function(scope, ext) {
|
2050
|
-
return ext ?
|
2053
|
+
_calcHostScope: function (scope, ext) {
|
2054
|
+
return ext ? '[is=' + scope + ']' : scope;
|
2051
2055
|
},
|
2052
|
-
rule: function(rule, scope, hostScope) {
|
2056
|
+
rule: function (rule, scope, hostScope) {
|
2053
2057
|
this._transformRule(rule, this._transformComplexSelector, scope, hostScope);
|
2054
2058
|
},
|
2055
|
-
_transformRule: function(rule, transformer, scope, hostScope) {
|
2059
|
+
_transformRule: function (rule, transformer, scope, hostScope) {
|
2056
2060
|
var p$ = rule.selector.split(COMPLEX_SELECTOR_SEP);
|
2057
2061
|
for (var i = 0, l = p$.length, p; i < l && (p = p$[i]); i++) {
|
2058
2062
|
p$[i] = transformer.call(this, p, scope, hostScope);
|
2059
2063
|
}
|
2060
2064
|
rule.selector = p$.join(COMPLEX_SELECTOR_SEP);
|
2061
2065
|
},
|
2062
|
-
_transformComplexSelector: function(selector, scope, hostScope) {
|
2066
|
+
_transformComplexSelector: function (selector, scope, hostScope) {
|
2063
2067
|
var stop = false;
|
2064
2068
|
var self = this;
|
2065
|
-
selector = selector.replace(SIMPLE_SELECTOR_SEP, function(m, c, s) {
|
2069
|
+
selector = selector.replace(SIMPLE_SELECTOR_SEP, function (m, c, s) {
|
2066
2070
|
if (!stop) {
|
2067
2071
|
var o = self._transformCompoundSelector(s, c, scope, hostScope);
|
2068
2072
|
if (o.stop) {
|
@@ -2075,10 +2079,10 @@ return c + s;
|
|
2075
2079
|
});
|
2076
2080
|
return selector;
|
2077
2081
|
},
|
2078
|
-
_transformCompoundSelector: function(selector, combinator, scope, hostScope) {
|
2082
|
+
_transformCompoundSelector: function (selector, combinator, scope, hostScope) {
|
2079
2083
|
var jumpIndex = selector.search(SCOPE_JUMP);
|
2080
2084
|
if (selector.indexOf(HOST) >= 0) {
|
2081
|
-
selector = selector.replace(HOST_PAREN, function(m, host, paren) {
|
2085
|
+
selector = selector.replace(HOST_PAREN, function (m, host, paren) {
|
2082
2086
|
return hostScope + paren;
|
2083
2087
|
});
|
2084
2088
|
selector = selector.replace(HOST, hostScope);
|
@@ -2086,11 +2090,11 @@ selector = selector.replace(HOST, hostScope);
|
|
2086
2090
|
selector = scope ? this._transformSimpleSelector(selector, scope) : selector;
|
2087
2091
|
}
|
2088
2092
|
if (selector.indexOf(CONTENT) >= 0) {
|
2089
|
-
combinator =
|
2093
|
+
combinator = '';
|
2090
2094
|
}
|
2091
2095
|
var stop;
|
2092
2096
|
if (jumpIndex >= 0) {
|
2093
|
-
selector = selector.replace(SCOPE_JUMP,
|
2097
|
+
selector = selector.replace(SCOPE_JUMP, ' ');
|
2094
2098
|
stop = true;
|
2095
2099
|
}
|
2096
2100
|
return {
|
@@ -2099,45 +2103,44 @@ combinator: combinator,
|
|
2099
2103
|
stop: stop
|
2100
2104
|
};
|
2101
2105
|
},
|
2102
|
-
_transformSimpleSelector: function(selector, scope) {
|
2106
|
+
_transformSimpleSelector: function (selector, scope) {
|
2103
2107
|
var p$ = selector.split(PSEUDO_PREFIX);
|
2104
2108
|
p$[0] += scope;
|
2105
2109
|
return p$.join(PSEUDO_PREFIX);
|
2106
2110
|
},
|
2107
|
-
rootRule: function(rule) {
|
2111
|
+
rootRule: function (rule) {
|
2108
2112
|
this._transformRule(rule, this._transformRootSelector);
|
2109
2113
|
},
|
2110
|
-
_transformRootSelector: function(selector) {
|
2114
|
+
_transformRootSelector: function (selector) {
|
2111
2115
|
return selector.match(SCOPE_JUMP) ? this._transformComplexSelector(selector) : selector.trim() + SCOPE_ROOT_SELECTOR;
|
2112
2116
|
},
|
2113
|
-
SCOPE_NAME:
|
2117
|
+
SCOPE_NAME: 'style-scope'
|
2114
2118
|
};
|
2115
2119
|
var SCOPE_NAME = api.SCOPE_NAME;
|
2116
|
-
var SCOPE_ROOT_SELECTOR =
|
2117
|
-
var COMPLEX_SELECTOR_SEP =
|
2120
|
+
var SCOPE_ROOT_SELECTOR = ':not([' + SCOPE_NAME + '])' + ':not(.' + SCOPE_NAME + ')';
|
2121
|
+
var COMPLEX_SELECTOR_SEP = ',';
|
2118
2122
|
var SIMPLE_SELECTOR_SEP = /(^|[\s>+~]+)([^\s>+~]+)/g;
|
2119
|
-
var HOST =
|
2123
|
+
var HOST = ':host';
|
2120
2124
|
var HOST_PAREN = /(\:host)(?:\(((?:\([^)(]*\)|[^)(]*)+?)\))/g;
|
2121
|
-
var CONTENT =
|
2125
|
+
var CONTENT = '::content';
|
2122
2126
|
var SCOPE_JUMP = /\:\:content|\:\:shadow|\/deep\//;
|
2123
|
-
var CSS_CLASS_PREFIX =
|
2124
|
-
var CSS_ATTR_PREFIX =
|
2125
|
-
var CSS_ATTR_SUFFIX =
|
2126
|
-
var PSEUDO_PREFIX =
|
2127
|
-
var CLASS =
|
2127
|
+
var CSS_CLASS_PREFIX = '.';
|
2128
|
+
var CSS_ATTR_PREFIX = '[' + SCOPE_NAME + '~=';
|
2129
|
+
var CSS_ATTR_SUFFIX = ']';
|
2130
|
+
var PSEUDO_PREFIX = ':';
|
2131
|
+
var CLASS = 'class';
|
2128
2132
|
return api;
|
2129
2133
|
}();
|
2130
|
-
|
2131
|
-
Polymer.StyleExtends = function() {
|
2134
|
+
Polymer.StyleExtends = function () {
|
2132
2135
|
var styleUtil = Polymer.StyleUtil;
|
2133
2136
|
return {
|
2134
|
-
hasExtends: function(cssText) {
|
2137
|
+
hasExtends: function (cssText) {
|
2135
2138
|
return Boolean(cssText.match(this.rx.EXTEND));
|
2136
2139
|
},
|
2137
|
-
transform: function(style) {
|
2140
|
+
transform: function (style) {
|
2138
2141
|
var rules = styleUtil.rulesForStyle(style);
|
2139
2142
|
var self = this;
|
2140
|
-
styleUtil.forEachStyleRule(rules, function(rule) {
|
2143
|
+
styleUtil.forEachStyleRule(rules, function (rule) {
|
2141
2144
|
var map = self._mapRule(rule);
|
2142
2145
|
if (rule.parent) {
|
2143
2146
|
var m;
|
@@ -2149,18 +2152,18 @@ self._extendRule(rule, extendor);
|
|
2149
2152
|
}
|
2150
2153
|
}
|
2151
2154
|
}
|
2152
|
-
rule.cssText = rule.cssText.replace(self.rx.EXTEND,
|
2155
|
+
rule.cssText = rule.cssText.replace(self.rx.EXTEND, '');
|
2153
2156
|
});
|
2154
|
-
return styleUtil.toCssText(rules, function(rule) {
|
2157
|
+
return styleUtil.toCssText(rules, function (rule) {
|
2155
2158
|
if (rule.selector.match(self.rx.STRIP)) {
|
2156
|
-
rule.cssText =
|
2159
|
+
rule.cssText = '';
|
2157
2160
|
}
|
2158
2161
|
}, true);
|
2159
2162
|
},
|
2160
|
-
_mapRule: function(rule) {
|
2163
|
+
_mapRule: function (rule) {
|
2161
2164
|
if (rule.parent) {
|
2162
2165
|
var map = rule.parent.map || (rule.parent.map = {});
|
2163
|
-
var parts = rule.selector.split(
|
2166
|
+
var parts = rule.selector.split(',');
|
2164
2167
|
for (var i = 0, p; i < parts.length; i++) {
|
2165
2168
|
p = parts[i];
|
2166
2169
|
map[p.trim()] = rule;
|
@@ -2168,24 +2171,24 @@ map[p.trim()] = rule;
|
|
2168
2171
|
return map;
|
2169
2172
|
}
|
2170
2173
|
},
|
2171
|
-
_findExtendor: function(extend, rule) {
|
2174
|
+
_findExtendor: function (extend, rule) {
|
2172
2175
|
return rule.parent && rule.parent.map && rule.parent.map[extend] || this._findExtendor(extend, rule.parent);
|
2173
2176
|
},
|
2174
|
-
_extendRule: function(target, source) {
|
2177
|
+
_extendRule: function (target, source) {
|
2175
2178
|
if (target.parent !== source.parent) {
|
2176
2179
|
this._cloneAndAddRuleToParent(source, target.parent);
|
2177
2180
|
}
|
2178
2181
|
target.extends = target.extends || (target.extends = []);
|
2179
2182
|
target.extends.push(source);
|
2180
|
-
source.selector = source.selector.replace(this.rx.STRIP,
|
2181
|
-
source.selector = (source.selector && source.selector +
|
2183
|
+
source.selector = source.selector.replace(this.rx.STRIP, '');
|
2184
|
+
source.selector = (source.selector && source.selector + ',\n') + target.selector;
|
2182
2185
|
if (source.extends) {
|
2183
|
-
source.extends.forEach(function(e) {
|
2186
|
+
source.extends.forEach(function (e) {
|
2184
2187
|
this._extendRule(target, e);
|
2185
2188
|
}, this);
|
2186
2189
|
}
|
2187
2190
|
},
|
2188
|
-
_cloneAndAddRuleToParent: function(rule, parent) {
|
2191
|
+
_cloneAndAddRuleToParent: function (rule, parent) {
|
2189
2192
|
rule = Object.create(rule);
|
2190
2193
|
rule.parent = parent;
|
2191
2194
|
if (rule.extends) {
|
@@ -2199,21 +2202,20 @@ STRIP: /%[^,]*$/
|
|
2199
2202
|
}
|
2200
2203
|
};
|
2201
2204
|
}();
|
2202
|
-
|
2203
|
-
(function() {
|
2205
|
+
(function () {
|
2204
2206
|
var prepElement = Polymer.Base._prepElement;
|
2205
2207
|
var nativeShadow = Polymer.Settings.useNativeShadow;
|
2206
2208
|
var styleUtil = Polymer.StyleUtil;
|
2207
2209
|
var styleTransformer = Polymer.StyleTransformer;
|
2208
2210
|
var styleExtends = Polymer.StyleExtends;
|
2209
2211
|
Polymer.Base._addFeature({
|
2210
|
-
_prepElement: function(element) {
|
2212
|
+
_prepElement: function (element) {
|
2211
2213
|
if (this._encapsulateStyle) {
|
2212
2214
|
styleTransformer.element(element, this.is, this._scopeCssViaAttr);
|
2213
2215
|
}
|
2214
2216
|
prepElement.call(this, element);
|
2215
2217
|
},
|
2216
|
-
_prepStyles: function() {
|
2218
|
+
_prepStyles: function () {
|
2217
2219
|
if (this._encapsulateStyle === undefined) {
|
2218
2220
|
this._encapsulateStyle = !nativeShadow && Boolean(this._template);
|
2219
2221
|
}
|
@@ -2226,9 +2228,9 @@ this._scopeStyle = style;
|
|
2226
2228
|
}
|
2227
2229
|
}
|
2228
2230
|
},
|
2229
|
-
_collectStyles: function() {
|
2231
|
+
_collectStyles: function () {
|
2230
2232
|
var styles = [];
|
2231
|
-
var cssText =
|
2233
|
+
var cssText = '', m$ = this.styleModules;
|
2232
2234
|
if (m$) {
|
2233
2235
|
for (var i = 0, l = m$.length, m; i < l && (m = m$[i]); i++) {
|
2234
2236
|
cssText += styleUtil.cssFromModule(m);
|
@@ -2236,7 +2238,7 @@ cssText += styleUtil.cssFromModule(m);
|
|
2236
2238
|
}
|
2237
2239
|
cssText += styleUtil.cssFromModule(this.is);
|
2238
2240
|
if (cssText) {
|
2239
|
-
var style = document.createElement(
|
2241
|
+
var style = document.createElement('style');
|
2240
2242
|
style.textContent = cssText;
|
2241
2243
|
if (styleExtends.hasExtends(style.textContent)) {
|
2242
2244
|
cssText = styleExtends.transform(style);
|
@@ -2245,34 +2247,38 @@ styles.push(style);
|
|
2245
2247
|
}
|
2246
2248
|
return styles;
|
2247
2249
|
},
|
2248
|
-
_elementAdd: function(node) {
|
2249
|
-
if (this._encapsulateStyle
|
2250
|
+
_elementAdd: function (node) {
|
2251
|
+
if (this._encapsulateStyle) {
|
2252
|
+
if (node.__styleScoped) {
|
2253
|
+
node.__styleScoped = false;
|
2254
|
+
} else {
|
2250
2255
|
styleTransformer.dom(node, this.is, this._scopeCssViaAttr);
|
2251
2256
|
}
|
2257
|
+
}
|
2252
2258
|
},
|
2253
|
-
_elementRemove: function(node) {
|
2259
|
+
_elementRemove: function (node) {
|
2254
2260
|
if (this._encapsulateStyle) {
|
2255
2261
|
styleTransformer.dom(node, this.is, this._scopeCssViaAttr, true);
|
2256
2262
|
}
|
2257
2263
|
},
|
2258
|
-
scopeSubtree: function(container, shouldObserve) {
|
2264
|
+
scopeSubtree: function (container, shouldObserve) {
|
2259
2265
|
if (nativeShadow) {
|
2260
2266
|
return;
|
2261
2267
|
}
|
2262
2268
|
var self = this;
|
2263
|
-
var scopify = function(node) {
|
2269
|
+
var scopify = function (node) {
|
2264
2270
|
if (node.nodeType === Node.ELEMENT_NODE) {
|
2265
2271
|
node.className = self._scopeElementClass(node, node.className);
|
2266
|
-
var n$ = node.querySelectorAll(
|
2267
|
-
Array.prototype.forEach.call(n$, function(n) {
|
2272
|
+
var n$ = node.querySelectorAll('*');
|
2273
|
+
Array.prototype.forEach.call(n$, function (n) {
|
2268
2274
|
n.className = self._scopeElementClass(n, n.className);
|
2269
2275
|
});
|
2270
2276
|
}
|
2271
2277
|
};
|
2272
2278
|
scopify(container);
|
2273
2279
|
if (shouldObserve) {
|
2274
|
-
var mo = new MutationObserver(function(mxns) {
|
2275
|
-
mxns.forEach(function(m) {
|
2280
|
+
var mo = new MutationObserver(function (mxns) {
|
2281
|
+
mxns.forEach(function (m) {
|
2276
2282
|
if (m.addedNodes) {
|
2277
2283
|
for (var i = 0; i < m.addedNodes.length; i++) {
|
2278
2284
|
scopify(m.addedNodes[i]);
|
@@ -2288,17 +2294,16 @@ return mo;
|
|
2288
2294
|
}
|
2289
2295
|
}
|
2290
2296
|
});
|
2291
|
-
}
|
2292
|
-
|
2293
|
-
Polymer.StyleProperties = function() {
|
2297
|
+
}());
|
2298
|
+
Polymer.StyleProperties = function () {
|
2294
2299
|
var nativeShadow = Polymer.Settings.useNativeShadow;
|
2295
2300
|
var matchesSelector = Polymer.DomApi.matchesSelector;
|
2296
2301
|
var styleUtil = Polymer.StyleUtil;
|
2297
2302
|
var styleTransformer = Polymer.StyleTransformer;
|
2298
2303
|
return {
|
2299
|
-
decorateStyles: function(styles) {
|
2304
|
+
decorateStyles: function (styles) {
|
2300
2305
|
var self = this, props = {};
|
2301
|
-
styleUtil.forRulesInStyles(styles, function(rule) {
|
2306
|
+
styleUtil.forRulesInStyles(styles, function (rule) {
|
2302
2307
|
self.decorateRule(rule);
|
2303
2308
|
self.collectPropertiesInCssText(rule.propertyInfo.cssText, props);
|
2304
2309
|
});
|
@@ -2308,7 +2313,7 @@ names.push(i);
|
|
2308
2313
|
}
|
2309
2314
|
return names;
|
2310
2315
|
},
|
2311
|
-
decorateRule: function(rule) {
|
2316
|
+
decorateRule: function (rule) {
|
2312
2317
|
if (rule.propertyInfo) {
|
2313
2318
|
return rule.propertyInfo;
|
2314
2319
|
}
|
@@ -2322,7 +2327,7 @@ info.cssText = this.collectCssText(rule);
|
|
2322
2327
|
rule.propertyInfo = info;
|
2323
2328
|
return info;
|
2324
2329
|
},
|
2325
|
-
collectProperties: function(rule, properties) {
|
2330
|
+
collectProperties: function (rule, properties) {
|
2326
2331
|
var info = rule.propertyInfo;
|
2327
2332
|
if (info) {
|
2328
2333
|
if (info.properties) {
|
@@ -2340,68 +2345,68 @@ any = true;
|
|
2340
2345
|
return any;
|
2341
2346
|
}
|
2342
2347
|
},
|
2343
|
-
collectCssText: function(rule) {
|
2344
|
-
var customCssText =
|
2348
|
+
collectCssText: function (rule) {
|
2349
|
+
var customCssText = '';
|
2345
2350
|
var cssText = rule.parsedCssText;
|
2346
|
-
cssText = cssText.replace(this.rx.BRACKETED,
|
2347
|
-
var parts = cssText.split(
|
2351
|
+
cssText = cssText.replace(this.rx.BRACKETED, '').replace(this.rx.VAR_ASSIGN, '');
|
2352
|
+
var parts = cssText.split(';');
|
2348
2353
|
for (var i = 0, p; i < parts.length; i++) {
|
2349
2354
|
p = parts[i];
|
2350
2355
|
if (p.match(this.rx.MIXIN_MATCH) || p.match(this.rx.VAR_MATCH)) {
|
2351
|
-
customCssText += p +
|
2356
|
+
customCssText += p + ';\n';
|
2352
2357
|
}
|
2353
2358
|
}
|
2354
2359
|
return customCssText;
|
2355
2360
|
},
|
2356
|
-
collectPropertiesInCssText: function(cssText, props) {
|
2361
|
+
collectPropertiesInCssText: function (cssText, props) {
|
2357
2362
|
var m;
|
2358
2363
|
while (m = this.rx.VAR_CAPTURE.exec(cssText)) {
|
2359
2364
|
props[m[1]] = true;
|
2360
2365
|
}
|
2361
2366
|
},
|
2362
|
-
reify: function(props) {
|
2367
|
+
reify: function (props) {
|
2363
2368
|
var names = Object.getOwnPropertyNames(props);
|
2364
2369
|
for (var i = 0, n; i < names.length; i++) {
|
2365
2370
|
n = names[i];
|
2366
2371
|
props[n] = this.valueForProperty(props[n], props);
|
2367
2372
|
}
|
2368
2373
|
},
|
2369
|
-
valueForProperty: function(property, props) {
|
2374
|
+
valueForProperty: function (property, props) {
|
2370
2375
|
if (property) {
|
2371
|
-
if (property.indexOf(
|
2376
|
+
if (property.indexOf(';') >= 0) {
|
2372
2377
|
property = this.valueForProperties(property, props);
|
2373
2378
|
} else {
|
2374
2379
|
var self = this;
|
2375
|
-
var fn = function(all, prefix, value, fallback) {
|
2380
|
+
var fn = function (all, prefix, value, fallback) {
|
2376
2381
|
var propertyValue = self.valueForProperty(props[value], props) || (props[fallback] ? self.valueForProperty(props[fallback], props) : fallback);
|
2377
|
-
return prefix + (propertyValue ||
|
2382
|
+
return prefix + (propertyValue || '');
|
2378
2383
|
};
|
2379
2384
|
property = property.replace(this.rx.VAR_MATCH, fn);
|
2380
2385
|
}
|
2381
2386
|
}
|
2382
|
-
return property && property.trim() ||
|
2387
|
+
return property && property.trim() || '';
|
2383
2388
|
},
|
2384
|
-
valueForProperties: function(property, props) {
|
2385
|
-
var parts = property.split(
|
2389
|
+
valueForProperties: function (property, props) {
|
2390
|
+
var parts = property.split(';');
|
2386
2391
|
for (var i = 0, p, m; i < parts.length && (p = parts[i]); i++) {
|
2387
2392
|
m = p.match(this.rx.MIXIN_MATCH);
|
2388
2393
|
if (m) {
|
2389
2394
|
p = this.valueForProperty(props[m[1]], props);
|
2390
2395
|
} else {
|
2391
|
-
var pp = p.split(
|
2396
|
+
var pp = p.split(':');
|
2392
2397
|
if (pp[1]) {
|
2393
2398
|
pp[1] = pp[1].trim();
|
2394
2399
|
pp[1] = this.valueForProperty(pp[1], props) || pp[1];
|
2395
2400
|
}
|
2396
|
-
p = pp.join(
|
2401
|
+
p = pp.join(':');
|
2397
2402
|
}
|
2398
|
-
parts[i] = p && p.lastIndexOf(
|
2403
|
+
parts[i] = p && p.lastIndexOf(';') === p.length - 1 ? p.slice(0, -1) : p || '';
|
2399
2404
|
}
|
2400
|
-
return parts.join(
|
2405
|
+
return parts.join(';');
|
2401
2406
|
},
|
2402
|
-
applyProperties: function(rule, props) {
|
2403
|
-
var output =
|
2404
|
-
if (!rule.
|
2407
|
+
applyProperties: function (rule, props) {
|
2408
|
+
var output = '';
|
2409
|
+
if (!rule.propertyInfo) {
|
2405
2410
|
this.decorateRule(rule);
|
2406
2411
|
}
|
2407
2412
|
if (rule.propertyInfo.cssText) {
|
@@ -2409,10 +2414,10 @@ output = this.valueForProperties(rule.propertyInfo.cssText, props);
|
|
2409
2414
|
}
|
2410
2415
|
rule.cssText = output;
|
2411
2416
|
},
|
2412
|
-
propertyDataFromStyles: function(styles, element) {
|
2417
|
+
propertyDataFromStyles: function (styles, element) {
|
2413
2418
|
var props = {}, self = this;
|
2414
2419
|
var o = [], i = 0;
|
2415
|
-
styleUtil.forRulesInStyles(styles, function(rule) {
|
2420
|
+
styleUtil.forRulesInStyles(styles, function (rule) {
|
2416
2421
|
if (!rule.propertyInfo) {
|
2417
2422
|
self.decorateRule(rule);
|
2418
2423
|
}
|
@@ -2427,21 +2432,21 @@ properties: props,
|
|
2427
2432
|
key: o
|
2428
2433
|
};
|
2429
2434
|
},
|
2430
|
-
scopePropertiesFromStyles: function(styles) {
|
2435
|
+
scopePropertiesFromStyles: function (styles) {
|
2431
2436
|
if (!styles._scopeStyleProperties) {
|
2432
2437
|
styles._scopeStyleProperties = this.selectedPropertiesFromStyles(styles, this.SCOPE_SELECTORS);
|
2433
2438
|
}
|
2434
2439
|
return styles._scopeStyleProperties;
|
2435
2440
|
},
|
2436
|
-
hostPropertiesFromStyles: function(styles) {
|
2441
|
+
hostPropertiesFromStyles: function (styles) {
|
2437
2442
|
if (!styles._hostStyleProperties) {
|
2438
2443
|
styles._hostStyleProperties = this.selectedPropertiesFromStyles(styles, this.HOST_SELECTORS);
|
2439
2444
|
}
|
2440
2445
|
return styles._hostStyleProperties;
|
2441
2446
|
},
|
2442
|
-
selectedPropertiesFromStyles: function(styles, selectors) {
|
2447
|
+
selectedPropertiesFromStyles: function (styles, selectors) {
|
2443
2448
|
var props = {}, self = this;
|
2444
|
-
styleUtil.forRulesInStyles(styles, function(rule) {
|
2449
|
+
styleUtil.forRulesInStyles(styles, function (rule) {
|
2445
2450
|
if (!rule.propertyInfo) {
|
2446
2451
|
self.decorateRule(rule);
|
2447
2452
|
}
|
@@ -2454,29 +2459,29 @@ return;
|
|
2454
2459
|
});
|
2455
2460
|
return props;
|
2456
2461
|
},
|
2457
|
-
transformStyles: function(element, properties, scopeSelector) {
|
2462
|
+
transformStyles: function (element, properties, scopeSelector) {
|
2458
2463
|
var self = this;
|
2459
2464
|
var hostRx = new RegExp(this.rx.HOST_PREFIX + element.is + this.rx.HOST_SUFFIX);
|
2460
|
-
return styleTransformer.elementStyles(element, function(rule) {
|
2465
|
+
return styleTransformer.elementStyles(element, function (rule) {
|
2461
2466
|
self.applyProperties(rule, properties);
|
2462
2467
|
if (rule.cssText && !nativeShadow) {
|
2463
2468
|
self._scopeSelector(rule, hostRx, element.is, element._scopeCssViaAttr, scopeSelector);
|
2464
2469
|
}
|
2465
2470
|
});
|
2466
2471
|
},
|
2467
|
-
_scopeSelector: function(rule, hostRx, is, viaAttr, scopeId) {
|
2472
|
+
_scopeSelector: function (rule, hostRx, is, viaAttr, scopeId) {
|
2468
2473
|
rule.transformedSelector = rule.transformedSelector || rule.selector;
|
2469
2474
|
var selector = rule.transformedSelector;
|
2470
|
-
var scope = viaAttr ?
|
2471
|
-
var parts = selector.split(
|
2475
|
+
var scope = viaAttr ? '[' + styleTransformer.SCOPE_NAME + '~=' + scopeId + ']' : '.' + scopeId;
|
2476
|
+
var parts = selector.split(',');
|
2472
2477
|
for (var i = 0, l = parts.length, p; i < l && (p = parts[i]); i++) {
|
2473
|
-
parts[i] = p.match(hostRx) ? p.replace(is, is + scope) : scope +
|
2478
|
+
parts[i] = p.match(hostRx) ? p.replace(is, is + scope) : scope + ' ' + p;
|
2474
2479
|
}
|
2475
|
-
rule.selector = parts.join(
|
2480
|
+
rule.selector = parts.join(',');
|
2476
2481
|
},
|
2477
|
-
applyElementScopeSelector: function(element, selector, old, viaAttr) {
|
2482
|
+
applyElementScopeSelector: function (element, selector, old, viaAttr) {
|
2478
2483
|
var c = viaAttr ? element.getAttribute(styleTransformer.SCOPE_NAME) : element.className;
|
2479
|
-
v = old ? c.replace(old, selector) : (c ? c +
|
2484
|
+
v = old ? c.replace(old, selector) : (c ? c + ' ' : '') + this.XSCOPE_NAME + ' ' + selector;
|
2480
2485
|
if (c !== v) {
|
2481
2486
|
if (viaAttr) {
|
2482
2487
|
element.setAttribute(styleTransformer.SCOPE_NAME, v);
|
@@ -2485,8 +2490,8 @@ element.className = v;
|
|
2485
2490
|
}
|
2486
2491
|
}
|
2487
2492
|
},
|
2488
|
-
applyElementStyle: function(element, properties, selector, style) {
|
2489
|
-
var cssText = style ? style.textContent ||
|
2493
|
+
applyElementStyle: function (element, properties, selector, style) {
|
2494
|
+
var cssText = style ? style.textContent || '' : this.transformStyles(element, properties, selector);
|
2490
2495
|
var s = element._customStyle;
|
2491
2496
|
if (s && !nativeShadow && s !== style) {
|
2492
2497
|
s._useCount--;
|
@@ -2517,12 +2522,12 @@ MIXIN_MATCH: /(?:^|\W+)@apply[\s]*\(([^)]*)\);?/im,
|
|
2517
2522
|
VAR_MATCH: /(^|\W+)var\([\s]*([^,)]*)[\s]*,?[\s]*((?:[^,)]*)|(?:[^;]*\([^;)]*\)))[\s]*?\)/gim,
|
2518
2523
|
VAR_CAPTURE: /\([\s]*(--[^,\s)]*)(?:,[\s]*(--[^,\s)]*))?(?:\)|,)/gim,
|
2519
2524
|
BRACKETED: /\{[^}]*\}/g,
|
2520
|
-
HOST_PREFIX:
|
2521
|
-
HOST_SUFFIX:
|
2525
|
+
HOST_PREFIX: '(?:^|[^.])',
|
2526
|
+
HOST_SUFFIX: '($|[.:[\\s>+~])'
|
2522
2527
|
},
|
2523
|
-
HOST_SELECTORS: [
|
2524
|
-
SCOPE_SELECTORS: [
|
2525
|
-
XSCOPE_NAME:
|
2528
|
+
HOST_SELECTORS: [':host'],
|
2529
|
+
SCOPE_SELECTORS: [':root'],
|
2530
|
+
XSCOPE_NAME: 'x-scope'
|
2526
2531
|
};
|
2527
2532
|
function addToBitMask(n, bits) {
|
2528
2533
|
var o = parseInt(n / 32);
|
@@ -2530,16 +2535,15 @@ var v = 1 << n % 32;
|
|
2530
2535
|
bits[o] = (bits[o] || 0) | v;
|
2531
2536
|
}
|
2532
2537
|
}();
|
2533
|
-
|
2534
|
-
Polymer.StyleDefaults = function() {
|
2538
|
+
Polymer.StyleDefaults = function () {
|
2535
2539
|
var styleProperties = Polymer.StyleProperties;
|
2536
2540
|
var styleUtil = Polymer.StyleUtil;
|
2537
|
-
var style = document.createElement(
|
2541
|
+
var style = document.createElement('style');
|
2538
2542
|
var api = {
|
2539
2543
|
style: style,
|
2540
|
-
_styles: [
|
2544
|
+
_styles: [style],
|
2541
2545
|
_properties: null,
|
2542
|
-
applyCss: function(cssText) {
|
2546
|
+
applyCss: function (cssText) {
|
2543
2547
|
this.style.textContent += cssText;
|
2544
2548
|
styleUtil.clearStyleRules(this.style);
|
2545
2549
|
this._properties = null;
|
@@ -2552,21 +2556,21 @@ this._properties = styleProperties.scopePropertiesFromStyles(this._styles);
|
|
2552
2556
|
}
|
2553
2557
|
return this._properties;
|
2554
2558
|
},
|
2555
|
-
_needsStyleProperties: function() {
|
2556
|
-
|
2559
|
+
_needsStyleProperties: function () {
|
2560
|
+
},
|
2561
|
+
_computeStyleProperties: function () {
|
2557
2562
|
return this._styleProperties;
|
2558
2563
|
}
|
2559
2564
|
};
|
2560
2565
|
return api;
|
2561
2566
|
}();
|
2562
|
-
|
2563
|
-
|
2564
|
-
Polymer.StyleCache = function() {
|
2567
|
+
(function () {
|
2568
|
+
Polymer.StyleCache = function () {
|
2565
2569
|
this.cache = {};
|
2566
2570
|
};
|
2567
2571
|
Polymer.StyleCache.prototype = {
|
2568
2572
|
MAX: 100,
|
2569
|
-
store: function(is, data, keyValues, keyStyles) {
|
2573
|
+
store: function (is, data, keyValues, keyStyles) {
|
2570
2574
|
data.keyValues = keyValues;
|
2571
2575
|
data.styles = keyStyles;
|
2572
2576
|
var s$ = this.cache[is] = this.cache[is] || [];
|
@@ -2575,7 +2579,7 @@ if (s$.length > this.MAX) {
|
|
2575
2579
|
s$.shift();
|
2576
2580
|
}
|
2577
2581
|
},
|
2578
|
-
retrieve: function(is, keyValues, keyStyles) {
|
2582
|
+
retrieve: function (is, keyValues, keyStyles) {
|
2579
2583
|
var cache = this.cache[is];
|
2580
2584
|
if (cache) {
|
2581
2585
|
for (var i = cache.length - 1, data; i >= 0; i--) {
|
@@ -2586,10 +2590,10 @@ return data;
|
|
2586
2590
|
}
|
2587
2591
|
}
|
2588
2592
|
},
|
2589
|
-
clear: function() {
|
2593
|
+
clear: function () {
|
2590
2594
|
this.cache = {};
|
2591
2595
|
},
|
2592
|
-
_objectsEqual: function(target, source) {
|
2596
|
+
_objectsEqual: function (target, source) {
|
2593
2597
|
for (var i in target) {
|
2594
2598
|
if (target[i] !== source[i]) {
|
2595
2599
|
return false;
|
@@ -2601,9 +2605,8 @@ return target.length === source.length;
|
|
2601
2605
|
return true;
|
2602
2606
|
}
|
2603
2607
|
};
|
2604
|
-
}
|
2605
|
-
|
2606
|
-
(function() {
|
2608
|
+
}());
|
2609
|
+
(function () {
|
2607
2610
|
var serializeValueToAttribute = Polymer.Base.serializeValueToAttribute;
|
2608
2611
|
var propertyUtils = Polymer.StyleProperties;
|
2609
2612
|
var styleTransformer = Polymer.StyleTransformer;
|
@@ -2611,21 +2614,21 @@ var styleUtil = Polymer.StyleUtil;
|
|
2611
2614
|
var styleDefaults = Polymer.StyleDefaults;
|
2612
2615
|
var nativeShadow = Polymer.Settings.useNativeShadow;
|
2613
2616
|
Polymer.Base._addFeature({
|
2614
|
-
_prepStyleProperties: function() {
|
2617
|
+
_prepStyleProperties: function () {
|
2615
2618
|
this._ownStylePropertyNames = this._styles ? propertyUtils.decorateStyles(this._styles) : [];
|
2616
2619
|
},
|
2617
|
-
_setupStyleProperties: function() {
|
2620
|
+
_setupStyleProperties: function () {
|
2618
2621
|
this.customStyle = {};
|
2619
2622
|
},
|
2620
|
-
_needsStyleProperties: function() {
|
2623
|
+
_needsStyleProperties: function () {
|
2621
2624
|
return Boolean(this._ownStylePropertyNames && this._ownStylePropertyNames.length);
|
2622
2625
|
},
|
2623
|
-
_beforeAttached: function() {
|
2626
|
+
_beforeAttached: function () {
|
2624
2627
|
if (!this._scopeSelector && this._needsStyleProperties()) {
|
2625
2628
|
this._updateStyleProperties();
|
2626
2629
|
}
|
2627
2630
|
},
|
2628
|
-
_updateStyleProperties: function() {
|
2631
|
+
_updateStyleProperties: function () {
|
2629
2632
|
var info, scope = this.domHost || styleDefaults;
|
2630
2633
|
if (!scope._styleCache) {
|
2631
2634
|
scope._styleCache = new Polymer.StyleCache();
|
@@ -2660,7 +2663,7 @@ styleCache.store(this.is, Object.create(info), this._ownStyleProperties, this._s
|
|
2660
2663
|
}
|
2661
2664
|
}
|
2662
2665
|
},
|
2663
|
-
_computeStyleProperties: function(scopeProps) {
|
2666
|
+
_computeStyleProperties: function (scopeProps) {
|
2664
2667
|
var scope = this.domHost || styleDefaults;
|
2665
2668
|
if (!scope._styleProperties) {
|
2666
2669
|
scope._computeStyleProperties();
|
@@ -2674,7 +2677,7 @@ this.mixin(props, this.customStyle);
|
|
2674
2677
|
propertyUtils.reify(props);
|
2675
2678
|
this._styleProperties = props;
|
2676
2679
|
},
|
2677
|
-
_computeOwnStyleProperties: function() {
|
2680
|
+
_computeOwnStyleProperties: function () {
|
2678
2681
|
var props = {};
|
2679
2682
|
for (var i = 0, n; i < this._ownStylePropertyNames.length; i++) {
|
2680
2683
|
n = this._ownStylePropertyNames[i];
|
@@ -2683,18 +2686,18 @@ props[n] = this._styleProperties[n];
|
|
2683
2686
|
this._ownStyleProperties = props;
|
2684
2687
|
},
|
2685
2688
|
_scopeCount: 0,
|
2686
|
-
_applyStyleProperties: function(info) {
|
2689
|
+
_applyStyleProperties: function (info) {
|
2687
2690
|
var oldScopeSelector = this._scopeSelector;
|
2688
|
-
this._scopeSelector = info ? info._scopeSelector : this.is +
|
2691
|
+
this._scopeSelector = info ? info._scopeSelector : this.is + '-' + this.__proto__._scopeCount++;
|
2689
2692
|
style = propertyUtils.applyElementStyle(this, this._styleProperties, this._scopeSelector, info && info.style);
|
2690
2693
|
if ((style || oldScopeSelector) && !nativeShadow) {
|
2691
2694
|
propertyUtils.applyElementScopeSelector(this, this._scopeSelector, oldScopeSelector, this._scopeCssViaAttr);
|
2692
2695
|
}
|
2693
2696
|
return style || {};
|
2694
2697
|
},
|
2695
|
-
serializeValueToAttribute: function(value, attribute, node) {
|
2698
|
+
serializeValueToAttribute: function (value, attribute, node) {
|
2696
2699
|
node = node || this;
|
2697
|
-
if (attribute ===
|
2700
|
+
if (attribute === 'class') {
|
2698
2701
|
var host = node === this ? this.domHost || this.dataHost : this;
|
2699
2702
|
if (host) {
|
2700
2703
|
value = host._scopeElementClass(node, value);
|
@@ -2703,13 +2706,13 @@ value = host._scopeElementClass(node, value);
|
|
2703
2706
|
node = Polymer.dom(node);
|
2704
2707
|
serializeValueToAttribute.call(this, value, attribute, node);
|
2705
2708
|
},
|
2706
|
-
_scopeElementClass: function(element, selector) {
|
2709
|
+
_scopeElementClass: function (element, selector) {
|
2707
2710
|
if (!nativeShadow && !this._scopeCssViaAttr) {
|
2708
|
-
selector += (selector ?
|
2711
|
+
selector += (selector ? ' ' : '') + SCOPE_NAME + ' ' + this.is + (element._scopeSelector ? ' ' + XSCOPE_NAME + ' ' + element._scopeSelector : '');
|
2709
2712
|
}
|
2710
2713
|
return selector;
|
2711
2714
|
},
|
2712
|
-
updateStyles: function() {
|
2715
|
+
updateStyles: function () {
|
2713
2716
|
if (this.isAttached) {
|
2714
2717
|
if (this._needsStyleProperties()) {
|
2715
2718
|
this._updateStyleProperties();
|
@@ -2722,9 +2725,9 @@ this._styleCache.clear();
|
|
2722
2725
|
this._updateRootStyles();
|
2723
2726
|
}
|
2724
2727
|
},
|
2725
|
-
_updateRootStyles: function(root) {
|
2728
|
+
_updateRootStyles: function (root) {
|
2726
2729
|
root = root || this.root;
|
2727
|
-
var c$ = Polymer.dom(root)._query(function(e) {
|
2730
|
+
var c$ = Polymer.dom(root)._query(function (e) {
|
2728
2731
|
return e.shadyRoot || e.shadowRoot;
|
2729
2732
|
});
|
2730
2733
|
for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
|
@@ -2734,7 +2737,7 @@ c.updateStyles();
|
|
2734
2737
|
}
|
2735
2738
|
}
|
2736
2739
|
});
|
2737
|
-
Polymer.updateStyles = function() {
|
2740
|
+
Polymer.updateStyles = function () {
|
2738
2741
|
styleDefaults._styleCache.clear();
|
2739
2742
|
Polymer.Base._updateRootStyles(document);
|
2740
2743
|
};
|
@@ -2742,10 +2745,9 @@ var styleCache = new Polymer.StyleCache();
|
|
2742
2745
|
Polymer.customStyleCache = styleCache;
|
2743
2746
|
var SCOPE_NAME = styleTransformer.SCOPE_NAME;
|
2744
2747
|
var XSCOPE_NAME = propertyUtils.XSCOPE_NAME;
|
2745
|
-
}
|
2746
|
-
|
2748
|
+
}());
|
2747
2749
|
Polymer.Base._addFeature({
|
2748
|
-
_registerFeatures: function() {
|
2750
|
+
_registerFeatures: function () {
|
2749
2751
|
this._prepIs();
|
2750
2752
|
this._prepAttributes();
|
2751
2753
|
this._prepExtends();
|
@@ -2759,12 +2761,12 @@ this._prepBehaviors();
|
|
2759
2761
|
this._prepBindings();
|
2760
2762
|
this._prepShady();
|
2761
2763
|
},
|
2762
|
-
_prepBehavior: function(b) {
|
2764
|
+
_prepBehavior: function (b) {
|
2763
2765
|
this._addPropertyEffects(b.properties);
|
2764
2766
|
this._addComplexObserverEffects(b.observers);
|
2765
2767
|
this._addHostAttributes(b.hostAttributes);
|
2766
2768
|
},
|
2767
|
-
_initFeatures: function() {
|
2769
|
+
_initFeatures: function () {
|
2768
2770
|
this._poolContent();
|
2769
2771
|
this._setupConfigure();
|
2770
2772
|
this._setupStyleProperties();
|
@@ -2779,41 +2781,40 @@ this._marshalBehaviors();
|
|
2779
2781
|
this._marshalAttributes();
|
2780
2782
|
this._tryReady();
|
2781
2783
|
},
|
2782
|
-
_marshalBehavior: function(b) {
|
2784
|
+
_marshalBehavior: function (b) {
|
2783
2785
|
this._listenListeners(b.listeners);
|
2784
2786
|
}
|
2785
2787
|
});
|
2786
|
-
|
2787
|
-
(function() {
|
2788
|
+
(function () {
|
2788
2789
|
var nativeShadow = Polymer.Settings.useNativeShadow;
|
2789
2790
|
var propertyUtils = Polymer.StyleProperties;
|
2790
2791
|
var styleUtil = Polymer.StyleUtil;
|
2791
2792
|
var styleDefaults = Polymer.StyleDefaults;
|
2792
2793
|
Polymer({
|
2793
|
-
is:
|
2794
|
-
|
2795
|
-
created: function() {
|
2796
|
-
this._appliesToDocument = this.parentNode.localName !==
|
2794
|
+
is: 'custom-style',
|
2795
|
+
extends: 'style',
|
2796
|
+
created: function () {
|
2797
|
+
this._appliesToDocument = this.parentNode.localName !== 'dom-module';
|
2797
2798
|
if (this._appliesToDocument) {
|
2798
2799
|
var e = this.__appliedElement || this;
|
2799
2800
|
var rules = styleUtil.rulesForStyle(e);
|
2800
|
-
propertyUtils.decorateStyles([
|
2801
|
+
propertyUtils.decorateStyles([e]);
|
2801
2802
|
this._rulesToDefaultProperties(rules);
|
2802
2803
|
this.async(this._applyStyle);
|
2803
2804
|
}
|
2804
2805
|
},
|
2805
|
-
_applyStyle: function() {
|
2806
|
+
_applyStyle: function () {
|
2806
2807
|
var e = this.__appliedElement || this;
|
2807
2808
|
this._computeStyleProperties();
|
2808
2809
|
var props = this._styleProperties;
|
2809
2810
|
var self = this;
|
2810
|
-
e.textContent = styleUtil.toCssText(styleUtil.rulesForStyle(e), function(rule) {
|
2811
|
-
if (rule.selector ===
|
2812
|
-
rule.selector =
|
2811
|
+
e.textContent = styleUtil.toCssText(styleUtil.rulesForStyle(e), function (rule) {
|
2812
|
+
if (rule.selector === ':root') {
|
2813
|
+
rule.selector = 'body';
|
2813
2814
|
}
|
2814
2815
|
var css = rule.cssText = rule.parsedCssText;
|
2815
|
-
if (rule.propertyInfo.cssText) {
|
2816
|
-
css = css.replace(propertyUtils.rx.VAR_ASSIGN,
|
2816
|
+
if (rule.propertyInfo && rule.propertyInfo.cssText) {
|
2817
|
+
css = css.replace(propertyUtils.rx.VAR_ASSIGN, '');
|
2817
2818
|
rule.cssText = propertyUtils.valueForProperties(css, props);
|
2818
2819
|
}
|
2819
2820
|
if (!nativeShadow) {
|
@@ -2821,10 +2822,10 @@ Polymer.StyleTransformer.rootRule(rule);
|
|
2821
2822
|
}
|
2822
2823
|
});
|
2823
2824
|
},
|
2824
|
-
_rulesToDefaultProperties: function(rules) {
|
2825
|
-
styleUtil.forEachStyleRule(rules, function(rule) {
|
2825
|
+
_rulesToDefaultProperties: function (rules) {
|
2826
|
+
styleUtil.forEachStyleRule(rules, function (rule) {
|
2826
2827
|
if (!rule.propertyInfo.properties) {
|
2827
|
-
rule.cssText =
|
2828
|
+
rule.cssText = '';
|
2828
2829
|
}
|
2829
2830
|
});
|
2830
2831
|
var cssText = styleUtil.parser.stringify(rules, true);
|
@@ -2833,24 +2834,19 @@ styleDefaults.applyCss(cssText);
|
|
2833
2834
|
}
|
2834
2835
|
}
|
2835
2836
|
});
|
2836
|
-
}
|
2837
|
-
|
2837
|
+
}());
|
2838
2838
|
Polymer.Templatizer = {
|
2839
|
-
properties: {
|
2840
|
-
_hideTemplateChildren: {
|
2841
|
-
observer: "_hideTemplateChildrenChanged"
|
2842
|
-
}
|
2843
|
-
},
|
2839
|
+
properties: { _hideTemplateChildren: { observer: '_showHideChildren' } },
|
2844
2840
|
_templatizerStatic: {
|
2845
2841
|
count: 0,
|
2846
2842
|
callbacks: {},
|
2847
2843
|
debouncer: null
|
2848
2844
|
},
|
2849
2845
|
_instanceProps: Polymer.nob,
|
2850
|
-
created: function() {
|
2846
|
+
created: function () {
|
2851
2847
|
this._templatizerId = this._templatizerStatic.count++;
|
2852
2848
|
},
|
2853
|
-
templatize: function(template) {
|
2849
|
+
templatize: function (template) {
|
2854
2850
|
if (!template._content) {
|
2855
2851
|
template._content = template.content;
|
2856
2852
|
}
|
@@ -2878,19 +2874,16 @@ archetype.constructor = ctor;
|
|
2878
2874
|
template._content._ctor = ctor;
|
2879
2875
|
this.ctor = ctor;
|
2880
2876
|
},
|
2881
|
-
_getRootDataHost: function() {
|
2877
|
+
_getRootDataHost: function () {
|
2882
2878
|
return this.dataHost && this.dataHost._rootDataHost || this.dataHost;
|
2883
2879
|
},
|
2884
|
-
|
2885
|
-
if (this._hideChildren) {
|
2886
|
-
this._hideChildren(hidden);
|
2887
|
-
}
|
2880
|
+
_showHideChildren: function (hidden) {
|
2888
2881
|
},
|
2889
|
-
_debounceTemplate: function(fn) {
|
2882
|
+
_debounceTemplate: function (fn) {
|
2890
2883
|
this._templatizerStatic.callbacks[this._templatizerId] = fn.bind(this);
|
2891
2884
|
this._templatizerStatic.debouncer = Polymer.Debounce(this._templatizerStatic.debouncer, this._flushTemplates.bind(this, true));
|
2892
2885
|
},
|
2893
|
-
_flushTemplates: function(debouncerExpired) {
|
2886
|
+
_flushTemplates: function (debouncerExpired) {
|
2894
2887
|
var db = this._templatizerStatic.debouncer;
|
2895
2888
|
while (debouncerExpired || db && db.finish) {
|
2896
2889
|
db.stop();
|
@@ -2902,13 +2895,13 @@ cbs[id]();
|
|
2902
2895
|
debouncerExpired = false;
|
2903
2896
|
}
|
2904
2897
|
},
|
2905
|
-
_customPrepEffects: function(archetype) {
|
2898
|
+
_customPrepEffects: function (archetype) {
|
2906
2899
|
var parentProps = archetype._parentProps;
|
2907
2900
|
for (var prop in parentProps) {
|
2908
|
-
archetype._addPropertyEffect(prop,
|
2901
|
+
archetype._addPropertyEffect(prop, 'function', this._createHostPropEffector(prop));
|
2909
2902
|
}
|
2910
2903
|
},
|
2911
|
-
_customPrepAnnotations: function(archetype, template) {
|
2904
|
+
_customPrepAnnotations: function (archetype, template) {
|
2912
2905
|
archetype._template = template;
|
2913
2906
|
var c = template._content;
|
2914
2907
|
if (!c._notes) {
|
@@ -2923,7 +2916,7 @@ this._processAnnotations(c._notes);
|
|
2923
2916
|
archetype._notes = c._notes;
|
2924
2917
|
archetype._parentProps = c._parentProps;
|
2925
2918
|
},
|
2926
|
-
_prepParentProperties: function(archetype, template) {
|
2919
|
+
_prepParentProperties: function (archetype, template) {
|
2927
2920
|
var parentProps = this._parentProps = archetype._parentProps;
|
2928
2921
|
if (this._forwardParentProp && parentProps) {
|
2929
2922
|
var proto = archetype._parentPropProto;
|
@@ -2937,13 +2930,14 @@ if (template != this) {
|
|
2937
2930
|
Polymer.Bind.prepareModel(proto);
|
2938
2931
|
}
|
2939
2932
|
for (prop in parentProps) {
|
2940
|
-
var parentProp =
|
2941
|
-
var effects = [
|
2942
|
-
|
2933
|
+
var parentProp = '_parent_' + prop;
|
2934
|
+
var effects = [
|
2935
|
+
{
|
2936
|
+
kind: 'function',
|
2943
2937
|
effect: this._createForwardPropEffector(prop)
|
2944
|
-
},
|
2945
|
-
kind:
|
2946
|
-
|
2938
|
+
},
|
2939
|
+
{ kind: 'notify' }
|
2940
|
+
];
|
2947
2941
|
Polymer.Bind._createAccessors(proto, parentProp, effects);
|
2948
2942
|
}
|
2949
2943
|
}
|
@@ -2954,18 +2948,18 @@ template._forwardParentProp = this._forwardParentProp.bind(this);
|
|
2954
2948
|
this._extendTemplate(template, proto);
|
2955
2949
|
}
|
2956
2950
|
},
|
2957
|
-
_createForwardPropEffector: function(prop) {
|
2958
|
-
return function(source, value) {
|
2951
|
+
_createForwardPropEffector: function (prop) {
|
2952
|
+
return function (source, value) {
|
2959
2953
|
this._forwardParentProp(prop, value);
|
2960
2954
|
};
|
2961
2955
|
},
|
2962
|
-
_createHostPropEffector: function(prop) {
|
2963
|
-
return function(source, value) {
|
2964
|
-
this.dataHost[
|
2956
|
+
_createHostPropEffector: function (prop) {
|
2957
|
+
return function (source, value) {
|
2958
|
+
this.dataHost['_parent_' + prop] = value;
|
2965
2959
|
};
|
2966
2960
|
},
|
2967
|
-
_extendTemplate: function(template, proto) {
|
2968
|
-
Object.getOwnPropertyNames(proto).forEach(function(n) {
|
2961
|
+
_extendTemplate: function (template, proto) {
|
2962
|
+
Object.getOwnPropertyNames(proto).forEach(function (n) {
|
2969
2963
|
var val = template[n];
|
2970
2964
|
var pd = Object.getOwnPropertyDescriptor(proto, n);
|
2971
2965
|
Object.defineProperty(template, n, pd);
|
@@ -2974,25 +2968,26 @@ template._propertySet(n, val);
|
|
2974
2968
|
}
|
2975
2969
|
});
|
2976
2970
|
},
|
2977
|
-
_forwardInstancePath: function(inst, path, value) {
|
2978
|
-
|
2971
|
+
_forwardInstancePath: function (inst, path, value) {
|
2972
|
+
},
|
2973
|
+
_notifyPathImpl: function (path, value) {
|
2979
2974
|
var dataHost = this.dataHost;
|
2980
|
-
var dot = path.indexOf(
|
2975
|
+
var dot = path.indexOf('.');
|
2981
2976
|
var root = dot < 0 ? path : path.slice(0, dot);
|
2982
2977
|
dataHost._forwardInstancePath.call(dataHost, this, path, value);
|
2983
2978
|
if (root in dataHost._parentProps) {
|
2984
|
-
dataHost.notifyPath(
|
2979
|
+
dataHost.notifyPath('_parent_' + path, value);
|
2985
2980
|
}
|
2986
2981
|
},
|
2987
|
-
_pathEffector: function(path, value, fromAbove) {
|
2982
|
+
_pathEffector: function (path, value, fromAbove) {
|
2988
2983
|
if (this._forwardParentPath) {
|
2989
|
-
if (path.indexOf(
|
2984
|
+
if (path.indexOf('_parent_') === 0) {
|
2990
2985
|
this._forwardParentPath(path.substring(8), value);
|
2991
2986
|
}
|
2992
2987
|
}
|
2993
2988
|
Polymer.Base._pathEffector.apply(this, arguments);
|
2994
2989
|
},
|
2995
|
-
_constructorImpl: function(model, host) {
|
2990
|
+
_constructorImpl: function (model, host) {
|
2996
2991
|
this._rootDataHost = host._getRootDataHost();
|
2997
2992
|
this._setupConfigure(model);
|
2998
2993
|
this._pushHost(host);
|
@@ -3010,115 +3005,111 @@ n._templateInstance = this;
|
|
3010
3005
|
this._children = children;
|
3011
3006
|
this._tryReady();
|
3012
3007
|
},
|
3013
|
-
_listenImpl: function(node, eventName, methodName) {
|
3008
|
+
_listenImpl: function (node, eventName, methodName) {
|
3014
3009
|
var model = this;
|
3015
3010
|
var host = this._rootDataHost;
|
3016
3011
|
var handler = host._createEventHandler(node, eventName, methodName);
|
3017
|
-
var decorated = function(e) {
|
3012
|
+
var decorated = function (e) {
|
3018
3013
|
e.model = model;
|
3019
3014
|
handler(e);
|
3020
3015
|
};
|
3021
3016
|
host._listen(node, eventName, decorated);
|
3022
3017
|
},
|
3023
|
-
_scopeElementClassImpl: function(node, value) {
|
3018
|
+
_scopeElementClassImpl: function (node, value) {
|
3024
3019
|
var host = this._rootDataHost;
|
3025
3020
|
if (host) {
|
3026
3021
|
return host._scopeElementClass(node, value);
|
3027
3022
|
}
|
3028
3023
|
},
|
3029
|
-
stamp: function(model) {
|
3024
|
+
stamp: function (model) {
|
3030
3025
|
model = model || {};
|
3031
3026
|
if (this._parentProps) {
|
3032
3027
|
for (var prop in this._parentProps) {
|
3033
|
-
model[prop] = this[
|
3028
|
+
model[prop] = this['_parent_' + prop];
|
3034
3029
|
}
|
3035
3030
|
}
|
3036
3031
|
return new this.ctor(model, this);
|
3037
3032
|
}
|
3038
3033
|
};
|
3039
|
-
|
3040
3034
|
Polymer({
|
3041
|
-
is:
|
3042
|
-
|
3043
|
-
behaviors: [
|
3044
|
-
ready: function() {
|
3035
|
+
is: 'dom-template',
|
3036
|
+
extends: 'template',
|
3037
|
+
behaviors: [Polymer.Templatizer],
|
3038
|
+
ready: function () {
|
3045
3039
|
this.templatize(this);
|
3046
3040
|
}
|
3047
3041
|
});
|
3048
|
-
|
3049
3042
|
Polymer._collections = new WeakMap();
|
3050
|
-
|
3051
|
-
Polymer.Collection = function(userArray) {
|
3043
|
+
Polymer.Collection = function (userArray) {
|
3052
3044
|
Polymer._collections.set(userArray, this);
|
3053
3045
|
this.userArray = userArray;
|
3054
3046
|
this.store = userArray.slice();
|
3055
3047
|
this.initMap();
|
3056
3048
|
};
|
3057
|
-
|
3058
3049
|
Polymer.Collection.prototype = {
|
3059
3050
|
constructor: Polymer.Collection,
|
3060
|
-
initMap: function() {
|
3051
|
+
initMap: function () {
|
3061
3052
|
var omap = this.omap = new WeakMap();
|
3062
3053
|
var pmap = this.pmap = {};
|
3063
3054
|
var s = this.store;
|
3064
3055
|
for (var i = 0; i < s.length; i++) {
|
3065
3056
|
var item = s[i];
|
3066
|
-
if (item && typeof item ==
|
3057
|
+
if (item && typeof item == 'object') {
|
3067
3058
|
omap.set(item, i);
|
3068
3059
|
} else {
|
3069
3060
|
pmap[item] = i;
|
3070
3061
|
}
|
3071
3062
|
}
|
3072
3063
|
},
|
3073
|
-
add: function(item) {
|
3064
|
+
add: function (item) {
|
3074
3065
|
var key = this.store.push(item) - 1;
|
3075
|
-
if (item && typeof item ==
|
3066
|
+
if (item && typeof item == 'object') {
|
3076
3067
|
this.omap.set(item, key);
|
3077
3068
|
} else {
|
3078
3069
|
this.pmap[item] = key;
|
3079
3070
|
}
|
3080
3071
|
return key;
|
3081
3072
|
},
|
3082
|
-
removeKey: function(key) {
|
3073
|
+
removeKey: function (key) {
|
3083
3074
|
this._removeFromMap(this.store[key]);
|
3084
3075
|
delete this.store[key];
|
3085
3076
|
},
|
3086
|
-
_removeFromMap: function(item) {
|
3087
|
-
if (typeof item ==
|
3077
|
+
_removeFromMap: function (item) {
|
3078
|
+
if (typeof item == 'object') {
|
3088
3079
|
this.omap.delete(item);
|
3089
3080
|
} else {
|
3090
3081
|
delete this.pmap[item];
|
3091
3082
|
}
|
3092
3083
|
},
|
3093
|
-
remove: function(item) {
|
3084
|
+
remove: function (item) {
|
3094
3085
|
var key = this.getKey(item);
|
3095
3086
|
this.removeKey(key);
|
3096
3087
|
return key;
|
3097
3088
|
},
|
3098
|
-
getKey: function(item) {
|
3099
|
-
if (typeof item ==
|
3089
|
+
getKey: function (item) {
|
3090
|
+
if (typeof item == 'object') {
|
3100
3091
|
return this.omap.get(item);
|
3101
3092
|
} else {
|
3102
3093
|
return this.pmap[item];
|
3103
3094
|
}
|
3104
3095
|
},
|
3105
|
-
getKeys: function() {
|
3096
|
+
getKeys: function () {
|
3106
3097
|
return Object.keys(this.store);
|
3107
3098
|
},
|
3108
|
-
setItem: function(key, value) {
|
3099
|
+
setItem: function (key, value) {
|
3109
3100
|
this.store[key] = value;
|
3110
3101
|
},
|
3111
|
-
getItem: function(key) {
|
3102
|
+
getItem: function (key) {
|
3112
3103
|
return this.store[key];
|
3113
3104
|
},
|
3114
|
-
getItems: function() {
|
3105
|
+
getItems: function () {
|
3115
3106
|
var items = [], store = this.store;
|
3116
3107
|
for (var key in store) {
|
3117
3108
|
items.push(store[key]);
|
3118
3109
|
}
|
3119
3110
|
return items;
|
3120
3111
|
},
|
3121
|
-
applySplices: function(splices) {
|
3112
|
+
applySplices: function (splices) {
|
3122
3113
|
var keySplices = [];
|
3123
3114
|
for (var i = 0; i < splices.length; i++) {
|
3124
3115
|
var j, o, key, s = splices[i];
|
@@ -3144,64 +3135,65 @@ added: added
|
|
3144
3135
|
return keySplices;
|
3145
3136
|
}
|
3146
3137
|
};
|
3147
|
-
|
3148
|
-
Polymer.Collection.get = function(userArray) {
|
3138
|
+
Polymer.Collection.get = function (userArray) {
|
3149
3139
|
return Polymer._collections.get(userArray) || new Polymer.Collection(userArray);
|
3150
3140
|
};
|
3151
|
-
|
3152
3141
|
Polymer({
|
3153
|
-
is:
|
3154
|
-
|
3142
|
+
is: 'dom-repeat',
|
3143
|
+
extends: 'template',
|
3155
3144
|
properties: {
|
3156
|
-
items: {
|
3157
|
-
type: Array
|
3158
|
-
},
|
3145
|
+
items: { type: Array },
|
3159
3146
|
as: {
|
3160
3147
|
type: String,
|
3161
|
-
value:
|
3148
|
+
value: 'item'
|
3162
3149
|
},
|
3163
3150
|
indexAs: {
|
3164
3151
|
type: String,
|
3165
|
-
value:
|
3152
|
+
value: 'index'
|
3166
3153
|
},
|
3167
3154
|
sort: {
|
3168
3155
|
type: Function,
|
3169
|
-
observer:
|
3156
|
+
observer: '_sortChanged'
|
3170
3157
|
},
|
3171
3158
|
filter: {
|
3172
3159
|
type: Function,
|
3173
|
-
observer:
|
3160
|
+
observer: '_filterChanged'
|
3174
3161
|
},
|
3175
3162
|
observe: {
|
3176
3163
|
type: String,
|
3177
|
-
observer:
|
3164
|
+
observer: '_observeChanged'
|
3178
3165
|
},
|
3179
3166
|
delay: Number
|
3180
3167
|
},
|
3181
|
-
behaviors: [
|
3182
|
-
observers: [
|
3183
|
-
detached: function() {
|
3168
|
+
behaviors: [Polymer.Templatizer],
|
3169
|
+
observers: ['_itemsChanged(items.*)'],
|
3170
|
+
detached: function () {
|
3184
3171
|
if (this.rows) {
|
3185
3172
|
for (var i = 0; i < this.rows.length; i++) {
|
3186
3173
|
this._detachRow(i);
|
3187
3174
|
}
|
3188
3175
|
}
|
3189
|
-
this.rows = null;
|
3190
3176
|
},
|
3191
|
-
|
3192
|
-
this.
|
3193
|
-
|
3194
|
-
|
3177
|
+
attached: function () {
|
3178
|
+
if (this.rows) {
|
3179
|
+
var parentNode = Polymer.dom(this).parentNode;
|
3180
|
+
for (var i = 0; i < this.rows.length; i++) {
|
3181
|
+
Polymer.dom(parentNode).insertBefore(this.rows[i].root, this);
|
3182
|
+
}
|
3183
|
+
}
|
3184
|
+
},
|
3185
|
+
ready: function () {
|
3186
|
+
this._instanceProps = { __key__: true };
|
3195
3187
|
this._instanceProps[this.as] = true;
|
3196
3188
|
this._instanceProps[this.indexAs] = true;
|
3197
3189
|
if (!this.ctor) {
|
3198
3190
|
this.templatize(this);
|
3199
3191
|
}
|
3200
3192
|
},
|
3201
|
-
_sortChanged: function() {
|
3193
|
+
_sortChanged: function () {
|
3202
3194
|
var dataHost = this._getRootDataHost();
|
3203
3195
|
var sort = this.sort;
|
3204
|
-
this._sortFn = sort && (typeof sort ==
|
3196
|
+
this._sortFn = sort && (typeof sort == 'function' ? sort : function () {
|
3205
3197
|
return dataHost[sort].apply(dataHost, arguments);
|
3206
3198
|
});
|
3207
3199
|
this._fullRefresh = true;
|
@@ -3209,10 +3201,10 @@ if (this.items) {
|
|
3209
3201
|
this._debounceTemplate(this._render);
|
3210
3202
|
}
|
3211
3203
|
},
|
3212
|
-
_filterChanged: function() {
|
3204
|
+
_filterChanged: function () {
|
3213
3205
|
var dataHost = this._getRootDataHost();
|
3214
3206
|
var filter = this.filter;
|
3215
|
-
this._filterFn = filter && (typeof filter ==
|
3207
|
+
this._filterFn = filter && (typeof filter == 'function' ? filter : function () {
|
3216
3208
|
return dataHost[filter].apply(dataHost, arguments);
|
3217
3209
|
});
|
3218
3210
|
this._fullRefresh = true;
|
@@ -3220,22 +3212,22 @@ if (this.items) {
|
|
3220
3212
|
this._debounceTemplate(this._render);
|
3221
3213
|
}
|
3222
3214
|
},
|
3223
|
-
_observeChanged: function() {
|
3224
|
-
this._observePaths = this.observe && this.observe.replace(
|
3215
|
+
_observeChanged: function () {
|
3216
|
+
this._observePaths = this.observe && this.observe.replace('.*', '.').split(' ');
|
3225
3217
|
},
|
3226
|
-
_itemsChanged: function(change) {
|
3227
|
-
if (change.path ==
|
3218
|
+
_itemsChanged: function (change) {
|
3219
|
+
if (change.path == 'items') {
|
3228
3220
|
if (Array.isArray(this.items)) {
|
3229
3221
|
this.collection = Polymer.Collection.get(this.items);
|
3230
3222
|
} else if (!this.items) {
|
3231
3223
|
this.collection = null;
|
3232
3224
|
} else {
|
3233
|
-
this._error(this._logf(
|
3225
|
+
this._error(this._logf('dom-repeat', 'expected array for `items`,' + ' found', this.items));
|
3234
3226
|
}
|
3235
3227
|
this._splices = [];
|
3236
3228
|
this._fullRefresh = true;
|
3237
3229
|
this._debounceTemplate(this._render);
|
3238
|
-
} else if (change.path ==
|
3230
|
+
} else if (change.path == 'items.splices') {
|
3239
3231
|
this._splices = this._splices.concat(change.value.keySplices);
|
3240
3232
|
this._debounceTemplate(this._render);
|
3241
3233
|
} else {
|
@@ -3244,15 +3236,15 @@ this._forwardItemPath(subpath, change.value);
|
|
3244
3236
|
this._checkObservedPaths(subpath);
|
3245
3237
|
}
|
3246
3238
|
},
|
3247
|
-
_checkObservedPaths: function(path) {
|
3239
|
+
_checkObservedPaths: function (path) {
|
3248
3240
|
if (this._observePaths) {
|
3249
|
-
path = path.substring(path.indexOf(
|
3241
|
+
path = path.substring(path.indexOf('.') + 1);
|
3250
3242
|
var paths = this._observePaths;
|
3251
3243
|
for (var i = 0; i < paths.length; i++) {
|
3252
3244
|
if (path.indexOf(paths[i]) === 0) {
|
3253
3245
|
this._fullRefresh = true;
|
3254
3246
|
if (this.delay) {
|
3255
|
-
this.debounce(
|
3247
|
+
this.debounce('render', this._render, this.delay);
|
3256
3248
|
} else {
|
3257
3249
|
this._debounceTemplate(this._render);
|
3258
3250
|
}
|
@@ -3261,12 +3253,12 @@ return;
|
|
3261
3253
|
}
|
3262
3254
|
}
|
3263
3255
|
},
|
3264
|
-
render: function() {
|
3256
|
+
render: function () {
|
3265
3257
|
this._fullRefresh = true;
|
3266
|
-
this.debounce(
|
3258
|
+
this.debounce('render', this._render);
|
3267
3259
|
this._flushTemplates();
|
3268
3260
|
},
|
3269
|
-
_render: function() {
|
3261
|
+
_render: function () {
|
3270
3262
|
var c = this.collection;
|
3271
3263
|
if (!this._fullRefresh) {
|
3272
3264
|
if (this._sortFn) {
|
@@ -3299,13 +3291,13 @@ row[this.as] = item;
|
|
3299
3291
|
row.__key__ = key;
|
3300
3292
|
row[this.indexAs] = i;
|
3301
3293
|
}
|
3302
|
-
for (;i < this.rows.length; i++) {
|
3294
|
+
for (; i < this.rows.length; i++) {
|
3303
3295
|
this._detachRow(i);
|
3304
3296
|
}
|
3305
3297
|
this.rows.splice(keys.length, this.rows.length - keys.length);
|
3306
|
-
this.fire(
|
3298
|
+
this.fire('dom-change');
|
3307
3299
|
},
|
3308
|
-
_sortAndFilter: function() {
|
3300
|
+
_sortAndFilter: function () {
|
3309
3301
|
var c = this.collection;
|
3310
3302
|
if (!this._sortFn) {
|
3311
3303
|
this._orderedKeys = [];
|
@@ -3319,20 +3311,20 @@ this._orderedKeys.push(c.getKey(items[i]));
|
|
3319
3311
|
this._orderedKeys = c ? c.getKeys() : [];
|
3320
3312
|
}
|
3321
3313
|
if (this._filterFn) {
|
3322
|
-
this._orderedKeys = this._orderedKeys.filter(function(a) {
|
3314
|
+
this._orderedKeys = this._orderedKeys.filter(function (a) {
|
3323
3315
|
return this._filterFn(c.getItem(a));
|
3324
3316
|
}, this);
|
3325
3317
|
}
|
3326
3318
|
if (this._sortFn) {
|
3327
|
-
this._orderedKeys.sort(function(a, b) {
|
3319
|
+
this._orderedKeys.sort(function (a, b) {
|
3328
3320
|
return this._sortFn(c.getItem(a), c.getItem(b));
|
3329
3321
|
}.bind(this));
|
3330
3322
|
}
|
3331
3323
|
},
|
3332
|
-
_keySort: function(a, b) {
|
3324
|
+
_keySort: function (a, b) {
|
3333
3325
|
return this.collection.getKey(a) - this.collection.getKey(b);
|
3334
3326
|
},
|
3335
|
-
_applySplicesViewSort: function(splices) {
|
3327
|
+
_applySplicesViewSort: function (splices) {
|
3336
3328
|
var c = this.collection;
|
3337
3329
|
var keys = this._orderedKeys;
|
3338
3330
|
var rows = this.rows;
|
@@ -3340,7 +3332,7 @@ var removedRows = [];
|
|
3340
3332
|
var addedKeys = [];
|
3341
3333
|
var pool = [];
|
3342
3334
|
var sortFn = this._sortFn || this._keySort.bind(this);
|
3343
|
-
splices.forEach(function(s) {
|
3335
|
+
splices.forEach(function (s) {
|
3344
3336
|
for (var i = 0; i < s.removed.length; i++) {
|
3345
3337
|
var idx = this._rowForKey[s.removed[i]];
|
3346
3338
|
if (idx != null) {
|
@@ -3362,11 +3354,11 @@ keys.splice(idx, 1);
|
|
3362
3354
|
}
|
3363
3355
|
if (addedKeys.length) {
|
3364
3356
|
if (this._filterFn) {
|
3365
|
-
addedKeys = addedKeys.filter(function(a) {
|
3357
|
+
addedKeys = addedKeys.filter(function (a) {
|
3366
3358
|
return this._filterFn(c.getItem(a));
|
3367
3359
|
}, this);
|
3368
3360
|
}
|
3369
|
-
addedKeys.sort(function(a, b) {
|
3361
|
+
addedKeys.sort(function (a, b) {
|
3370
3362
|
return this._sortFn(c.getItem(a), c.getItem(b));
|
3371
3363
|
}.bind(this));
|
3372
3364
|
var start = 0;
|
@@ -3375,7 +3367,7 @@ start = this._insertRowIntoViewSort(start, addedKeys[i], pool);
|
|
3375
3367
|
}
|
3376
3368
|
}
|
3377
3369
|
},
|
3378
|
-
_insertRowIntoViewSort: function(start, key, pool) {
|
3370
|
+
_insertRowIntoViewSort: function (start, key, pool) {
|
3379
3371
|
var c = this.collection;
|
3380
3372
|
var item = c.getItem(key);
|
3381
3373
|
var end = this.rows.length - 1;
|
@@ -3401,18 +3393,21 @@ this._orderedKeys.splice(idx, 0, key);
|
|
3401
3393
|
this.rows.splice(idx, 0, this._insertRow(idx, pool, c.getItem(key)));
|
3402
3394
|
return idx;
|
3403
3395
|
},
|
3404
|
-
_applySplicesArraySort: function(splices) {
|
3396
|
+
_applySplicesArraySort: function (splices) {
|
3405
3397
|
var keys = this._orderedKeys;
|
3406
3398
|
var pool = [];
|
3407
|
-
splices.forEach(function(s) {
|
3399
|
+
splices.forEach(function (s) {
|
3408
3400
|
for (var i = 0; i < s.removed.length; i++) {
|
3409
3401
|
pool.push(this._detachRow(s.index + i));
|
3410
3402
|
}
|
3411
3403
|
this.rows.splice(s.index, s.removed.length);
|
3412
3404
|
}, this);
|
3413
3405
|
var c = this.collection;
|
3414
|
-
splices.forEach(function(s) {
|
3415
|
-
var args = [
|
3406
|
+
splices.forEach(function (s) {
|
3407
|
+
var args = [
|
3408
|
+
s.index,
|
3409
|
+
s.removed.length
|
3410
|
+
].concat(s.added);
|
3416
3411
|
keys.splice.apply(keys, args);
|
3417
3412
|
for (var i = 0; i < s.added.length; i++) {
|
3418
3413
|
var item = c.getItem(s.added[i]);
|
@@ -3421,7 +3416,7 @@ this.rows.splice(s.index + i, 0, row);
|
|
3421
3416
|
}
|
3422
3417
|
}, this);
|
3423
3418
|
},
|
3424
|
-
_detachRow: function(idx) {
|
3419
|
+
_detachRow: function (idx) {
|
3425
3420
|
var row = this.rows[idx];
|
3426
3421
|
var parentNode = Polymer.dom(this).parentNode;
|
3427
3422
|
for (var i = 0; i < row._children.length; i++) {
|
@@ -3430,7 +3425,7 @@ Polymer.dom(row.root).appendChild(el);
|
|
3430
3425
|
}
|
3431
3426
|
return row;
|
3432
3427
|
},
|
3433
|
-
_insertRow: function(idx, pool, item) {
|
3428
|
+
_insertRow: function (idx, pool, item) {
|
3434
3429
|
var row = pool && pool.pop() || this._generateRow(idx, item);
|
3435
3430
|
var beforeRow = this.rows[idx];
|
3436
3431
|
var beforeNode = beforeRow ? beforeRow._children[0] : this;
|
@@ -3438,58 +3433,56 @@ var parentNode = Polymer.dom(this).parentNode;
|
|
3438
3433
|
Polymer.dom(parentNode).insertBefore(row.root, beforeNode);
|
3439
3434
|
return row;
|
3440
3435
|
},
|
3441
|
-
_generateRow: function(idx, item) {
|
3442
|
-
var model = {
|
3443
|
-
__key__: this.collection.getKey(item)
|
3444
|
-
};
|
3436
|
+
_generateRow: function (idx, item) {
|
3437
|
+
var model = { __key__: this.collection.getKey(item) };
|
3445
3438
|
model[this.as] = item;
|
3446
3439
|
model[this.indexAs] = idx;
|
3447
3440
|
var row = this.stamp(model);
|
3448
3441
|
return row;
|
3449
3442
|
},
|
3450
|
-
|
3443
|
+
_showHideChildren: function (hidden) {
|
3451
3444
|
if (this.rows) {
|
3452
3445
|
for (var i = 0; i < this.rows.length; i++) {
|
3453
3446
|
var c$ = this.rows[i]._children;
|
3454
3447
|
for (var j = 0; j < c$.length; j++) {
|
3455
3448
|
var c = c$[j];
|
3456
3449
|
if (c.style) {
|
3457
|
-
c.style.display = hidden ?
|
3450
|
+
c.style.display = hidden ? 'none' : '';
|
3458
3451
|
}
|
3459
3452
|
c._hideTemplateChildren = hidden;
|
3460
3453
|
}
|
3461
3454
|
}
|
3462
3455
|
}
|
3463
3456
|
},
|
3464
|
-
_forwardInstancePath: function(row, path, value) {
|
3465
|
-
if (path.indexOf(this.as +
|
3466
|
-
this.notifyPath(
|
3457
|
+
_forwardInstancePath: function (row, path, value) {
|
3458
|
+
if (path.indexOf(this.as + '.') === 0) {
|
3459
|
+
this.notifyPath('items.' + row.__key__ + '.' + path.slice(this.as.length + 1), value);
|
3467
3460
|
return true;
|
3468
3461
|
}
|
3469
3462
|
},
|
3470
|
-
_forwardParentProp: function(prop, value) {
|
3463
|
+
_forwardParentProp: function (prop, value) {
|
3471
3464
|
if (this.rows) {
|
3472
|
-
this.rows.forEach(function(row) {
|
3465
|
+
this.rows.forEach(function (row) {
|
3473
3466
|
row[prop] = value;
|
3474
3467
|
}, this);
|
3475
3468
|
}
|
3476
3469
|
},
|
3477
|
-
_forwardParentPath: function(path, value) {
|
3470
|
+
_forwardParentPath: function (path, value) {
|
3478
3471
|
if (this.rows) {
|
3479
|
-
this.rows.forEach(function(row) {
|
3472
|
+
this.rows.forEach(function (row) {
|
3480
3473
|
row.notifyPath(path, value, true);
|
3481
3474
|
}, this);
|
3482
3475
|
}
|
3483
3476
|
},
|
3484
|
-
_forwardItemPath: function(path, value) {
|
3477
|
+
_forwardItemPath: function (path, value) {
|
3485
3478
|
if (this._rowForKey) {
|
3486
|
-
var dot = path.indexOf(
|
3479
|
+
var dot = path.indexOf('.');
|
3487
3480
|
var key = path.substring(0, dot < 0 ? path.length : dot);
|
3488
3481
|
var idx = this._rowForKey[key];
|
3489
3482
|
var row = this.rows[idx];
|
3490
3483
|
if (row) {
|
3491
3484
|
if (dot >= 0) {
|
3492
|
-
path = this.as +
|
3485
|
+
path = this.as + '.' + path.substring(dot + 1);
|
3493
3486
|
row.notifyPath(path, value, true);
|
3494
3487
|
} else {
|
3495
3488
|
row[this.as] = value;
|
@@ -3497,7 +3490,7 @@ row[this.as] = value;
|
|
3497
3490
|
}
|
3498
3491
|
}
|
3499
3492
|
},
|
3500
|
-
modelForElement: function(el) {
|
3493
|
+
modelForElement: function (el) {
|
3501
3494
|
var model;
|
3502
3495
|
while (el) {
|
3503
3496
|
if (model = el._templateInstance) {
|
@@ -3511,26 +3504,25 @@ el = el.parentNode;
|
|
3511
3504
|
}
|
3512
3505
|
}
|
3513
3506
|
},
|
3514
|
-
itemForElement: function(el) {
|
3507
|
+
itemForElement: function (el) {
|
3515
3508
|
var instance = this.modelForElement(el);
|
3516
3509
|
return instance && instance[this.as];
|
3517
3510
|
},
|
3518
|
-
keyForElement: function(el) {
|
3511
|
+
keyForElement: function (el) {
|
3519
3512
|
var instance = this.modelForElement(el);
|
3520
3513
|
return instance && instance.__key__;
|
3521
3514
|
},
|
3522
|
-
indexForElement: function(el) {
|
3515
|
+
indexForElement: function (el) {
|
3523
3516
|
var instance = this.modelForElement(el);
|
3524
3517
|
return instance && instance[this.indexAs];
|
3525
3518
|
}
|
3526
3519
|
});
|
3527
|
-
|
3528
3520
|
Polymer({
|
3529
|
-
is:
|
3521
|
+
is: 'array-selector',
|
3530
3522
|
properties: {
|
3531
3523
|
items: {
|
3532
3524
|
type: Array,
|
3533
|
-
observer:
|
3525
|
+
observer: '_itemsChanged'
|
3534
3526
|
},
|
3535
3527
|
selected: {
|
3536
3528
|
type: Object,
|
@@ -3539,13 +3531,13 @@ notify: true
|
|
3539
3531
|
toggle: Boolean,
|
3540
3532
|
multi: Boolean
|
3541
3533
|
},
|
3542
|
-
_itemsChanged: function() {
|
3534
|
+
_itemsChanged: function () {
|
3543
3535
|
if (Array.isArray(this.selected)) {
|
3544
3536
|
for (var i = 0; i < this.selected.length; i++) {
|
3545
|
-
this.unlinkPaths(
|
3537
|
+
this.unlinkPaths('selected.' + i);
|
3546
3538
|
}
|
3547
3539
|
} else {
|
3548
|
-
this.unlinkPaths(
|
3540
|
+
this.unlinkPaths('selected');
|
3549
3541
|
}
|
3550
3542
|
if (this.multi) {
|
3551
3543
|
this.selected = [];
|
@@ -3553,22 +3545,22 @@ this.selected = [];
|
|
3553
3545
|
this.selected = null;
|
3554
3546
|
}
|
3555
3547
|
},
|
3556
|
-
deselect: function(item) {
|
3548
|
+
deselect: function (item) {
|
3557
3549
|
if (this.multi) {
|
3558
3550
|
var scol = Polymer.Collection.get(this.selected);
|
3559
3551
|
var sidx = this.selected.indexOf(item);
|
3560
3552
|
if (sidx >= 0) {
|
3561
3553
|
var skey = scol.getKey(item);
|
3562
|
-
this.splice(
|
3563
|
-
this.unlinkPaths(
|
3554
|
+
this.splice('selected', sidx, 1);
|
3555
|
+
this.unlinkPaths('selected.' + skey);
|
3564
3556
|
return true;
|
3565
3557
|
}
|
3566
3558
|
} else {
|
3567
3559
|
this.selected = null;
|
3568
|
-
this.unlinkPaths(
|
3560
|
+
this.unlinkPaths('selected');
|
3569
3561
|
}
|
3570
3562
|
},
|
3571
|
-
select: function(item) {
|
3563
|
+
select: function (item) {
|
3572
3564
|
var icol = Polymer.Collection.get(this.items);
|
3573
3565
|
var key = icol.getKey(item);
|
3574
3566
|
if (this.multi) {
|
@@ -3577,28 +3569,27 @@ var skey = scol.getKey(item);
|
|
3577
3569
|
if (skey >= 0) {
|
3578
3570
|
this.deselect(item);
|
3579
3571
|
} else if (this.toggle) {
|
3580
|
-
this.push(
|
3581
|
-
this.async(function() {
|
3572
|
+
this.push('selected', item);
|
3573
|
+
this.async(function () {
|
3582
3574
|
skey = scol.getKey(item);
|
3583
|
-
this.linkPaths(
|
3575
|
+
this.linkPaths('selected.' + skey, 'items.' + key);
|
3584
3576
|
});
|
3585
3577
|
}
|
3586
3578
|
} else {
|
3587
3579
|
if (this.toggle && item == this.selected) {
|
3588
3580
|
this.deselect();
|
3589
3581
|
} else {
|
3590
|
-
this.linkPaths(
|
3582
|
+
this.linkPaths('selected', 'items.' + key);
|
3591
3583
|
this.selected = item;
|
3592
3584
|
}
|
3593
3585
|
}
|
3594
3586
|
}
|
3595
3587
|
});
|
3596
|
-
|
3597
3588
|
Polymer({
|
3598
|
-
is:
|
3599
|
-
|
3589
|
+
is: 'dom-if',
|
3590
|
+
extends: 'template',
|
3600
3591
|
properties: {
|
3601
|
-
|
3592
|
+
'if': {
|
3602
3593
|
type: Boolean,
|
3603
3594
|
value: false
|
3604
3595
|
},
|
@@ -3607,42 +3598,42 @@ type: Boolean,
|
|
3607
3598
|
value: false
|
3608
3599
|
}
|
3609
3600
|
},
|
3610
|
-
behaviors: [
|
3611
|
-
observers: [
|
3612
|
-
_queueRender: function() {
|
3601
|
+
behaviors: [Polymer.Templatizer],
|
3602
|
+
observers: ['_queueRender(if, restamp)'],
|
3603
|
+
_queueRender: function () {
|
3613
3604
|
this._debounceTemplate(this._render);
|
3614
3605
|
},
|
3615
|
-
detached: function() {
|
3606
|
+
detached: function () {
|
3616
3607
|
this._teardownInstance();
|
3617
3608
|
},
|
3618
|
-
attached: function() {
|
3609
|
+
attached: function () {
|
3619
3610
|
if (this.if && this.ctor) {
|
3620
3611
|
this.async(this._ensureInstance);
|
3621
3612
|
}
|
3622
3613
|
},
|
3623
|
-
render: function() {
|
3614
|
+
render: function () {
|
3624
3615
|
this._flushTemplates();
|
3625
3616
|
},
|
3626
|
-
_render: function() {
|
3617
|
+
_render: function () {
|
3627
3618
|
if (this.if) {
|
3628
3619
|
if (!this.ctor) {
|
3629
3620
|
this._wrapTextNodes(this._content || this.content);
|
3630
3621
|
this.templatize(this);
|
3631
3622
|
}
|
3632
3623
|
this._ensureInstance();
|
3633
|
-
this.
|
3624
|
+
this._showHideChildren();
|
3634
3625
|
} else if (this.restamp) {
|
3635
3626
|
this._teardownInstance();
|
3636
3627
|
}
|
3637
3628
|
if (!this.restamp && this._instance) {
|
3638
|
-
this.
|
3629
|
+
this._showHideChildren();
|
3639
3630
|
}
|
3640
3631
|
if (this.if != this._lastIf) {
|
3641
|
-
this.fire(
|
3632
|
+
this.fire('dom-change');
|
3642
3633
|
this._lastIf = this.if;
|
3643
3634
|
}
|
3644
3635
|
},
|
3645
|
-
_ensureInstance: function() {
|
3636
|
+
_ensureInstance: function () {
|
3646
3637
|
if (!this._instance) {
|
3647
3638
|
this._instance = this.stamp();
|
3648
3639
|
var root = this._instance.root;
|
@@ -3650,116 +3641,114 @@ var parent = Polymer.dom(Polymer.dom(this).parentNode);
|
|
3650
3641
|
parent.insertBefore(root, this);
|
3651
3642
|
}
|
3652
3643
|
},
|
3653
|
-
_teardownInstance: function() {
|
3644
|
+
_teardownInstance: function () {
|
3654
3645
|
if (this._instance) {
|
3655
3646
|
var c = this._instance._children;
|
3656
3647
|
if (c) {
|
3657
3648
|
var parent = Polymer.dom(Polymer.dom(c[0]).parentNode);
|
3658
|
-
c.forEach(function(n) {
|
3649
|
+
c.forEach(function (n) {
|
3659
3650
|
parent.removeChild(n);
|
3660
3651
|
});
|
3661
3652
|
}
|
3662
3653
|
this._instance = null;
|
3663
3654
|
}
|
3664
3655
|
},
|
3665
|
-
_wrapTextNodes: function(root) {
|
3656
|
+
_wrapTextNodes: function (root) {
|
3666
3657
|
for (var n = root.firstChild; n; n = n.nextSibling) {
|
3667
3658
|
if (n.nodeType === Node.TEXT_NODE) {
|
3668
|
-
var s = document.createElement(
|
3659
|
+
var s = document.createElement('span');
|
3669
3660
|
root.insertBefore(s, n);
|
3670
3661
|
s.appendChild(n);
|
3671
3662
|
n = s;
|
3672
3663
|
}
|
3673
3664
|
}
|
3674
3665
|
},
|
3675
|
-
|
3666
|
+
_showHideChildren: function () {
|
3667
|
+
var hidden = this._hideTemplateChildren || !this.if;
|
3676
3668
|
if (this._instance) {
|
3677
3669
|
var c$ = this._instance._children;
|
3678
3670
|
for (var i = 0; i < c$.length; i++) {
|
3679
3671
|
var c = c$[i];
|
3680
|
-
c.style.display = hidden ?
|
3672
|
+
c.style.display = hidden ? 'none' : '';
|
3681
3673
|
c._hideTemplateChildren = hidden;
|
3682
3674
|
}
|
3683
3675
|
}
|
3684
3676
|
},
|
3685
|
-
_forwardParentProp: function(prop, value) {
|
3677
|
+
_forwardParentProp: function (prop, value) {
|
3686
3678
|
if (this._instance) {
|
3687
3679
|
this._instance[prop] = value;
|
3688
3680
|
}
|
3689
3681
|
},
|
3690
|
-
_forwardParentPath: function(path, value) {
|
3682
|
+
_forwardParentPath: function (path, value) {
|
3691
3683
|
if (this._instance) {
|
3692
3684
|
this._instance.notifyPath(path, value, true);
|
3693
3685
|
}
|
3694
3686
|
}
|
3695
3687
|
});
|
3696
|
-
|
3697
3688
|
Polymer.ImportStatus = {
|
3698
3689
|
_ready: false,
|
3699
3690
|
_callbacks: [],
|
3700
|
-
whenLoaded: function(cb) {
|
3691
|
+
whenLoaded: function (cb) {
|
3701
3692
|
if (this._ready) {
|
3702
3693
|
cb();
|
3703
3694
|
} else {
|
3704
3695
|
this._callbacks.push(cb);
|
3705
3696
|
}
|
3706
3697
|
},
|
3707
|
-
_importsLoaded: function() {
|
3698
|
+
_importsLoaded: function () {
|
3708
3699
|
this._ready = true;
|
3709
|
-
this._callbacks.forEach(function(cb) {
|
3700
|
+
this._callbacks.forEach(function (cb) {
|
3710
3701
|
cb();
|
3711
3702
|
});
|
3712
3703
|
this._callbacks = [];
|
3713
3704
|
}
|
3714
3705
|
};
|
3715
|
-
|
3716
|
-
window.addEventListener("load", function() {
|
3706
|
+
window.addEventListener('load', function () {
|
3717
3707
|
Polymer.ImportStatus._importsLoaded();
|
3718
3708
|
});
|
3719
|
-
|
3720
3709
|
if (window.HTMLImports) {
|
3721
|
-
HTMLImports.whenReady(function() {
|
3710
|
+
HTMLImports.whenReady(function () {
|
3722
3711
|
Polymer.ImportStatus._importsLoaded();
|
3723
3712
|
});
|
3724
3713
|
}
|
3725
|
-
|
3726
3714
|
Polymer({
|
3727
|
-
is:
|
3728
|
-
|
3729
|
-
created: function() {
|
3715
|
+
is: 'dom-bind',
|
3716
|
+
extends: 'template',
|
3717
|
+
created: function () {
|
3730
3718
|
Polymer.ImportStatus.whenLoaded(this._readySelf.bind(this));
|
3731
3719
|
},
|
3732
|
-
_registerFeatures: function() {
|
3720
|
+
_registerFeatures: function () {
|
3733
3721
|
this._prepExtends();
|
3734
3722
|
this._prepConstructor();
|
3735
3723
|
},
|
3736
|
-
_insertChildren: function() {
|
3724
|
+
_insertChildren: function () {
|
3737
3725
|
var parentDom = Polymer.dom(Polymer.dom(this).parentNode);
|
3738
3726
|
parentDom.insertBefore(this.root, this);
|
3739
3727
|
},
|
3740
|
-
_removeChildren: function() {
|
3728
|
+
_removeChildren: function () {
|
3741
3729
|
if (this._children) {
|
3742
3730
|
for (var i = 0; i < this._children.length; i++) {
|
3743
3731
|
this.root.appendChild(this._children[i]);
|
3744
3732
|
}
|
3745
3733
|
}
|
3746
3734
|
},
|
3747
|
-
_initFeatures: function() {
|
3748
|
-
|
3735
|
+
_initFeatures: function () {
|
3736
|
+
},
|
3737
|
+
_scopeElementClass: function (element, selector) {
|
3749
3738
|
if (this.dataHost) {
|
3750
3739
|
return this.dataHost._scopeElementClass(element, selector);
|
3751
3740
|
} else {
|
3752
3741
|
return selector;
|
3753
3742
|
}
|
3754
3743
|
},
|
3755
|
-
_prepConfigure: function() {
|
3744
|
+
_prepConfigure: function () {
|
3756
3745
|
var config = {};
|
3757
3746
|
for (var prop in this._propertyEffects) {
|
3758
3747
|
config[prop] = this[prop];
|
3759
3748
|
}
|
3760
3749
|
this._setupConfigure = this._setupConfigure.bind(this, config);
|
3761
3750
|
},
|
3762
|
-
attached: function() {
|
3751
|
+
attached: function () {
|
3763
3752
|
if (!this._children) {
|
3764
3753
|
this._template = this;
|
3765
3754
|
this._prepAnnotations();
|
@@ -3771,9 +3760,9 @@ Polymer.Base._initFeatures.call(this);
|
|
3771
3760
|
this._children = Array.prototype.slice.call(this.root.childNodes);
|
3772
3761
|
}
|
3773
3762
|
this._insertChildren();
|
3774
|
-
this.fire(
|
3763
|
+
this.fire('dom-change');
|
3775
3764
|
},
|
3776
|
-
detached: function() {
|
3765
|
+
detached: function () {
|
3777
3766
|
this._removeChildren();
|
3778
3767
|
}
|
3779
3768
|
});</script>
|