From ed1454d6289ad441b5dc416e53d4c5303508fe8f Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Thu, 30 Nov 2017 15:25:50 -0800 Subject: [PATCH] Minor updates based on review. --- closure.log | 88 ------------------- lib/mixins/properties-mixin.html | 38 ++++---- lib/mixins/property-effects.html | 5 +- ...perties-mixin-with-property-accessors.html | 12 +-- test/unit/polymer.properties-mixin.html | 8 +- 5 files changed, 30 insertions(+), 121 deletions(-) delete mode 100644 closure.log diff --git a/closure.log b/closure.log deleted file mode 100644 index e465a0cdc6..0000000000 --- a/closure.log +++ /dev/null @@ -1,88 +0,0 @@ -gulp-google-closure-compiler: externs/closure-types.js:28: WARNING - property _generatePropertyAccessor on interface Polymer_PropertiesChanged is not implemented by type PropertiesChanged -Polymer_PropertiesChanged.prototype._generatePropertyAccessor = function(property, readOnly){}; -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -externs/closure-types.js:124: WARNING - property _propertyForAttribute on interface Polymer_PropertiesChanged is not implemented by type PropertiesChanged -Polymer_PropertiesChanged.prototype._propertyForAttribute = function(attribute){}; -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -externs/closure-types.js:129: WARNING - property _attributeForProperty on interface Polymer_PropertiesChanged is not implemented by type PropertiesChanged -Polymer_PropertiesChanged.prototype._attributeForProperty = function(property){}; -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -externs/closure-types.js:133: WARNING - property _typeForProperty on interface Polymer_PropertiesChanged is not implemented by type PropertiesChanged -Polymer_PropertiesChanged.prototype._typeForProperty = function(name){}; -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -externs/closure-types.js:144: WARNING - property __dataCounter on interface Polymer_PropertyAccessors is not implemented by type PropertyAccessors -Polymer_PropertyAccessors.prototype.__dataCounter; -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -externs/closure-types.js:941: WARNING - property disconnectedCallback not defined on any supertype of Polymer_LegacyElementMixin -Polymer_LegacyElementMixin.prototype.disconnectedCallback = function(){}; -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -polymer.html_script_10.js:6: WARNING - Type annotation references non-existent type AsyncInterface. - /** @const {!AsyncInterface} */ - ^^^^^^^^^^^^^^ - -polymer.html_script_11.js:262: WARNING - Property _definePropertyAccessor never defined on base.prototype of type base.prototype - super._definePropertyAccessor(property, readOnly); - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -polymer.html_script_13.js:1134: WARNING - Found two declarations for property __dataCounter on type PropertyEffects. - - this.__dataCounter; - ^^^^^^^^^^^^^^^^^^ - -polymer.html_script_14.js:56: WARNING - Type annotation references non-existent type PropertiesClassConstructor. - * @param {PropertiesClassConstructor} constructor PropertiesClass constructor - ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -polymer.html_script_14.js:57: WARNING - Type annotation references non-existent type PropertiesClassConstructor. - * @return {PropertiesClassConstructor} Super class constructor - ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -polymer.html_script_14.js:60: WARNING - Type annotation references non-existent type PropertiesClassConstructor. - const proto = /** @type {PropertiesClassConstructor} */ (constructor).prototype; - ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -polymer.html_script_14.js:72: WARNING - Type annotation references non-existent type PropertiesClassConstructor. - * @param {PropertiesClassConstructor} constructor PropertiesClass constructor - ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -polymer.html_script_14.js:98: WARNING - Property _properties never defined on this of type PropertiesClass - const props = this._properties; - ^^^^^^^^^^^^^^^^ - -polymer.html_script_14.js:100: WARNING - Property attributeNameForProperty never defined on $jscomp$this of type PropertiesClass - return this.attributeNameForProperty(p); - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -polymer.html_script_15.js:212: WARNING - Invalid type(s) for operator IN. -Expected : Object -Found : (PolymerElement|null) - - if (!info.readOnly && !(name in proto)) { - ^^^^^ - -polymer.html_script_15.js:226: WARNING - Property _finalizeClass never defined on polymerElementBase of type polymerElementBase<|function(new:polymerElementBase): ?|> - super._finalizeClass(); - ^^^^^^^^^^^^^^^^^^^^ - -polymer.html_script_15.js:463: WARNING - Property connectedCallback never defined on polymerElementBase.prototype of type polymerElementBase.prototype - super.connectedCallback(); - ^^^^^^^^^^^^^^^^^^^^^^^ - -polymer.html_script_15.js:474: WARNING - The right side in the assignment is not a subtype of the left side. -Expected : IObject -Found : IObject - - this.$ = this.root.$; - ^^^^^^^^^^^^^^^^^^^^ - -polymer.html_script_9.js:57: WARNING - Type annotation references non-existent type AsyncInterface. - * @return {AsyncInterface} An async timeout interface - ^^^^^^^^^^^^^^ - -0 error(s), 20 warning(s), 76.6% typed diff --git a/lib/mixins/properties-mixin.html b/lib/mixins/properties-mixin.html index b02b4ef938..f8e2201496 100644 --- a/lib/mixins/properties-mixin.html +++ b/lib/mixins/properties-mixin.html @@ -17,14 +17,15 @@ 'use strict'; /** - * Mixin that provides minimal starting point to using the PropertiesChanged + * Mixin that provides a minimal starting point to using the PropertiesChanged * mixin by providing a mechanism to declare properties in a static * getter (e.g. static get properties() { return { foo: String } }). Changes * are reported via the `_propertiesChanged` method. * * This mixin provides no specific support for rendering. Users are expected - * to create a shadowRoot and put content into it and update it in whatever - * way makes sense for the use case. + * to create a ShadowRoot and put content into it and update it in whatever + * way makes sense. This can be done in reaction to properties changing by + * implementing `_propertiesChanged`. * * @mixinFunction * @polymer @@ -54,11 +55,8 @@ function normalizeProperties(props) { const output = {}; for (let p in props) { - let o = props[p]; - if (typeof o == 'function') { - o = { type: o }; - } - output[p] = o; + const o = props[p]; + output[p] = (typeof o === 'function') ? {type: o} : o; } return output; } @@ -70,9 +68,8 @@ * @param {PropertiesMixinConstructor} constructor PropertiesMixin constructor * @return {PropertiesMixinConstructor} Super class constructor */ - function superForClass(constructor) { - const proto = /** @type {PropertiesMixinConstructor} */ (constructor).prototype; - const superCtor = Object.getPrototypeOf(proto).constructor; + function superPropertiesClass(constructor) { + const superCtor = Object.getPrototypeOf(constructor); if (superCtor.prototype instanceof PropertiesMixin) { return superCtor; } @@ -110,9 +107,7 @@ */ static get observedAttributes() { const props = this._properties; - return props ? Object.keys(props).map(p => { - return this.attributeNameForProperty(p); - }) : []; + return props ? Object.keys(props).map(p => this.attributeNameForProperty(p)) : []; } /** @@ -123,7 +118,7 @@ */ static finalize() { if (!this.hasOwnProperty(JSCompiler_renameProperty('__finalized', this))) { - const superCtor = superForClass(this); + const superCtor = superPropertiesClass(this); if (superCtor) { superCtor.finalize(); } @@ -149,7 +144,7 @@ /** * Returns a memoized version of all properties, including those inherited * from super classes. Properties not in object format are converted to - * at lesat {type}. + * at least {type}. * * @return {Object} Object containing properties for this class * @protected @@ -157,15 +152,16 @@ static get _properties() { if (!this.hasOwnProperty( JSCompiler_renameProperty('__properties', this))) { - const superCtor = superForClass(this); + const superCtor = superPropertiesClass(this); this.__properties = Object.assign({}, - superCtor && superCtor._properties, ownProperties(this)); + superCtor && superCtor._properties, + ownProperties(this)); } return this.__properties; } /** - * Overrides PropertiesChanged method to return type specified in the + * Overrides `PropertiesChanged` method to return type specified in the * static `properties` object for the given property. * @param {string} name Name of property * @return {*} Type to which to deserialize attribute @@ -178,8 +174,8 @@ } /** - * Overrides default behavior and adds a call to `finalize` which lazily - * configures the element's property accessors. + * Overrides `PropertiesChanged` method and adds a call to + * `finalize` which lazily configures the element's property accessors. * @override */ _initializeProperties() { diff --git a/lib/mixins/property-effects.html b/lib/mixins/property-effects.html index 324674c281..27ad6b933c 100644 --- a/lib/mixins/property-effects.html +++ b/lib/mixins/property-effects.html @@ -1113,6 +1113,9 @@ constructor() { super(); /** @type {number} */ + // NOTE: used to track re-entrant calls to `_flushProperties` + // path changes dirty check against `__dataTemp` only during one "turn" + // and are cleared when `__dataCounter` returns to 0. this.__dataCounter = 0; /** @type {boolean} */ this.__dataClientsReady; @@ -1150,8 +1153,6 @@ this.__observeEffects; /** @type {Object} */ this.__readOnly; - /** @type {number} */ - this.__dataCounter; /** @type {!TemplateInfo} */ this.__templateInfo; } diff --git a/test/unit/polymer.properties-mixin-with-property-accessors.html b/test/unit/polymer.properties-mixin-with-property-accessors.html index c011c64586..5bfc623dc8 100644 --- a/test/unit/polymer.properties-mixin-with-property-accessors.html +++ b/test/unit/polymer.properties-mixin-with-property-accessors.html @@ -202,7 +202,7 @@