Avoid stomping on property objects when mixing behaviors.

This commit is contained in:
Steven Orvell 2015-11-06 17:52:30 -08:00
parent dc2255c8b3
commit ec4d3132cd
4 changed files with 13 additions and 11 deletions

View File

@ -42,12 +42,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
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) {

View File

@ -170,6 +170,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
// 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

View File

@ -116,8 +116,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
archetype._prepEffects();
this._customPrepEffects(archetype);
archetype._prepBehaviors();
archetype._prepBindings();
archetype._prepPropertyInfo();
archetype._prepBindings();
// boilerplate code
archetype._notifyPathUp = this._notifyPathUpImpl;

View File

@ -105,6 +105,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* @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) {
@ -156,8 +159,11 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
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;
@ -165,12 +171,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
if (!t.readOnly) {
t.readOnly = s.readOnly;
}
if (!t.notify) {
t.notify = s.notify;
}
if (!t.readOnly) {
t.readOnly = s.readOnly;
}
}
}
}