Skip to content

Commit

Permalink
Avoid stomping on property objects when mixing behaviors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Orvell committed Nov 7, 2015
1 parent dc2255c commit ec4d313
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions polymer.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
this._prepEffects();
// shared behaviors
this._prepBehaviors();
// fast access to property info
this._prepPropertyInfo();
// accessors part 2
this._prepBindings();
// dom encapsulation
this._prepShady();
// fast access to property info
this._prepPropertyInfo();
},

_prepBehavior: function(b) {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/bind/accessors.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@
// ReadOnly properties have a private setter only
// TODO(kschaaf): Per current Bind factoring, we shouldn't
// be interrogating the prototype here
// TODO(sorvell): we want to avoid using `getPropertyInfo` here, but
// this requires more data in `_propertyInfo`
var info = model.getPropertyInfo && model.getPropertyInfo(property);
if (info && info.readOnly) {
// Computed properties are read-only (no property setter), but also don't
Expand Down
2 changes: 1 addition & 1 deletion src/lib/template/templatizer.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@
archetype._prepEffects();
this._customPrepEffects(archetype);
archetype._prepBehaviors();
archetype._prepBindings();
archetype._prepPropertyInfo();
archetype._prepBindings();

// boilerplate code
archetype._notifyPathUp = this._notifyPathUpImpl;
Expand Down
16 changes: 8 additions & 8 deletions src/micro/properties.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@
* @param {string} property Name of property to introspect.
* @return {Object} Property descriptor for specified property.
*/
// TODO(sorvell): This function returns the first property object found
// and this is not the property info Polymer acts on for readOnly or type
// This api should be combined with _propertyInfo.
getPropertyInfo: function(property) {
var info = this._getPropertyInfo(property, this.properties);
if (!info) {
Expand Down Expand Up @@ -156,21 +159,18 @@
continue;
}
if (!target[i]) {
target[i] = t = typeof(s) === 'function' ? {type: s} : s;
t.attribute = Polymer.CaseMap.camelToDashCase(i);
target[i] = {
type: typeof(s) === 'function' ? s : s.type,
readOnly: s.readOnly,
attribute: Polymer.CaseMap.camelToDashCase(i)
}
} else {
if (!t.type) {
t.type = s.type;
}
if (!t.readOnly) {
t.readOnly = s.readOnly;
}
if (!t.notify) {
t.notify = s.notify;
}
if (!t.readOnly) {
t.readOnly = s.readOnly;
}
}
}
}
Expand Down

0 comments on commit ec4d313

Please sign in to comment.