mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
lazily create effect objects so we can more easily abort processing.
avoid forEach
This commit is contained in:
parent
a2376b6e95
commit
66df196696
@ -60,18 +60,19 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
Polymer.Base._addFeature({
|
||||
|
||||
_prepAttributes: function() {
|
||||
this._aggregatedAttributes = {};
|
||||
},
|
||||
|
||||
_addHostAttributes: function(attributes) {
|
||||
if (!this._aggregatedAttributes) {
|
||||
this._aggregatedAttributes = {};
|
||||
}
|
||||
if (attributes) {
|
||||
this.mixin(this._aggregatedAttributes, attributes);
|
||||
}
|
||||
},
|
||||
|
||||
_marshalHostAttributes: function() {
|
||||
this._applyAttributes(this, this._aggregatedAttributes);
|
||||
if (this._aggregatedAttributes) {
|
||||
this._applyAttributes(this, this._aggregatedAttributes);
|
||||
}
|
||||
},
|
||||
|
||||
/* apply attributes to node but avoid overriding existing values */
|
||||
@ -83,8 +84,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
if (!this.hasAttribute(n) && (n !== 'class')) {
|
||||
var v = attr$[n];
|
||||
this.serializeValueToAttribute(v, n, this);
|
||||
// TODO(sorvell): this should not be in micro layer.
|
||||
// if necessary, add this value to configuration...
|
||||
if (!this._clientsReady && this._propertyInfo[n] &&
|
||||
if (!this._clientsReadied && this._propertyInfo[n] &&
|
||||
(this._config[n] === undefined)) {
|
||||
this._config[n] = v;
|
||||
}
|
||||
@ -161,9 +163,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
// this._warn(this._logf('serializeValueToAttribute',
|
||||
// 'serializing long attribute values can lead to poor performance', this));
|
||||
// }
|
||||
(node || this)
|
||||
[str === undefined ? 'removeAttribute' : 'setAttribute']
|
||||
(attribute, str);
|
||||
node = node || this;
|
||||
if (str === undefined) {
|
||||
node.removeAttribute(attribute);
|
||||
} else {
|
||||
node.setAttribute(attribute, str);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -79,7 +79,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
_flattenBehaviorsList: function(behaviors) {
|
||||
var flat = [];
|
||||
behaviors.forEach(function(b) {
|
||||
for (var i=0; i < behaviors.length; i++) {
|
||||
var b = behaviors[i];
|
||||
if (b instanceof Array) {
|
||||
flat = flat.concat(this._flattenBehaviorsList(b));
|
||||
}
|
||||
@ -89,32 +90,17 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
} else {
|
||||
this._warn(this._logf('_flattenBehaviorsList', 'behavior is null, check for missing or 404 import'));
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
return flat;
|
||||
},
|
||||
|
||||
_mixinBehavior: function(b) {
|
||||
Object.getOwnPropertyNames(b).forEach(function(n) {
|
||||
switch (n) {
|
||||
case 'hostAttributes':
|
||||
case 'registered':
|
||||
case 'properties':
|
||||
case 'observers':
|
||||
case 'listeners':
|
||||
case 'created':
|
||||
case 'attached':
|
||||
case 'detached':
|
||||
case 'attributeChanged':
|
||||
case 'configure':
|
||||
case 'ready':
|
||||
break;
|
||||
default:
|
||||
if (!this.hasOwnProperty(n)) {
|
||||
this.copyOwnProperty(n, b, this);
|
||||
}
|
||||
break;
|
||||
var n$ = Object.getOwnPropertyNames(b);
|
||||
for (var i=0, n; (i<n$.length) && (n=n$[i]); i++) {
|
||||
if (!Polymer.Base._behaviorMethods[n] && !this.hasOwnProperty(n)) {
|
||||
this.copyOwnProperty(n, b, this);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
},
|
||||
|
||||
_prepBehaviors: function() {
|
||||
@ -155,4 +141,17 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
});
|
||||
|
||||
Polymer.Base._behaviorMethods = {
|
||||
hostAttributes: true,
|
||||
registered: true,
|
||||
properties: true,
|
||||
observers: true,
|
||||
listeners: true,
|
||||
created: true,
|
||||
attached: true,
|
||||
detached: true,
|
||||
attributeChanged: true,
|
||||
ready: true
|
||||
}
|
||||
|
||||
</script>
|
||||
|
@ -108,9 +108,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
getPropertyInfo: function(property) {
|
||||
var info = this._getPropertyInfo(property, this.properties);
|
||||
if (!info) {
|
||||
this.behaviors.some(function(b) {
|
||||
return info = this._getPropertyInfo(property, b.properties);
|
||||
}, this);
|
||||
for (var i=0; i < this.behaviors.length; i++) {
|
||||
info = this._getPropertyInfo(property, this.behaviors[i].properties);
|
||||
if (info) {
|
||||
return info;
|
||||
}
|
||||
};
|
||||
}
|
||||
return info || Polymer.nob;
|
||||
},
|
||||
|
@ -31,7 +31,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
// if it has any _stylePropertyNames
|
||||
this._ownStylePropertyNames = this._styles ?
|
||||
propertyUtils.decorateStyles(this._styles) :
|
||||
[];
|
||||
null;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -40,7 +40,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
* (analogous to setting `style`) and then calling `updateStyles()`.
|
||||
*
|
||||
*/
|
||||
customStyle: {},
|
||||
customStyle: null,
|
||||
|
||||
// here we have an instance time spot to put custom property data
|
||||
_setupStyleProperties: function() {
|
||||
|
Loading…
Reference in New Issue
Block a user