From 66df196696dffcec76e0cee4fc7f44ef888b36e3 Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Mon, 2 Nov 2015 17:26:05 -0800 Subject: [PATCH] lazily create effect objects so we can more easily abort processing. avoid forEach --- src/micro/attributes.html | 23 ++++++++++++-------- src/micro/behaviors.html | 43 ++++++++++++++++++------------------- src/micro/properties.html | 9 +++++--- src/standard/x-styling.html | 4 ++-- 4 files changed, 43 insertions(+), 36 deletions(-) diff --git a/src/micro/attributes.html b/src/micro/attributes.html index 3a5a4b1f61..73eadb16e0 100644 --- a/src/micro/attributes.html +++ b/src/micro/attributes.html @@ -60,18 +60,19 @@ 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 @@ 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 @@ // 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); + } }, /** diff --git a/src/micro/behaviors.html b/src/micro/behaviors.html index ca5ca85354..160df13579 100644 --- a/src/micro/behaviors.html +++ b/src/micro/behaviors.html @@ -79,7 +79,8 @@ _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 @@ } 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 diff --git a/src/micro/properties.html b/src/micro/properties.html index 92156c32bd..2b4633a539 100644 --- a/src/micro/properties.html +++ b/src/micro/properties.html @@ -108,9 +108,12 @@ 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; }, diff --git a/src/standard/x-styling.html b/src/standard/x-styling.html index 2975eeb99e..aeb6543f59 100644 --- a/src/standard/x-styling.html +++ b/src/standard/x-styling.html @@ -31,7 +31,7 @@ // if it has any _stylePropertyNames this._ownStylePropertyNames = this._styles ? propertyUtils.decorateStyles(this._styles) : - []; + null; }, /** @@ -40,7 +40,7 @@ * (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() {