|
91 | 91 | }, |
92 | 92 |
|
93 | 93 | _takeAttributesToModel: function(model) { |
94 | | - for (var i=0, l=this.attributes.length; i<l; i++) { |
95 | | - this._setAttributeToProperty(model, this.attributes[i].name); |
| 94 | + for (var i in this._propertyInfo) { |
| 95 | + var info = this._propertyInfo[i]; |
| 96 | + if (this.hasAttribute(info.attribute)) { |
| 97 | + this._setAttributeToProperty(model, info.attribute, i, info); |
| 98 | + } |
96 | 99 | } |
97 | 100 | }, |
98 | 101 |
|
99 | | - _setAttributeToProperty: function(model, attrName) { |
| 102 | + _setAttributeToProperty: function(model, attribute, property, info) { |
100 | 103 | // Don't deserialize back to property if currently reflecting |
101 | 104 | if (!this._serializing) { |
102 | | - var propName = Polymer.CaseMap.dashToCamelCase(attrName); |
103 | | - var info = this.getPropertyInfo(propName); |
104 | | - if (info.defined || |
105 | | - (this._propertyEffects && this._propertyEffects[propName])) { |
106 | | - var val = this.getAttribute(attrName); |
107 | | - model[propName] = this.deserialize(val, info.type); |
| 105 | + var property = property || Polymer.CaseMap.dashToCamelCase(attribute); |
| 106 | + // fallback to property lookup |
| 107 | + info = info || this._propertyInfo[property]; |
| 108 | + if (info && !info.readOnly) { |
| 109 | + 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 | + } |
108 | 115 | } |
109 | 116 | } |
110 | 117 | }, |
|
0 commit comments