From 2ba08eca6825b775fda7383dfe7f7b1a478dd8d4 Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Tue, 20 Oct 2015 14:07:03 -0700 Subject: [PATCH] Add flattened properties to dom-bind, templatizer, optimize by 'liming properties that are protected/private and not readOnly from list. --- src/lib/template/dom-bind.html | 1 + src/lib/template/templatizer.html | 1 + src/micro/attributes.html | 8 ++------ src/micro/properties.html | 6 ++++++ src/standard/configure.html | 7 ++++--- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/lib/template/dom-bind.html b/src/lib/template/dom-bind.html index c0064e9ce7..caac780fa5 100644 --- a/src/lib/template/dom-bind.html +++ b/src/lib/template/dom-bind.html @@ -145,6 +145,7 @@ this._prepBehaviors(); this._prepConfigure(); this._prepBindings(); + this._prepPropertyInfo(); Polymer.Base._initFeatures.call(this); this._children = Array.prototype.slice.call(this.root.childNodes); } diff --git a/src/lib/template/templatizer.html b/src/lib/template/templatizer.html index 035e410db1..4d51457d4b 100644 --- a/src/lib/template/templatizer.html +++ b/src/lib/template/templatizer.html @@ -117,6 +117,7 @@ this._customPrepEffects(archetype); archetype._prepBehaviors(); archetype._prepBindings(); + archetype._prepPropertyInfo(); // boilerplate code archetype._notifyPathUp = this._notifyPathUpImpl; diff --git a/src/micro/attributes.html b/src/micro/attributes.html index f4ac4d8d88..5367b1ebcb 100644 --- a/src/micro/attributes.html +++ b/src/micro/attributes.html @@ -104,14 +104,10 @@ if (!this._serializing) { var property = property || Polymer.CaseMap.dashToCamelCase(attribute); // fallback to property lookup - info = info || this._propertyInfo[property]; + info = info || (this._propertyInfo && this._propertyInfo[property]); if (info && !info.readOnly) { var v = this.getAttribute(attribute); - // TODO(sorvell): maybe not kosher but under current rules, - // we can avoid deserializing null values for non-Boolean types. - if (v !== null || info.type === Boolean) { - model[property] = this.deserialize(v, info.type); - } + model[property] = this.deserialize(v, info.type); } } }, diff --git a/src/micro/properties.html b/src/micro/properties.html index 83f23b3ea4..92156c32bd 100644 --- a/src/micro/properties.html +++ b/src/micro/properties.html @@ -146,6 +146,12 @@ for (var i in source) { t = target[i]; s = source[i]; + // optimization: avoid info'ing properties that are protected and + // not read only since they are not needed for attributes or + // configuration. + if (i.indexOf('_') === 0 && !s.readOnly) { + continue; + } if (!target[i]) { target[i] = t = typeof(s) === 'function' ? {type: s} : s; t.attribute = Polymer.CaseMap.camelToDashCase(i); diff --git a/src/standard/configure.html b/src/standard/configure.html index fdf0036f87..8d493fa60e 100644 --- a/src/standard/configure.html +++ b/src/standard/configure.html @@ -125,9 +125,10 @@ //if (!this.getPropertyInfo(prop).readOnly) { // TODO(sorvell): tempatized things don't have _propertyInfo atm // so fallback to property lookup. - var info = this._propertyInfo && this._propertyInfo[prop] || - this.getPropertyInfo(prop); - if (!info.readOnly) { + // var info = this._propertyInfo && this._propertyInfo[prop] || + // this.getPropertyInfo(prop); + var info = this._propertyInfo[prop]; + if (!info || !info.readOnly) { a[prop] = b[prop]; } }