polymer-rails 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,10 +23,11 @@ addEventListener('DOMContentLoaded', resolve);
23
23
  window.Polymer = {
24
24
  Settings: function () {
25
25
  var user = window.Polymer || {};
26
- location.search.slice(1).split('&').forEach(function (o) {
26
+ var parts = location.search.slice(1).split('&');
27
+ for (var i = 0, o; i < parts.length && (o = parts[i]); i++) {
27
28
  o = o.split('=');
28
29
  o[0] && (user[o[0]] = o[1] || true);
29
- });
30
+ }
30
31
  var wantShadow = user.dom === 'shadow';
31
32
  var hasShadow = Boolean(Element.prototype.createShadowRoot);
32
33
  var nativeShadow = hasShadow && !window.ShadowDOMPolyfill;
@@ -113,15 +114,43 @@ this._callbacks.push(cb);
113
114
  },
114
115
  _makeReady: function () {
115
116
  this._ready = true;
116
- this._callbacks.forEach(function (cb) {
117
- cb();
118
- });
117
+ for (var i = 0; i < this._callbacks.length; i++) {
118
+ this._callbacks[i]();
119
+ }
119
120
  this._callbacks = [];
120
121
  },
121
122
  _catchFirstRender: function () {
122
123
  requestAnimationFrame(function () {
123
124
  Polymer.RenderStatus._makeReady();
124
125
  });
126
+ },
127
+ _afterNextRenderQueue: [],
128
+ _waitingNextRender: false,
129
+ afterNextRender: function (element, fn, args) {
130
+ if (!this._waitingNextRender) {
131
+ this._waitingNextRender = true;
132
+ this.whenReady(this._flushAfterNextRender);
133
+ }
134
+ this._afterNextRenderQueue.push([
135
+ element,
136
+ fn,
137
+ args
138
+ ]);
139
+ },
140
+ _flushAfterNextRender: function () {
141
+ requestAnimationFrame(function () {
142
+ setTimeout(Polymer.RenderStatus.__flushAfterNextRender);
143
+ });
144
+ },
145
+ __flushAfterNextRender: function () {
146
+ var self = Polymer.RenderStatus;
147
+ self._waitingNextRender = false;
148
+ for (var i = 0, h; i < self._afterNextRenderQueue.length; i++) {
149
+ h = self._afterNextRenderQueue[i];
150
+ h[1].apply(h[0], h[2] || Polymer.nar);
151
+ }
152
+ ;
153
+ self._afterNextRenderQueue = [];
125
154
  }
126
155
  };
127
156
  if (window.HTMLImports) {
@@ -151,27 +180,33 @@ this._doBehavior('created');
151
180
  this._initFeatures();
152
181
  },
153
182
  attachedCallback: function () {
183
+ var self = this;
154
184
  Polymer.RenderStatus.whenReady(function () {
155
- this.isAttached = true;
156
- this._doBehavior('attached');
157
- }.bind(this));
185
+ self.isAttached = true;
186
+ self._doBehavior('attached');
187
+ });
158
188
  },
159
189
  detachedCallback: function () {
160
190
  this.isAttached = false;
161
191
  this._doBehavior('detached');
162
192
  },
163
- attributeChangedCallback: function (name) {
193
+ attributeChangedCallback: function (name, oldValue, newValue) {
164
194
  this._attributeChangedImpl(name);
165
- this._doBehavior('attributeChanged', arguments);
195
+ this._doBehavior('attributeChanged', [
196
+ name,
197
+ oldValue,
198
+ newValue
199
+ ]);
166
200
  },
167
201
  _attributeChangedImpl: function (name) {
168
202
  this._setAttributeToProperty(this, name);
169
203
  },
170
204
  extend: function (prototype, api) {
171
205
  if (prototype && api) {
172
- Object.getOwnPropertyNames(api).forEach(function (n) {
206
+ var n$ = Object.getOwnPropertyNames(api);
207
+ for (var i = 0, n; i < n$.length && (n = n$[i]); i++) {
173
208
  this.copyOwnProperty(n, api, prototype);
174
- }, this);
209
+ }
175
210
  }
176
211
  return prototype || api;
177
212
  },
@@ -301,7 +336,8 @@ return behaviors;
301
336
  },
