mirror of
https://github.com/Polymer/polymer.git
synced 2026-08-19 01:14:44 -05:00
Move function out of closure. Add comments.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user