diff --git a/lib/mixins/properties-changed.html b/lib/mixins/properties-changed.html index 6269babe2f..fd6fbc9630 100644 --- a/lib/mixins/properties-changed.html +++ b/lib/mixins/properties-changed.html @@ -20,39 +20,6 @@ /** @const {!AsyncInterface} */ const microtask = Polymer.Async.microTask; - /** - * Returns the map matching attribute names to properties. This map is - * used in `propertyNameForAttribute` which locks property names and - * attribute names together using this data. - * - * @private - * @param {PropertiesChangedConstructor} constructor PropertiesChanged - * constructor - * @return {Object} Object mapping property names to attributes. - */ - function getAttributeToPropertyMap(constructor) { - return constructor.__attributeToPropertyMap; - } - - /** - * Adds to the `attributeToPropertyMap` for the given class. A key for the - * attribute discovered via `attributeNameForProperty` points to the - * given property name. This map is used in `propertyNameForAttribute`. - * - * @private - * @param {PropertiesChangedConstructor} constructor PropertiesChanged - * constructor - * @param {string} property Property name. - */ - function addToAttributeToPropertyMap(constructor, property) { - if (!constructor.hasOwnProperty(JSCompiler_renameProperty( - '__attributeToPropertyMap', constructor))) { - constructor.__attributeToPropertyMap = {}; - } - const attr = constructor.attributeNameForProperty(property); - constructor.__attributeToPropertyMap[attr] = property; - } - /** * Element class mixin that provides basic meta-programming for creating one * or more property accessors (getter/setter pair) that enqueue an async @@ -112,7 +79,7 @@ * @protected */ static propertyNameForAttribute(attribute) { - const map = getAttributeToPropertyMap(this); + const map = this.prototype.__dataAttributes; return map && map[attribute] || attribute; } @@ -157,9 +124,13 @@ if (!this.hasOwnProperty('__dataHasAccessor')) { this.__dataHasAccessor = Object.assign({}, this.__dataHasAccessor); } + if (!this.hasOwnProperty('__dataAttributes')) { + this.__dataAttributes = Object.assign({}, this.__dataAttributes); + } if (!this.__dataHasAccessor[property]) { this.__dataHasAccessor[property] = true; - addToAttributeToPropertyMap(this.constructor, property); + const attr = this.constructor.attributeNameForProperty(property); + this.__dataAttributes[attr] = property; this._definePropertyAccessor(property, readOnly); } } diff --git a/test/unit/polymer.properties-element.html b/test/unit/polymer.properties-element.html index ed89ecf0dd..2f393886a7 100644 --- a/test/unit/polymer.properties-element.html +++ b/test/unit/polymer.properties-element.html @@ -100,7 +100,8 @@ static get properties() { return { - prop2: String + prop2: String, + camelCase2: String }; } @@ -208,7 +209,7 @@ @@ -326,7 +327,9 @@ var fixtureEl = fixture('sub-element-attr'); assert.equal(fixtureEl.prop, 'attr'); assert.equal(fixtureEl.prop2, 'attr'); - assert.equal(fixtureEl._callAttributeChangedCallback, 3); + assert.equal(fixtureEl.camelCase, 'camelCase'); + assert.equal(fixtureEl.camelCase2, 'camelCase2'); + assert.equal(fixtureEl._callAttributeChangedCallback, 5); }); });