Skip to content

Commit

Permalink
Add flattened properties to dom-bind, templatizer, optimize by 'limin…
Browse files Browse the repository at this point in the history
…g properties that are protected/private and not readOnly from list.
  • Loading branch information
Steven Orvell committed Oct 20, 2015
1 parent acdd242 commit 2ba08ec
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/lib/template/dom-bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/template/templatizer.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
this._customPrepEffects(archetype);
archetype._prepBehaviors();
archetype._prepBindings();
archetype._prepPropertyInfo();

// boilerplate code
archetype._notifyPathUp = this._notifyPathUpImpl;
Expand Down
8 changes: 2 additions & 6 deletions src/micro/attributes.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
},
Expand Down
6 changes: 6 additions & 0 deletions src/micro/properties.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions src/standard/configure.html
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
Expand Down

0 comments on commit 2ba08ec

Please sign in to comment.