Skip to content

Commit

Permalink
Reduce closure warnings in PropertyAccessors
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed May 25, 2017
1 parent c34ef0b commit 3591be8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 17 deletions.
26 changes: 18 additions & 8 deletions lib/mixins/property-accessors.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
/**
* @polymerMixinClass
* @implements {Polymer_PropertyAccessors}
* @extends HTMLElement
* @unrestricted
*/
class PropertyAccessors extends superClass {
Expand All @@ -120,6 +121,14 @@
this._initializeProperties();
}

/**
* Implements native Custom Elements `attributeChangedCallback` to
* set an attribute value to a property via `_attributeToProperty`.
*
* @param {string} name Name of attribute that changed
* @param {?string} old Old attribute value
* @param {?string} value New attribute value
*/
attributeChangedCallback(name, old, value) {
if (old !== value) {
this._attributeToProperty(name, value);
Expand Down Expand Up @@ -214,8 +223,8 @@
* a typed value.
*
* @param {string} attribute Name of attribute to deserialize.
* @param {string} value of the attribute.
* @param {*} type type to deserialize to.
* @param {?string} value of the attribute.
* @param {*=} type type to deserialize to.
*/
_attributeToProperty(attribute, value, type) {
// Don't deserialize back to property if currently reflecting
Expand Down Expand Up @@ -306,8 +315,8 @@
* Note: The return value of `undefined` is used as a sentinel value to
* indicate the attribute should be removed.
*
* @param {string} value Attribute value to deserialize.
* @param {*} type Type to deserialize the string to.
* @param {?string} value Attribute value to deserialize.
* @param {*=} type Type to deserialize the string to.
* @return {*} Typed value deserialized from the provided string.
*/
_deserializeValue(value, type) {
Expand All @@ -326,15 +335,15 @@

case Object:
try {
outValue = JSON.parse(value);
outValue = JSON.parse(/** @type string */(value));
} catch(x) {
// allow non-JSON literals like Strings and Numbers
}
break;

case Array:
try {
outValue = JSON.parse(value);
outValue = JSON.parse(/** @type string */(value));
} catch(x) {
outValue = null;
console.warn(`Polymer::Attributes: couldn't decode Array as JSON: ${value}`);
Expand Down Expand Up @@ -427,7 +436,8 @@
*/
_setPendingProperty(property, value) {
let old = this.__data[property];
if (this._shouldPropertyChange(property, value, old)) {
let changed = this._shouldPropertyChange(property, value, old)
if (changed) {
if (!this.__dataPending) {
this.__dataPending = {};
this.__dataOld = {};
Expand All @@ -438,8 +448,8 @@
}
this.__data[property] = value;
this.__dataPending[property] = value;
return true;
}
return changed;
}

/**
Expand Down
23 changes: 14 additions & 9 deletions lib/utils/boot.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
/**
* @namespace Polymer
* @summary Polymer is a lightweight library built on top of the web
* standards-based Web Components API's, and makes it easy to build your
* own custom HTML elements.
* standards-based Web Components API's, and makes it easy to build your
* own custom HTML elements.
* @param {Object} info Prototype for the custom element. It must contain
* an `is` property to specify the element name. Other properties populate
* the element prototype. The `properties`, `observers`, `hostAttributes`,
* and `listeners` properties are processed to create element features.
* an `is` property to specify the element name. Other properties populate
* the element prototype. The `properties`, `observers`, `hostAttributes`,
* and `listeners` properties are processed to create element features.
* @return {Object} Returns a custom element class for the given provided
* prototype `info` object. The name of the element if given by `info.is`.
* prototype `info` object. The name of the element if given by `info.is`.
*/
window.Polymer = function(info) {
return window.Polymer._polymerFn(info);
Expand All @@ -35,15 +35,20 @@
}

// To be plugged by legacy implementation if loaded
/* eslint-disable valid-jsdoc */
/**
* @param {Object} info Prototype for the custom element. It must contain
* an `is` property to specify the element name. Other properties populate
* the element prototype. The `properties`, `observers`, `hostAttributes`,
* and `listeners` properties are processed to create element features.
* an `is` property to specify the element name. Other properties populate
* the element prototype. The `properties`, `observers`, `hostAttributes`,
* and `listeners` properties are processed to create element features.
* @return {Object} Returns a custom element class for the given provided
* prototype `info` object. The name of the element if given by `info.is`.
*/
window.Polymer._polymerFn = function(info) { // eslint-disable-line no-unused-vars
throw new Error('Load polymer.html to use the Polymer() function.');
}
/* eslint-enable */

window.Polymer.version = '2.0.0';

/* eslint-disable no-unused-vars */
Expand Down

0 comments on commit 3591be8

Please sign in to comment.