Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
* [PropertiesChanged]: check for and call `super.attributeChangedCallback`
* [PropertiesMixin]:
  * remove `disconnectedCallback` stub.
  * Improve comments
  • Loading branch information
Steven Orvell committed Dec 11, 2017
1 parent a89c9ba commit 1b514b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
4 changes: 4 additions & 0 deletions lib/mixins/properties-changed.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

/**
Expand Down
32 changes: 11 additions & 21 deletions lib/mixins/properties-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1b514b4

Please sign in to comment.