From 1b514b4f9b13775ce1616fc3c33cab250388dc6e Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Mon, 11 Dec 2017 11:11:12 -0800 Subject: [PATCH] Minor fixes * [PropertiesChanged]: check for and call `super.attributeChangedCallback` * [PropertiesMixin]: * remove `disconnectedCallback` stub. * Improve comments --- lib/mixins/properties-changed.html | 4 ++++ lib/mixins/properties-mixin.html | 32 ++++++++++-------------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/lib/mixins/properties-changed.html b/lib/mixins/properties-changed.html index 3a2036889e..195ffc8cde 100644 --- a/lib/mixins/properties-changed.html +++ b/lib/mixins/properties-changed.html @@ -369,11 +369,15 @@ * @param {string} name Name of attribute that changed * @param {?string} old Old attribute value * @param {?string} value New attribute value + * @suppress {missingProperties} Super may or may not implement the callback */ attributeChangedCallback(name, old, value) { if (old !== value) { this._attributeToProperty(name, value); } + if (super.attributeChangedCallback) { + super.attributeChangedCallback(name, old, value); + } } /** diff --git a/lib/mixins/properties-mixin.html b/lib/mixins/properties-mixin.html index 89a65534d5..612b6a6568 100644 --- a/lib/mixins/properties-mixin.html +++ b/lib/mixins/properties-mixin.html @@ -17,15 +17,15 @@ 'use strict'; /** - * Mixes `moreProps` into `props` but upgrades shorthand type - * syntax to { type: Type}. - * - * @param {Object} props Properties to normalize - * @return {Object} Copy of input `props` with normalized properties that - * are in the form {type: Type} - * @private - */ - function normalizeProperties(props) { + * Creates a copy of `props` with each property normalized such that + * upgraded it is an object with at least a type property { type: Type}. + * + * @param {Object} props Properties to normalize + * @return {Object} Copy of input `props` with normalized properties that + * are in the form {type: Type} + * @private + */ + function normalizeProperties(props) { const output = {}; for (let p in props) { const o = props[p]; @@ -74,7 +74,7 @@ // generated by this call to the mixin; the instanceof test only works // because the mixin is deduped and guaranteed only to apply once, hence // all constructors in a proto chain will see the same `PropertiesMixin` - return (superCtor.prototype instanceof PropertiesMixin) ? + return (superCtor.prototype instanceof PropertiesMixin) ? /** @type {PropertiesMixinConstructor} */ (superCtor) : null; } @@ -120,7 +120,7 @@ * accessors exist on the element prototype. This method calls * `_finalizeClass` to finalize each constructor in the prototype chain. */ - static finalize() { + static finalize() { if (!this.hasOwnProperty(JSCompiler_renameProperty('__finalized', this))) { const superCtor = superPropertiesClass(/** @type {PropertiesMixinConstructor} */(this)); if (superCtor) { @@ -200,16 +200,6 @@ this._enableProperties(); } - /** - * Called when the element is removed from a document - * @suppress {missingProperties} Super may or may not implement the callback - */ - disconnectedCallback() { - if (super.disconnectedCallback) { - super.disconnectedCallback(); - } - } - } return PropertiesMixin;