Skip to content

Commit 2ba08ec

Browse files
author
Steven Orvell
committed
Add flattened properties to dom-bind, templatizer, optimize by 'liming properties that are protected/private and not readOnly from list.
1 parent acdd242 commit 2ba08ec

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

src/lib/template/dom-bind.html

+1
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
this._prepBehaviors();
146146
this._prepConfigure();
147147
this._prepBindings();
148+
this._prepPropertyInfo();
148149
Polymer.Base._initFeatures.call(this);
149150
this._children = Array.prototype.slice.call(this.root.childNodes);
150151
}

src/lib/template/templatizer.html

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
this._customPrepEffects(archetype);
118118
archetype._prepBehaviors();
119119
archetype._prepBindings();
120+
archetype._prepPropertyInfo();
120121

121122
// boilerplate code
122123
archetype._notifyPathUp = this._notifyPathUpImpl;

src/micro/attributes.html

+2-6
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,10 @@
104104
if (!this._serializing) {
105105
var property = property || Polymer.CaseMap.dashToCamelCase(attribute);
106106
// fallback to property lookup
107-
info = info || this._propertyInfo[property];
107+
info = info || (this._propertyInfo && this._propertyInfo[property]);
108108
if (info && !info.readOnly) {
109109
var v = this.getAttribute(attribute);
110-
// TODO(sorvell): maybe not kosher but under current rules,
111-
// we can avoid deserializing null values for non-Boolean types.
112-
if (v !== null || info.type === Boolean) {
113-
model[property] = this.deserialize(v, info.type);
114-
}
110+
model[property] = this.deserialize(v, info.type);
115111
}
116112
}
117113
},

src/micro/properties.html

+6
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@
146146
for (var i in source) {
147147
t = target[i];
148148
s = source[i];
149+
// optimization: avoid info'ing properties that are protected and
150+
// not read only since they are not needed for attributes or
151+
// configuration.
152+
if (i.indexOf('_') === 0 && !s.readOnly) {
153+
continue;
154+
}
149155
if (!target[i]) {
150156
target[i] = t = typeof(s) === 'function' ? {type: s} : s;
151157
t.attribute = Polymer.CaseMap.camelToDashCase(i);

src/standard/configure.html

+4-3
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,10 @@
125125
//if (!this.getPropertyInfo(prop).readOnly) {
126126
// TODO(sorvell): tempatized things don't have _propertyInfo atm
127127
// so fallback to property lookup.
128-
var info = this._propertyInfo && this._propertyInfo[prop] ||
129-
this.getPropertyInfo(prop);
130-
if (!info.readOnly) {
128+
// var info = this._propertyInfo && this._propertyInfo[prop] ||
129+
// this.getPropertyInfo(prop);
130+
var info = this._propertyInfo[prop];
131+
if (!info || !info.readOnly) {
131132
a[prop] = b[prop];
132133
}
133134
}

0 commit comments

Comments
 (0)