Move function out of closure. Add comments.

This commit is contained in:
Kevin Schaaf
2017-12-05 15:32:46 -08:00
parent ed1454d628
commit ad539fe725
+30 -29
View File
@@ -16,6 +16,24 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
(function() {
'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) {
const output = {};
for (let p in props) {
const o = props[p];
output[p] = (typeof o === 'function') ? {type: o} : o;
}
return output;
}
/**
* Mixin that provides a minimal starting point to using the PropertiesChanged
* mixin by providing a mechanism to declare properties in a static
@@ -43,36 +61,21 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*/
const base = Polymer.PropertiesChanged(superClass);
/**
* 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) {
const output = {};
for (let p in props) {
const o = props[p];
output[p] = (typeof o === 'function') ? {type: o} : o;
}
return output;
}
/**
* Returns the super class constructor for the given class, if it is an
* instance of the PropertiesMixin.
*
* @param {PropertiesMixinConstructor} constructor PropertiesMixin constructor
* @return {PropertiesMixinConstructor} Super class constructor
* @param {!PropertiesMixin} constructor PropertiesMixin constructor
* @return {PropertiesMixin} Super class constructor
*/
function superPropertiesClass(constructor) {
const superCtor = Object.getPrototypeOf(constructor);
if (superCtor.prototype instanceof PropertiesMixin) {
return superCtor;
}
// Note, the `PropertiesMixin` class below only refers to the class
// 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) ?
/** @type {PropertiesMixin} */ (superCtor) : null;
}
/**
@@ -80,7 +83,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* given class. Properties not in object format are converted to at
* least {type}.
*
* @param {PropertiesMixinConstructor} constructor PropertiesMixin constructor
* @param {PropertiesMixin} constructor PropertiesMixin constructor
* @return {Object} Memoized properties object
*/
function ownProperties(constructor) {
@@ -189,14 +192,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
* `PropertiesChanged`.
*/
connectedCallback() {
if (super.connectedCallback) {
super.connectedCallback();
}
this._enableProperties();
}
/**
* Called when the element is removed from a document
*/
disconnectedCallback() {}
}
return PropertiesMixin;