302
337
  _flattenBehaviorsList: function (behaviors) {
303
338
  var flat = [];
304
- behaviors.forEach(function (b) {
339
+ for (var i = 0; i < behaviors.length; i++) {
340
+ var b = behaviors[i];
305
341
  if (b instanceof Array) {
306
342
  flat = flat.concat(this._flattenBehaviorsList(b));
307
343
  } else if (b) {
@@ -309,31 +345,16 @@ flat.push(b);
309
345
  } else {
310
346
  this._warn(this._logf('_flattenBehaviorsList', 'behavior is null, check for missing or 404 import'));
311
347
  }
312
- }, this);
348
+ }
313
349
  return flat;
314
350
  },
315
351
  _mixinBehavior: function (b) {
316
- Object.getOwnPropertyNames(b).forEach(function (n) {
317
- switch (n) {
318
- case 'hostAttributes':
319
- case 'registered':
320
- case 'properties':
321
- case 'observers':
322
- case 'listeners':
323
- case 'created':
324
- case 'attached':
325
- case 'detached':
326
- case 'attributeChanged':
327
- case 'configure':
328
- case 'ready':
329
- break;
330
- default:
331
- if (!this.hasOwnProperty(n)) {
352
+ var n$ = Object.getOwnPropertyNames(b);
353
+ for (var i = 0, n; i < n$.length && (n = n$[i]); i++) {
354
+ if (!Polymer.Base._behaviorProperties[n] && !this.hasOwnProperty(n)) {
332
355
  this.copyOwnProperty(n, b, this);
333
356
  }
334
- break;
335
357
  }
336
- }, this);
337
358
  },
338
359
  _prepBehaviors: function () {
339
360
  this._prepFlattenedBehaviors(this.behaviors);
@@ -345,9 +366,9 @@ this._prepBehavior(behaviors[i]);
345
366
  this._prepBehavior(this);
346
367
  },
347
368
  _doBehavior: function (name, args) {
348
- this.behaviors.forEach(function (b) {
349
- this._invokeBehavior(b, name, args);
350
- }, this);
369
+ for (var i = 0; i < this.behaviors.length; i++) {
370
+ this._invokeBehavior(this.behaviors[i], name, args);
371
+ }
351
372
  this._invokeBehavior(this, name, args);
352
373
  },
353
374
  _invokeBehavior: function (b, name, args) {
@@ -357,12 +378,24 @@ fn.apply(this, args || Polymer.nar);
357
378
  }
358
379
  },
359
380
  _marshalBehaviors: function () {
360
- this.behaviors.forEach(function (b) {
361
- this._marshalBehavior(b);
362
- }, this);
381
+ for (var i = 0; i < this.behaviors.length; i++) {
382
+ this._marshalBehavior(this.behaviors[i]);
383
+ }
363
384
  this._marshalBehavior(this);
364
385
  }
365
386
  });
387
+ Polymer.Base._behaviorProperties = {
388
+ hostAttributes: true,
389
+ registered: true,
390
+ properties: true,
391
+ observers: true,
392
+ listeners: true,
393
+ created: true,
394
+ attached: true,
395
+ detached: true,
396
+ attributeChanged: true,
397
+ ready: true
398
+ };
366
399
  Polymer.Base._addFeature({
367
400
  _getExtendedPrototype: function (tag) {
368
401
  return this._getExtendedNativePrototype(tag);
@@ -414,9 +447,13 @@ properties: {},
414
447
  getPropertyInfo: function (property) {
415
448
  var info = this._getPropertyInfo(property, this.properties);
416
449
  if (!info) {
417
- this.behaviors.some(function (b) {
418
- return info = this._getPropertyInfo(property, b.properties);
419
- }, this);
450
+ for (var i = 0; i < this.behaviors.length; i++) {
451
+ info = this._getPropertyInfo(property, this.behaviors[i].properties);
452
+ if (info) {
453
+ return info;
454
+ }
455
+ }
456
+ ;
420
457
  }
421
458
  return info || Polymer.nob;
422
459
  },
@@ -429,6 +466,40 @@ if (p) {
429
466
  p.defined = true;
430
467
  }
431
468
  return p;
469
+ },
470
+ _prepPropertyInfo: function () {
471
+ this._propertyInfo = {};
472
+ for (var i = 0, p; i < this.behaviors.length; i++) {
473
+ this._addPropertyInfo(this._propertyInfo, this.behaviors[i].properties);
474
+ }
475
+ this._addPropertyInfo(this._propertyInfo, this.properties);
476
+ this._addPropertyInfo(this._propertyInfo, this._propertyEffects);
477
+ },
478
+ _addPropertyInfo: function (target, source) {
479
+ if (source) {
480
+ var t, s;
481
+ for (var i in source) {
482
+ t = target[i];
483
+ s = source[i];
484
+ if (i[0] === '_' && !s.readOnly) {
485
+ continue;
486
+ }
487
+ if (!target[i]) {
488
+ target[i] = {
489
+ type: typeof s === 'function' ? s : s.type,
490
+ readOnly: s.readOnly,
491
+ attribute: Polymer.CaseMap.camelToDashCase(i)
492
+ };
493
+ } else {
494
+ if (!t.type) {
495
+ t.type = s.type;
496
+ }
497
+ if (!t.readOnly) {
498
+ t.readOnly = s.readOnly;
499
+ }
500
+ }
501
+ }
502
+ }
432
503
  }
433
504
  });
