Skip to content

Commit

Permalink
PropertyAccessors
Browse files Browse the repository at this point in the history
Update based on `PropertiesChanged` changes
  • Loading branch information
Steven Orvell committed Nov 10, 2017
1 parent 05cb5d2 commit 5846d58
Showing 1 changed file with 7 additions and 35 deletions.
42 changes: 7 additions & 35 deletions lib/mixins/property-accessors.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
constructor() {
super();
/** @type {number} */
this.__dataCounter;
this.__dataCounter = 0;
}

/**
Expand Down Expand Up @@ -163,8 +163,6 @@
* @protected
*/
_initializeProperties() {
this.__serializing = false;
this.__dataCounter = 0;
if (this.__dataProto) {
this._initializeProtoProperties(this.__dataProto);
this.__dataProto = null;
Expand Down Expand Up @@ -222,24 +220,14 @@
}

/**
* Converts a typed JavaScript value to a string.
*
* This method is called by Polymer when setting JS property values to
* HTML attributes. Users may override this method on Polymer element
* prototypes to provide serialization for custom types.
*
* Note: The return value of `undefined` is used as a sentinel value to
* indicate the attribute should be removed.
* Overrides PropertiesChanged implemention to serialize objects as JSON.
*
* @param {*} value Property value to serialize.
* @return {string | undefined} String serialized from the provided property value.
*/
_serializeValue(value) {
/* eslint-disable no-fallthrough */
switch (typeof value) {
case 'boolean':
return value ? '' : undefined;

case 'object':
if (value instanceof Date) {
return value.toString();
Expand All @@ -252,7 +240,7 @@
}

default:
return value != null ? value.toString() : undefined;
return super._serializeValue(value);
}
}

Expand Down Expand Up @@ -357,30 +345,14 @@
}

/**
* Overrides `PropertiesChanged` implementation to only process changes
* if any are pending.
* Overrides `PropertiesChanged` implementation.
*
* @protected
*/
_flushProperties() {
if (this.__dataPending && this.__dataOld) {
this.__dataCounter++;
super._flushProperties();
this.__dataCounter--;
}
}

/**
* Overrides implementation in PropertiesChanged to call
* _flushProperties to immediately process any pending changes to
* properties.
*
* @public
*/
ready() {
super.ready();
// Run normal flush
this._flushProperties();
this.__dataCounter++;
super._flushProperties();
this.__dataCounter--;
}

}
Expand Down

0 comments on commit 5846d58

Please sign in to comment.