434
505
  Polymer.CaseMap = {
@@ -456,21 +527,24 @@ return g[0] + '-' + g[1].toLowerCase();
456
527
  }
457
528
  };
458
529
  Polymer.Base._addFeature({
459
- _prepAttributes: function () {
460
- this._aggregatedAttributes = {};
461
- },
462
530
  _addHostAttributes: function (attributes) {
531
+ if (!this._aggregatedAttributes) {
532
+ this._aggregatedAttributes = {};
533
+ }
463
534
  if (attributes) {
464
535
  this.mixin(this._aggregatedAttributes, attributes);
465
536
  }
466
537
  },
467
538
  _marshalHostAttributes: function () {
539
+ if (this._aggregatedAttributes) {
468
540
  this._applyAttributes(this, this._aggregatedAttributes);
541
+ }
469
542
  },
470
543
  _applyAttributes: function (node, attr$) {
471
544
  for (var n in attr$) {
472
545
  if (!this.hasAttribute(n) && n !== 'class') {
473
- this.serializeValueToAttribute(attr$[n], n, this);
546
+ var v = attr$[n];
547
+ this.serializeValueToAttribute(v, n, this);
474
548
  }
475
549
  }
476
550
  },
@@ -478,29 +552,40 @@ _marshalAttributes: function () {
478
552
  this._takeAttributesToModel(this);
479
553
  },
480
554
  _takeAttributesToModel: function (model) {
481
- for (var i = 0, l = this.attributes.length; i < l; i++) {
482
- this._setAttributeToProperty(model, this.attributes[i].name);
555
+ if (this.hasAttributes()) {
556
+ for (var i in this._propertyInfo) {
557
+ var info = this._propertyInfo[i];
558
+ if (this.hasAttribute(info.attribute)) {
559
+ this._setAttributeToProperty(model, info.attribute, i, info);
560
+ }
561
+ }
483
562
  }
484
563
  },
485
- _setAttributeToProperty: function (model, attrName) {
564
+ _setAttributeToProperty: function (model, attribute, property, info) {
486
565
  if (!this._serializing) {
487
- var propName = Polymer.CaseMap.dashToCamelCase(attrName);
488
- var info = this.getPropertyInfo(propName);
489
- if (info.defined || this._propertyEffects && this._propertyEffects[propName]) {
490
- var val = this.getAttribute(attrName);
491
- model[propName] = this.deserialize(val, info.type);
566
+ var property = property || Polymer.CaseMap.dashToCamelCase(attribute);
567
+ info = info || this._propertyInfo && this._propertyInfo[property];
568
+ if (info && !info.readOnly) {
569
+ var v = this.getAttribute(attribute);
570
+ model[property] = this.deserialize(v, info.type);
492
571
  }
493
572
  }
494
573
  },
495
574
  _serializing: false,
496
- reflectPropertyToAttribute: function (name) {
575
+ reflectPropertyToAttribute: function (property, attribute, value) {
497
576
  this._serializing = true;
498
- this.serializeValueToAttribute(this[name], Polymer.CaseMap.camelToDashCase(name));
577
+ value = value === undefined ? this[property] : value;
578
+ this.serializeValueToAttribute(value, attribute || Polymer.CaseMap.camelToDashCase(property));
499
579
  this._serializing = false;
500
580
  },
501
581
  serializeValueToAttribute: function (value, attribute, node) {
502
582
  var str = this.serialize(value);
503
- (node || this)[str === undefined ? 'removeAttribute' : 'setAttribute'](attribute, str);
583
+ node = node || this;
584
+ if (str === undefined) {
585
+ node.removeAttribute(attribute);
586
+ } else {
587
+ node.setAttribute(attribute, str);
588
+ }
504
589
  },
505
590
  deserialize: function (value, type) {
506
591
  switch (type) {
@@ -576,13 +661,13 @@ debouncer.stop();
576
661
  }
577
662
  }
578
663
  });
579
- Polymer.version = '1.2.1';
664
+ Polymer.version = '1.2.2';
580
665
  Polymer.Base._addFeature({
581
666
  _registerFeatures: function () {
582
667
  this._prepIs();
583
- this._prepAttributes();
584
668
  this._prepBehaviors();
585
669
  this._prepConstructor();
670
+ this._prepPropertyInfo();
586
671
  },
587
672
  _prepBehavior: function (b) {
588
673
  this._addHostAttributes(b.hostAttributes);
@@ -10,7 +10,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
10
10
 
11
11
  <script>Polymer.Base._addFeature({
12
12
  _prepTemplate: function () {
13
- this._template = this._template || Polymer.DomModule.import(this.is, 'template');
13
+ if (this._template === undefined) {
14
+ this._template = Polymer.DomModule.import(this.is, 'template');
15
+ }
14
16
  if (this._template && this._template.hasAttribute('is')) {
15
17
  this._warn(this._logf('_prepTemplate', 'top-level Polymer template ' + 'must not be a type-extension, found', this._template, 'Move inside simple <template>.'));
16
18
  }
@@ -35,20 +37,19 @@ Polymer.Base._addFeature({
35
37
  _hostStack: [],
36
38
  ready: function () {
37
39
  },
38
- _pushHost: function (host) {
40
+ _registerHost: function (host) {
39
41
  this.dataHost = host = host || Polymer.Base._hostStack[Polymer.Base._hostStack.length - 1];
40
42
  if (host && host._clients) {
41
43
  host._clients.push(this);
42
44
  }
43
- this._beginHost();
44
45
  },
45
- _beginHost: function () {
46
+ _beginHosting: function () {
46
47
  Polymer.Base._hostStack.push(this);
47
48
  if (!this._clients) {
48
49
  this._clients = [];
49
50
  }
50
51
  },
51
- _popHost: function () {
52
+ _endHosting: function () {
52
53
  Polymer.Base._hostStack.pop();
53
54
  },
54
55
  _tryReady: function () {
@@ -61,20 +62,24 @@ return !this.dataHost || this.dataHost._clientsReadied;
61
62
  },
62
63
  _ready: function () {
63
64
  this._beforeClientsReady();
65
+ if (this._template) {
64
66
  this._setupRoot();
65
67
  this._readyClients();
68
+ }
69
+ this._clientsReadied = true;
70
+ this._clients = null;
66
71
  this._afterClientsReady();
67
72
  this._readySelf();
68
73
  },
69
74
  _readyClients: function () {
70
75
  this._beginDistribute();
71
76
  var c$ = this._clients;
77
+ if (c$) {
72
78
  for (var i = 0, l = c$.length, c; i < l && (c = c$[i]); i++) {
73
79
  c._ready();
74
80
  }
81
+ }
75
82
  this._finishDistribute();
76
- this._clientsReadied = true;
77
- this._clients = null;
78
83
  },
79
84
  _readySelf: function () {
80
85
  this._doBehavior('ready');
@@ -377,20 +382,16 @@ var nativeRemoveChild = Element.prototype.removeChild;
377
382
  var nativeAppendChild = Element.prototype.appendChild;
378
383
  var nativeCloneNode = Element.prototype.cloneNode;
379
384
  var nativeImportNode = Document.prototype.importNode;
380
- var DomApi = function (node) {
381
- this.node = node;
382
- if (this.patch) {
383
- this.patch();
384
- }
385
+ var needsToWrap = Settings.hasShadow && !Settings.nativeShadow;
386
+ var wrap = window.wrap ? window.wrap : function (node) {
387
+ return node;
385
388
  };
386
- if (window.wrap && Settings.useShadow && !Settings.useNativeShadow) {
387
- DomApi = function (node) {
388
- this.node = wrap(node);
389
+ var DomApi = function (node) {
390
+ this.node = needsToWrap ? wrap(node) : node;
389
391
  if (this.patch) {
390
392
  this.patch();
391
393
  }
392
394
  };
393
- }
394
395
  DomApi.prototype = {
395
396
  flush: function () {
396
397
  Polymer.dom.flush();
@@ -625,7 +626,7 @@ _addLogicalInfo: function (node, container, index) {
625
626
  var children = factory(container).childNodes;
626
627
  index = index === undefined ? children.length : index;
627
628
  if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
628
- var c$ = Array.prototype.slice.call(node.childNodes);
629
+ var c$ = arrayCopyChildNodes(node);
629
630
  for (var i = 0, n; i < c$.length && (n = c$[i]); i++) {
630
631
  children.splice(index++, 0, n);
631
632
  n._lightParent = container;
@@ -787,7 +788,7 @@ Object.defineProperties(DomApi.prototype, {
787
788
  childNodes: {
788
789
  get: function () {
789
790
  var c$ = getLightChildren(this.node);
790
- return Array.isArray(c$) ? c$ : Array.prototype.slice.call(c$);
791
+ return Array.isArray(c$) ? c$ : arrayCopyChildNodes(this.node);
791
792
  },
792
793
  configurable: true
793
794
  },
@@ -910,7 +911,7 @@ if (nt !== Node.TEXT_NODE || nt !== Node.COMMENT_NODE) {
910
911
  this._clear();
911
912
  var d = document.createElement('div');
912
913
  d.innerHTML = text;
913
- var c$ = Array.prototype.slice.call(d.childNodes);
914
+ var c$ = arrayCopyChildNodes(d);
914
915
  for (var i = 0; i < c$.length; i++) {
915
916
  this.appendChild(c$[i]);
916
917
  }
@@ -923,20 +924,25 @@ DomApi.prototype._getComposedInnerHTML = function () {
923
924
  return getInnerHTML(this.node, true);
924
925
  };
925
926
  } else {
926
- var forwardMethods = [
927
+ var forwardMethods = function (m$) {
928
+ for (var i = 0; i < m$.length; i++) {
929
+ forwardMethod(m$[i]);
930
+ }
931
+ };
932
+ var forwardMethod = function (method) {
933
+ DomApi.prototype[method] = function () {
934
+ return this.node[method].apply(this.node, arguments);
935
+ };
936
+ };
937
+ forwardMethods([
927
938
  'cloneNode',
928
939
  'appendChild',
929
940
  'insertBefore',
930
941
  'removeChild',
931
942
  'replaceChild'
932
- ];
933
- forwardMethods.forEach(function (name) {
934
- DomApi.prototype[name] = function () {
935
- return this.node[name].apply(this.node, arguments);
936
- };
937
- });
943
+ ]);
938
944
  DomApi.prototype.querySelectorAll = function (selector) {
939
- return Array.prototype.slice.call(this.node.querySelectorAll(selector));
945
+ return arrayCopy(this.node.querySelectorAll(selector));
940
946
  };
941
947
  DomApi.prototype.getOwnerRoot = function () {
942
948
  var n = this.node;
@@ -953,35 +959,24 @@ return doc.importNode(externalNode, deep);
953
959
  };
954
960
  DomApi.prototype.getDestinationInsertionPoints = function () {
955
961
  var n$ = this.node.getDestinationInsertionPoints && this.node.getDestinationInsertionPoints();
956
- return n$ ? Array.prototype.slice.call(n$) : [];
962
+ return n$ ? arrayCopy(n$) : [];
957
963
  };
958
964
  DomApi.prototype.getDistributedNodes = function () {
959
965
  var n$ = this.node.getDistributedNodes && this.node.getDistributedNodes();
960
- return n$ ? Array.prototype.slice.call(n$) : [];
966
+ return n$ ? arrayCopy(n$) : [];
961
967
  };
962
968
  DomApi.prototype._distributeParent = function () {
963
969
  };
964
- var nativeForwards = [
965
- 'appendChild',
966
- 'insertBefore',
967
- 'removeChild',
968
- 'replaceChild'
969
- ];
970
- nativeForwards.forEach(function (forward) {
971
- DomApi.prototype[forward] = function () {
972
- return this.node[forward].apply(this.node, arguments);
973
- };
974
- });
975
970
  Object.defineProperties(DomApi.prototype, {
976
971
  childNodes: {
977
972
  get: function () {
978
- return Array.prototype.slice.call(this.node.childNodes);
973
+ return arrayCopyChildNodes(this.node);
979
974
  },
980
975
  configurable: true
981
976
  },
982
977
  children: {
983
978
  get: function () {
984
- return Array.prototype.slice.call(this.node.children);
979
+ return arrayCopyChildren(this.node);
985
980
  },
986
981
  configurable: true
987
982
  },
@@ -1004,7 +999,20 @@ return this.node.innerHTML = value;
1004
999
  configurable: true
1005
1000
  }
1006
1001
  });
1007
- var forwardProperties = [
1002
+ var forwardProperties = function (f$) {
1003
+ for (var i = 0; i < f$.length; i++) {
1004
+ forwardProperty(f$[i]);
1005
+ }
1006
+ };
1007
+ var forwardProperty = function (name) {
1008
+ Object.defineProperty(DomApi.prototype, name, {
1009
+ get: function () {
1010
+ return this.node[name];
1011
+ },
1012
+ configurable: true
1013
+ });
1014
+ };
1015
+ forwardProperties([
1008
1016
  'parentNode',
1009
1017
  'firstChild',
1010
1018
  'lastChild',
@@ -1014,15 +1022,7 @@ var forwardProperties = [
1014
1022
  'lastElementChild',
1015
1023
  'nextElementSibling',
1016
1024
  'previousElementSibling'
1017
- ];
1018
- forwardProperties.forEach(function (name) {
1019
- Object.defineProperty(DomApi.prototype, name, {
1020
- get: function () {
1021
- return this.node[name];
1022
- },
1023
- configurable: true
1024
- });
1025
- });
1025
+ ]);
1026
1026
  }
1027
1027
  var CONTENT = 'content';
1028
1028
  function factory(node, patch) {
@@ -1036,6 +1036,7 @@ return node.__domApi;
1036
1036
  function hasDomApi(node) {
1037
1037
  return Boolean(node.__domApi);
1038
1038
  }
1039
+ ;
1039
1040
  Polymer.dom = function (obj, patch) {
1040
1041
  if (obj instanceof Event) {
1041
1042
  return Polymer.EventApi.factory(obj);
@@ -1049,7 +1050,7 @@ return children ? children : node.childNodes;
1049
1050
  }
1050
1051
  function getComposedChildren(node) {
1051
1052
  if (!node._composedChildren) {
1052
- node._composedChildren = Array.prototype.slice.call(node.childNodes);
1053
+ node._composedChildren = arrayCopyChildNodes(node);
1053
1054
  }
1054
1055
  return node._composedChildren;
1055
1056
  }
@@ -1085,13 +1086,35 @@ children.splice(i, 1);
1085
1086
  }
1086
1087
  function saveLightChildrenIfNeeded(node) {
1087
1088
  if (!node._lightChildren) {
1088
- var c$ = Array.prototype.slice.call(node.childNodes);
1089
+ var c$ = arrayCopyChildNodes(node);
1089
1090
  for (var i = 0, l = c$.length, child; i < l && (child = c$[i]); i++) {
1090
1091
  child._lightParent = child._lightParent || node;
1091
1092
  }
1092
1093
  node._lightChildren = c$;
1093
1094
  }
1094
1095
  }
1096
+ function arrayCopyChildNodes(parent) {
1097
+ var copy = [], i = 0;
1098
+ for (var n = parent.firstChild; n; n = n.nextSibling) {
1099
+ copy[i++] = n;
1100
+ }
1101
+ return copy;
1102
+ }
1103
+ function arrayCopyChildren(parent) {
1104
+ var copy = [], i = 0;
1105
+ for (var n = parent.firstElementChild; n; n = n.nextElementSibling) {
1106
+ copy[i++] = n;
1107
+ }
1108
+ return copy;
1109
+ }
1110
+ function arrayCopy(a$) {
1111
+ var l = a$.length;
1112
+ var copy = new Array(l);
1113
+ for (var i = 0; i < l; i++) {
1114
+ copy[i] = a$[i];
1115
+ }
1116
+ return copy;
1117
+ }
1095
1118
  function hasInsertionPoint(root) {
1096
1119
  return Boolean(root && root._insertionPoints.length);
1097
1120
  }
@@ -1107,7 +1130,11 @@ matchesSelector: matchesSelector,
1107
1130
  hasInsertionPoint: hasInsertionPoint,
1108
1131
  ctor: DomApi,
1109
1132
  factory: factory,
1110
- hasDomApi: hasDomApi
1133
+ hasDomApi: hasDomApi,
1134
+ arrayCopy: arrayCopy,
1135
+ arrayCopyChildNodes: arrayCopyChildNodes,
1136
+ arrayCopyChildren: arrayCopyChildren,
1137
+ wrap: wrap
1111
1138
  };
1112
1139
  }();
1113
1140
  Polymer.Base.extend(Polymer.dom, {
@@ -1328,7 +1355,10 @@ n.__observeNodesMap.set(this, this._observeContent(n));
1328
1355
  }
1329
1356
  },
1330
1357
  _observeContent: function (content) {
1331
- var h = Polymer.dom(content).observeNodes(this._scheduleNotify.bind(this));
1358
+ var self = this;
1359
+ var h = Polymer.dom(content).observeNodes(function () {
1360
+ self._scheduleNotify();
1361
+ });
1332
1362
  h._avoidChangeCalculation = true;
1333
1363
  return h;
1334
1364
  },
@@ -1405,7 +1435,9 @@ self._scheduleNotify();
1405
1435
  }
1406
1436
  };
1407
1437
  this._observer = new MutationObserver(this._mutationHandler);
1408
- this._boundFlush = this._flush.bind(this);
1438
+ this._boundFlush = function () {
1439
+ self._flush();
1440
+ };
1409
1441
  Polymer.dom.addStaticFlush(this._boundFlush);
1410
1442
  this._observer.observe(this.node, { childList: true });
1411
1443
  }
@@ -1474,7 +1506,10 @@ if (!this._observer) {
1474
1506
  var root = this.domApi.getOwnerRoot();
1475
1507
  var host = root && root.host;
1476
1508
  if (host) {
1477
- this._observer = Polymer.dom(host).observeNodes(this._scheduleNotify.bind(this));
1509
+ var self = this;
1510
+ this._observer = Polymer.dom(host).observeNodes(function () {
1511
+ self._scheduleNotify();
1512
+ });
1478
1513
  this._observer._isContentListener = true;
1479
1514
  if (this._hasAttrSelect()) {
1480
1515
  Polymer.dom(host).observer.enableShadowAttributeTracking();
@@ -1519,6 +1554,7 @@ upgradeLightChildren(this._lightChildren);
1519
1554
  _createLocalRoot: function () {
1520
1555
  this.shadyRoot = this.root;
1521
1556
  this.shadyRoot._distributionClean = false;
1557
+ this.shadyRoot._hasDistributed = false;
1522
1558
  this.shadyRoot._isShadyRoot = true;
1523
1559
  this.shadyRoot._dirtyRoots = [];
1524
1560
  var i$ = this.shadyRoot._insertionPoints = !this._notes || this._notes._hasContent ? this.shadyRoot.querySelectorAll('content') : [];
@@ -1845,20 +1881,23 @@ Polymer.DomModule = document.createElement('dom-module');
1845
1881
  Polymer.Base._addFeature({
1846
1882
  _registerFeatures: function () {
1847
1883
  this._prepIs();
1848
- this._prepAttributes();
1849
1884
  this._prepBehaviors();
1850
1885
  this._prepConstructor();
1851
1886
  this._prepTemplate();
1852
1887
  this._prepShady();
1888
+ this._prepPropertyInfo();
1853
1889
  },
1854
1890
  _prepBehavior: function (b) {
1855
1891
  this._addHostAttributes(b.hostAttributes);
1856
1892
  },
1857
1893
  _initFeatures: function () {
1894
+ this._registerHost();
1895
+ if (this._template) {
1858
1896
  this._poolContent();
1859
- this._pushHost();
1897
+ this._beginHosting();
1860
1898
  this._stampTemplate();
1861
- this._popHost();
1899
+ this._endHosting();
1900
+ }
1862
1901
  this._marshalHostAttributes();
1863
1902
  this._setupDebouncers();
1864
1903
  this._marshalBehaviors();