From a12934c578cfa17f48dec2477176c0cc8dc6f6c7 Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Tue, 5 Dec 2017 17:34:14 -0800 Subject: [PATCH] Fix most closure warnings. --- externs/closure-types.js | 173 +++++++++++++---------- externs/polymer-closure-types.html | 161 --------------------- externs/polymer-externs.js | 6 +- externs/polymer-internal-shared-types.js | 2 +- lib/legacy/legacy-element-mixin.html | 20 +-- lib/mixins/element-mixin.html | 27 +++- lib/mixins/properties-mixin.html | 19 +-- lib/mixins/property-accessors.html | 4 +- lib/mixins/property-effects.html | 2 +- 9 files changed, 152 insertions(+), 262 deletions(-) delete mode 100644 externs/polymer-closure-types.html diff --git a/externs/closure-types.js b/externs/closure-types.js index f798feb746..e3ff8c5906 100644 --- a/externs/closure-types.js +++ b/externs/closure-types.js @@ -25,7 +25,7 @@ Polymer_PropertiesChanged.prototype._createPropertyAccessor = function(property, * @param {string} property Name of the property * @param {boolean=} readOnly When true, no setter is created */ -Polymer_PropertiesChanged.prototype._generatePropertyAccessor = function(property, readOnly){}; +Polymer_PropertiesChanged.prototype._definePropertyAccessor = function(property, readOnly){}; /** * @return {undefined} */ @@ -92,7 +92,7 @@ Polymer_PropertiesChanged.prototype.attributeChangedCallback = function(name, ol * @param {string} attribute Name of attribute to deserialize. * @param {?string} value of the attribute. * @param {*=} type type to deserialize to, defaults to the value -returned from `_typeForProperty` +returned from `typeForProperty` */ Polymer_PropertiesChanged.prototype._attributeToProperty = function(attribute, value, type){}; /** @@ -108,7 +108,8 @@ Polymer_PropertiesChanged.prototype._propertyToAttribute = function(property, at */ Polymer_PropertiesChanged.prototype._valueToNodeAttribute = function(node, value, attribute){}; /** -* @param {*} value +* @param {*} value Property value to serialize. +* @return {(string|undefined)} */ Polymer_PropertiesChanged.prototype._serializeValue = function(value){}; /** @@ -118,31 +119,23 @@ Polymer_PropertiesChanged.prototype._serializeValue = function(value){}; */ Polymer_PropertiesChanged.prototype._deserializeValue = function(value, type){}; /** -* @param {string} attribute Attribute to convert -* @return {string} +* @param {Object} props Object whose keys are names of accessors. */ -Polymer_PropertiesChanged.prototype._propertyForAttribute = function(attribute){}; +Polymer_PropertiesChanged.createProperties = function(props){}; /** * @param {string} property Property to convert * @return {string} */ -Polymer_PropertiesChanged.prototype._attributeForProperty = function(property){}; +Polymer_PropertiesChanged.attributeNameForProperty = function(property){}; /** * @param {string} name Name of property */ -Polymer_PropertiesChanged.prototype._typeForProperty = function(name){}; -/** -* @param {Object} props Object whose keys are names of accessors. -*/ -Polymer_PropertiesChanged.createProperties = function(props){}; +Polymer_PropertiesChanged.typeForProperty = function(name){}; /** * @interface * @extends {Polymer_PropertiesChanged} */ function Polymer_PropertyAccessors(){} -/** @type {number} */ -Polymer_PropertyAccessors.prototype.__dataCounter; - /** * @param {string} property Name of the property * @param {boolean=} readOnly When true, no setter is created @@ -153,23 +146,14 @@ to set those properties back into the accessor. When calling on an instance, the overwritten value is set via `_setPendingProperty`, and the user should call `_invalidateProperties` or `_flushProperties` for the values to take effect. +* @return {void} */ -Polymer_PropertyAccessors.prototype._generatePropertyAccessor = function(property, readOnly){}; +Polymer_PropertyAccessors.prototype._definePropertyAccessor = function(property, readOnly){}; /** -* @return {undefined} +* @return {void} */ Polymer_PropertyAccessors.prototype._initializeProperties = function(){}; /** -* @return {undefined} -*/ -Polymer_PropertyAccessors.prototype._flushProperties = function(){}; -/** -* @param {Element} node Element to set attribute to. -* @param {*} value Value to serialize. -* @param {string} attribute Attribute name to serialize to. -*/ -Polymer_PropertyAccessors.prototype._valueToNodeAttribute = function(node, value, attribute){}; -/** * @param {*} value Property value to serialize. * @return {(string|undefined)} */ @@ -181,23 +165,15 @@ Polymer_PropertyAccessors.prototype._serializeValue = function(value){}; */ Polymer_PropertyAccessors.prototype._deserializeValue = function(value, type){}; /** -* @param {string} attribute Attribute to convert -* @return {string} -*/ -Polymer_PropertyAccessors.prototype._propertyForAttribute = function(attribute){}; -/** -* @param {string} property Property to convert -* @return {string} -*/ -Polymer_PropertyAccessors.prototype._attributeForProperty = function(property){}; -/** * @param {Object} props Bag of property values that were overwritten when creating property accessors. +* @return {void} */ Polymer_PropertyAccessors.prototype._initializeProtoProperties = function(props){}; /** * @param {string} attribute Name of attribute to ensure is set. * @param {string} value of the attribute. +* @return {void} */ Polymer_PropertyAccessors.prototype._ensureAttribute = function(attribute, value){}; /** @@ -211,7 +187,12 @@ Polymer_PropertyAccessors.prototype._hasAccessor = function(property){}; */ Polymer_PropertyAccessors.prototype._isPropertyPending = function(prop){}; /** -* @return {undefined} +* @param {string} property Property to convert +* @return {string} +*/ +Polymer_PropertyAccessors.attributeNameForProperty = function(property){}; +/** +* @return {void} */ Polymer_PropertyAccessors.createPropertiesForAttributes = function(){}; /** @@ -236,12 +217,14 @@ Polymer_TemplateStamp.prototype._addMethodEventListenerToNode = function(node, e * @param {Node} node Node to add event listener to * @param {string} eventName Name of event * @param {Function} handler Listener function to add +* @return {void} */ Polymer_TemplateStamp.prototype._addEventListenerToNode = function(node, eventName, handler){}; /** * @param {Node} node Node to remove event listener from * @param {string} eventName Name of event * @param {Function} handler Listener function to remove +* @return {void} */ Polymer_TemplateStamp.prototype._removeEventListenerFromNode = function(node, eventName, handler){}; /** @@ -268,6 +251,7 @@ Polymer_TemplateStamp._parseTemplateNode = function(node, templateInfo, nodeInfo * @param {Node} root Root node whose `childNodes` will be parsed * @param {!TemplateInfo} templateInfo Template metadata for current template * @param {!NodeInfo} nodeInfo Node metadata for current template. +* @return {void} */ Polymer_TemplateStamp._parseTemplateChildNodes = function(root, templateInfo, nodeInfo){}; /** @@ -305,9 +289,6 @@ Polymer_TemplateStamp._contentForTemplate = function(template){}; * @extends {Polymer_PropertyAccessors} */ function Polymer_PropertyEffects(){} -/** @type {number} */ -Polymer_PropertyEffects.prototype.__dataCounter; - /** @type {boolean} */ Polymer_PropertyEffects.prototype.__dataClientsReady; @@ -402,6 +383,10 @@ Polymer_PropertyEffects.prototype._setPendingProperty = function(property, value */ Polymer_PropertyEffects.prototype._invalidateProperties = function(){}; /** +* @return {undefined} +*/ +Polymer_PropertyEffects.prototype._flushProperties = function(){}; +/** * @override */ Polymer_PropertyEffects.prototype._propertiesChanged = function(currentProps, changedProps, oldProps){}; @@ -414,12 +399,14 @@ Polymer_PropertyEffects.prototype._initializeProtoProperties = function(props){} * @param {string} property Property that should trigger the effect * @param {string} type Effect type, from this.PROPERTY_EFFECT_TYPES * @param {Object=} effect Effect metadata object +* @return {void} */ Polymer_PropertyEffects.prototype._addPropertyEffect = function(property, type, effect){}; /** * @param {string} property Property the effect was associated with * @param {string} type Effect type, from this.PROPERTY_EFFECT_TYPES * @param {Object=} effect Effect metadata object to remove +* @return {void} */ Polymer_PropertyEffects.prototype._removePropertyEffect = function(property, type, effect){}; /** @@ -465,18 +452,20 @@ Polymer_PropertyEffects.prototype._setPendingPropertyOrPath = function(path, val * @param {Node} node The node to set a property on * @param {string} prop The property to set * @param {*} value The value to set +* @return {void} */ Polymer_PropertyEffects.prototype._setUnmanagedPropertyToNode = function(node, prop, value){}; /** * @param {Object} client PropertyEffects client to enqueue +* @return {void} */ Polymer_PropertyEffects.prototype._enqueueClient = function(client){}; /** -* @return {undefined} +* @return {void} */ Polymer_PropertyEffects.prototype._flushClients = function(){}; /** -* @return {undefined} +* @return {void} */ Polymer_PropertyEffects.prototype._readyClients = function(){}; /** @@ -485,21 +474,25 @@ Polymer_PropertyEffects.prototype._readyClients = function(){}; * @param {boolean=} setReadOnly When true, any private values set in `props` will be set. By default, `setProperties` will not set `readOnly: true` root properties. +* @return {void} */ Polymer_PropertyEffects.prototype.setProperties = function(props, setReadOnly){}; /** * @param {Object} changedProps Bag of changed properties * @param {Object} oldProps Bag of previous values for changed properties * @param {boolean} hasPaths True with `props` contains one or more paths +* @return {void} */ Polymer_PropertyEffects.prototype._propagatePropertyChanges = function(changedProps, oldProps, hasPaths){}; /** * @param {(string|!Array.<(string|number)>)} to Target path to link. * @param {(string|!Array.<(string|number)>)} from Source path to link. +* @return {void} */ Polymer_PropertyEffects.prototype.linkPaths = function(to, from){}; /** * @param {(string|!Array.<(string|number)>)} path Target path to unlink. +* @return {void} */ Polymer_PropertyEffects.prototype.unlinkPaths = function(path){}; /** @@ -516,6 +509,7 @@ Polymer_PropertyEffects.prototype.unlinkPaths = function(path){}; Note that splice records _must_ be normalized such that they are reported in index order (raw results from `Object.observe` are not ordered and must be normalized/merged before notifying). +* @return {void} */ Polymer_PropertyEffects.prototype.notifySplices = function(path, splices){}; /** @@ -541,6 +535,7 @@ Polymer_PropertyEffects.prototype.get = function(path, root){}; * @param {*} value Value to set at the specified path. * @param {Object=} root Root object from which the path is evaluated. When specified, no notification will occur. +* @return {void} */ Polymer_PropertyEffects.prototype.set = function(path, value, root){}; /** @@ -576,33 +571,39 @@ Polymer_PropertyEffects.prototype.unshift = function(path, items){}; /** * @param {string} path Path that should be notified. * @param {*=} value Value at the path (optional). +* @return {void} */ Polymer_PropertyEffects.prototype.notifyPath = function(path, value){}; /** * @param {string} property Property name * @param {boolean=} protectedSetter Creates a custom protected setter when `true`. +* @return {void} */ Polymer_PropertyEffects.prototype._createReadOnlyProperty = function(property, protectedSetter){}; /** * @param {string} property Property name -* @param {string} methodName Name of observer method to call +* @param {(string|function (*, *))} method Function or name of observer method to call * @param {boolean=} dynamicFn Whether the method name should be included as a dependency to the effect. +* @return {void} */ -Polymer_PropertyEffects.prototype._createPropertyObserver = function(property, methodName, dynamicFn){}; +Polymer_PropertyEffects.prototype._createPropertyObserver = function(property, method, dynamicFn){}; /** * @param {string} expression Method expression * @param {(boolean|Object)=} dynamicFn Boolean or object map indicating whether method names should be included as a dependency to the effect. +* @return {void} */ Polymer_PropertyEffects.prototype._createMethodObserver = function(expression, dynamicFn){}; /** * @param {string} property Property name +* @return {void} */ Polymer_PropertyEffects.prototype._createNotifyingProperty = function(property){}; /** * @param {string} property Property name +* @return {void} */ Polymer_PropertyEffects.prototype._createReflectedProperty = function(property){}; /** @@ -610,6 +611,7 @@ Polymer_PropertyEffects.prototype._createReflectedProperty = function(property){ * @param {string} expression Method expression * @param {(boolean|Object)=} dynamicFn Boolean or object map indicating whether method names should be included as a dependency to the effect. +* @return {void} */ Polymer_PropertyEffects.prototype._createComputedProperty = function(property, expression, dynamicFn){}; /** @@ -626,6 +628,7 @@ Polymer_PropertyEffects.prototype._bindTemplate = function(template, instanceBin /** * @param {!StampedTemplate} dom DocumentFragment previously returned from `_stampTemplate` associated with the nodes to be removed +* @return {void} */ Polymer_PropertyEffects.prototype._removeBoundDom = function(dom){}; /** @@ -658,33 +661,38 @@ Polymer_PropertyEffects._parseTemplateNodeAttribute = function(node, templateInf * @param {string} property Property that should trigger the effect * @param {string} type Effect type, from this.PROPERTY_EFFECT_TYPES * @param {Object=} effect Effect metadata object +* @return {void} */ Polymer_PropertyEffects.addPropertyEffect = function(property, type, effect){}; /** * @param {string} property Property name -* @param {string} methodName Name of observer method to call +* @param {(string|function (*, *))} method Function or name of observer method to call * @param {boolean=} dynamicFn Whether the method name should be included as a dependency to the effect. +* @return {void} */ -Polymer_PropertyEffects.createPropertyObserver = function(property, methodName, dynamicFn){}; +Polymer_PropertyEffects.createPropertyObserver = function(property, method, dynamicFn){}; /** * @param {string} expression Method expression * @param {(boolean|Object)=} dynamicFn Boolean or object map indicating - whether method names should be included as a dependency to the effect. +* @return {void} */ Polymer_PropertyEffects.createMethodObserver = function(expression, dynamicFn){}; /** * @param {string} property Property name +* @return {void} */ Polymer_PropertyEffects.createNotifyingProperty = function(property){}; /** * @param {string} property Property name * @param {boolean=} protectedSetter Creates a custom protected setter when `true`. +* @return {void} */ Polymer_PropertyEffects.createReadOnlyProperty = function(property, protectedSetter){}; /** * @param {string} property Property name +* @return {void} */ Polymer_PropertyEffects.createReflectedProperty = function(property){}; /** @@ -692,6 +700,7 @@ Polymer_PropertyEffects.createReflectedProperty = function(property){}; * @param {string} expression Method expression * @param {(boolean|Object)=} dynamicFn Boolean or object map indicating whether method names should be included as a dependency to the effect. +* @return {void} */ Polymer_PropertyEffects.createComputedProperty = function(property, expression, dynamicFn){}; /** @@ -704,6 +713,7 @@ Polymer_PropertyEffects.bindTemplate = function(template){}; * @param {Object} templateInfo Template metadata to add effect to * @param {string} prop Property that should trigger the effect * @param {Object=} effect Effect metadata object +* @return {void} */ Polymer_PropertyEffects._addTemplatePropertyEffect = function(templateInfo, prop, effect){}; /** @@ -733,19 +743,6 @@ function Polymer_PropertiesMixin(){} */ Polymer_PropertiesMixin.prototype._initializeProperties = function(){}; /** -* @param {*} name -*/ -Polymer_PropertiesMixin.prototype._propertyForAttribute = function(name){}; -/** -* @param {*} name -*/ -Polymer_PropertiesMixin.prototype._attributeForProperty = function(name){}; -/** -* @param {string} name Name of property -* @return {*} -*/ -Polymer_PropertiesMixin.prototype._typeForProperty = function(name){}; -/** * @return {undefined} */ Polymer_PropertiesMixin.prototype.connectedCallback = function(){}; @@ -754,6 +751,11 @@ Polymer_PropertiesMixin.prototype.connectedCallback = function(){}; */ Polymer_PropertiesMixin.prototype.disconnectedCallback = function(){}; /** +* @param {string} name Name of property +* @return {*} +*/ +Polymer_PropertiesMixin.typeForProperty = function(name){}; +/** * @return {undefined} */ Polymer_PropertiesMixin.finalize = function(){}; @@ -764,6 +766,7 @@ Polymer_PropertiesMixin._finalizeClass = function(){}; /** * @interface * @extends {Polymer_PropertyEffects} +* @extends {Polymer_PropertiesMixin} */ function Polymer_ElementMixin(){} /** @type {HTMLTemplateElement} */ @@ -794,13 +797,6 @@ Polymer_ElementMixin.prototype.ready = function(){}; Polymer_ElementMixin.prototype._initializeProperties = function(){}; /** * @override -* @param {string} name Name of attribute. -* @param {?string} old Old value of attribute. -* @param {?string} value Current value of attribute. -*/ -Polymer_ElementMixin.prototype.attributeChangedCallback = function(name, old, value){}; -/** -* @override */ Polymer_ElementMixin.prototype._readyClients = function(){}; /** @@ -815,6 +811,7 @@ Polymer_ElementMixin.prototype._attachDom = function(dom){}; /** * @param {Object=} properties Bag of custom property key/values to apply to this element. +* @return {void} */ Polymer_ElementMixin.prototype.updateStyles = function(properties){}; /** @@ -829,14 +826,25 @@ Polymer_ElementMixin.prototype.resolveUrl = function(url, base){}; */ Polymer_ElementMixin._parseTemplateContent = function(template, templateInfo, nodeInfo){}; /** -* @param {*} props +* @override +* @return {void} */ Polymer_ElementMixin.createProperties = function(props){}; /** -* @return {undefined} +* @override +* @return {void} */ Polymer_ElementMixin._finalizeClass = function(){}; /** +* @param {Object} observers Array of observer descriptors for + this class +* @param {Object} dynamicFns Object containing keys for any properties + that are functions and should trigger the effect when the function + reference is changed +* @return {void} +*/ +Polymer_ElementMixin.createObservers = function(observers, dynamicFns){}; +/** * @param {string} cssText Text containing styling to process * @param {string} baseURI Base URI to rebase CSS paths against * @return {string} @@ -844,6 +852,7 @@ Polymer_ElementMixin._finalizeClass = function(){}; Polymer_ElementMixin._processStyleText = function(cssText, baseURI){}; /** * @param {string} is Tag name (or type extension name) for this element +* @return {void} */ Polymer_ElementMixin._finalizeTemplate = function(is){}; /** @@ -926,6 +935,10 @@ Polymer_LegacyElementMixin.prototype.attributeChangedCallback = function(name, o */ Polymer_LegacyElementMixin.prototype.connectedCallback = function(){}; /** +* @override +*/ +Polymer_LegacyElementMixin.prototype.disconnectedCallback = function(){}; +/** * @return {undefined} */ Polymer_LegacyElementMixin.prototype.created = function(){}; @@ -934,10 +947,6 @@ Polymer_LegacyElementMixin.prototype.created = function(){}; */ Polymer_LegacyElementMixin.prototype.attached = function(){}; /** -* @override -*/ -Polymer_LegacyElementMixin.prototype.disconnectedCallback = function(){}; -/** * @return {undefined} */ Polymer_LegacyElementMixin.prototype.detached = function(){}; @@ -974,12 +983,14 @@ Polymer_LegacyElementMixin.prototype.deserialize = function(value, type){}; * @param {string} property Property name to reflect. * @param {string=} attribute Attribute name to reflect. * @param {*=} value Property value to reflect. +* @return {void} */ Polymer_LegacyElementMixin.prototype.reflectPropertyToAttribute = function(property, attribute, value){}; /** * @param {*} value Value to serialize. * @param {string} attribute Attribute name to serialize to. * @param {Element} node Element to set attribute to. +* @return {void} */ Polymer_LegacyElementMixin.prototype.serializeValueToAttribute = function(value, attribute, node){}; /** @@ -1021,6 +1032,7 @@ Polymer_LegacyElementMixin.prototype.fire = function(type, detail, options){}; * @param {Element} node Element to add event listener to. * @param {string} eventName Name of event to listen for. * @param {string} methodName Name of handler method on `this` to call. +* @return {void} */ Polymer_LegacyElementMixin.prototype.listen = function(node, eventName, methodName){}; /** @@ -1028,6 +1040,7 @@ Polymer_LegacyElementMixin.prototype.listen = function(node, eventName, methodNa * @param {string} eventName Name of event to stop listening to. * @param {string} methodName Name of handler method on `this` to not call anymore. +* @return {void} */ Polymer_LegacyElementMixin.prototype.unlisten = function(node, eventName, methodName){}; /** @@ -1035,6 +1048,7 @@ Polymer_LegacyElementMixin.prototype.unlisten = function(node, eventName, method Defaults to `all`. * @param {Element=} node Element to apply scroll direction setting. Defaults to `this`. +* @return {void} */ Polymer_LegacyElementMixin.prototype.setScrollDirection = function(direction, node){}; /** @@ -1043,7 +1057,7 @@ Polymer_LegacyElementMixin.prototype.setScrollDirection = function(direction, no */ Polymer_LegacyElementMixin.prototype.$$ = function(slctr){}; /** -* @return {undefined} +* @return {void} */ Polymer_LegacyElementMixin.prototype.distributeContent = function(){}; /** @@ -1121,10 +1135,12 @@ Polymer_LegacyElementMixin.prototype.debounce = function(jobName, callback, wait Polymer_LegacyElementMixin.prototype.isDebouncerActive = function(jobName){}; /** * @param {string} jobName The name of the debouncer started with `debounce` +* @return {void} */ Polymer_LegacyElementMixin.prototype.flushDebouncer = function(jobName){}; /** * @param {string} jobName The name of the debouncer started with `debounce` +* @return {void} */ Polymer_LegacyElementMixin.prototype.cancelDebouncer = function(jobName){}; /** @@ -1138,6 +1154,7 @@ Polymer_LegacyElementMixin.prototype.async = function(callback, waitTime){}; /** * @param {number} handle Handle returned from original `async` call to cancel. +* @return {void} */ Polymer_LegacyElementMixin.prototype.cancelAsync = function(handle){}; /** @@ -1182,6 +1199,7 @@ Polymer_LegacyElementMixin.prototype.toggleClass = function(name, bool, node){}; * @param {string} transformText Transform setting. * @param {Element=} node Element to apply the transform to. Defaults to `this` +* @return {void} */ Polymer_LegacyElementMixin.prototype.transform = function(transformText, node){}; /** @@ -1190,6 +1208,7 @@ Polymer_LegacyElementMixin.prototype.transform = function(transformText, node){} * @param {number} z Z offset. * @param {Element=} node Element to apply the transform to. Defaults to `this`. +* @return {void} */ Polymer_LegacyElementMixin.prototype.translate3d = function(x, y, z, node){}; /** @@ -1283,17 +1302,21 @@ Polymer_ArraySelectorMixin.prototype.isSelected = function(item){}; Polymer_ArraySelectorMixin.prototype.isIndexSelected = function(idx){}; /** * @param {*} item Item from `items` array to deselect +* @return {void} */ Polymer_ArraySelectorMixin.prototype.deselect = function(item){}; /** * @param {number} idx Index from `items` array to deselect +* @return {void} */ Polymer_ArraySelectorMixin.prototype.deselectIndex = function(idx){}; /** * @param {*} item Item from `items` array to select +* @return {void} */ Polymer_ArraySelectorMixin.prototype.select = function(item){}; /** * @param {number} idx Index from `items` array to select +* @return {void} */ Polymer_ArraySelectorMixin.prototype.selectIndex = function(idx){}; \ No newline at end of file diff --git a/externs/polymer-closure-types.html b/externs/polymer-closure-types.html deleted file mode 100644 index 0c499ecee8..0000000000 --- a/externs/polymer-closure-types.html +++ /dev/null @@ -1,161 +0,0 @@ - - - \ No newline at end of file diff --git a/externs/polymer-externs.js b/externs/polymer-externs.js index 2ebdb20ef8..12bd2d0384 100644 --- a/externs/polymer-externs.js +++ b/externs/polymer-externs.js @@ -21,7 +21,7 @@ * computed: (string | undefined), * reflectToAttribute: (boolean | undefined), * notify: (boolean | undefined), - * observer: (string | undefined) + * observer: (string | function(*,*) | undefined) * }} */ let PolymerElementPropertiesMeta; @@ -59,6 +59,10 @@ PolymerElementConstructor.observers; /** @type {(!HTMLTemplateElement | string | undefined)} */ PolymerElementConstructor.template; +let PropertiesMixinConstructor = function (){}; +/** @type {(!PolymerElementProperties | undefined)} */ +PropertiesMixinConstructor.properties; + /** * @param {!PolymerInit} init * @return {!function(new:HTMLElement)} diff --git a/externs/polymer-internal-shared-types.js b/externs/polymer-internal-shared-types.js index ef49e68dc9..30220a35c6 100644 --- a/externs/polymer-internal-shared-types.js +++ b/externs/polymer-internal-shared-types.js @@ -21,7 +21,7 @@ function StampedTemplate() { } StampedTemplate.prototype.__noInsertionPoint; /** @type {!Array} */ StampedTemplate.prototype.nodeList; -/** @type {!Object} */ +/** @type {!Object} */ StampedTemplate.prototype.$; /** @type {!TemplateInfo | undefined} */ StampedTemplate.prototype.templateInfo; diff --git a/lib/legacy/legacy-element-mixin.html b/lib/legacy/legacy-element-mixin.html index 482dfeacd9..1a671a7274 100644 --- a/lib/legacy/legacy-element-mixin.html +++ b/lib/legacy/legacy-element-mixin.html @@ -483,11 +483,12 @@ * childNodes list is the same as the element's childNodes except that * any `` elements are replaced with the list of nodes distributed * to the ``, the result of its `getDistributedNodes` method. - * @this {Element} * @return {Array} List of effective child nodes. + * @suppress {invalidCasts} LegacyElementMixin must be applied to an HTMLElement */ getEffectiveChildNodes() { - const domApi = /** @type {Polymer.DomApi} */(Polymer.dom(this)); + const thisEl = /** @type {Element} */ (this); + const domApi = /** @type {Polymer.DomApi} */(Polymer.dom(thisEl)); return domApi.getEffectiveChildNodes(); } @@ -496,11 +497,12 @@ * `selector`. These can be dom children or elements distributed to * children that are insertion points. * @param {string} selector Selector to run. - * @this {Element} * @return {Array} List of distributed elements that match selector. + * @suppress {invalidCasts} LegacyElementMixin must be applied to an HTMLElement */ queryDistributedElements(selector) { - const domApi = /** @type {Polymer.DomApi} */(Polymer.dom(this)); + const thisEl = /** @type {Element} */ (this); + const domApi = /** @type {Polymer.DomApi} */(Polymer.dom(thisEl)); return domApi.queryDistributedElements(selector); } @@ -601,12 +603,13 @@ * Checks whether an element is in this element's light DOM tree. * * @param {?Node} node The element to be checked. - * @this {Element} * @return {boolean} true if node is in this element's light DOM tree. + * @suppress {invalidCasts} LegacyElementMixin must be applied to an HTMLElement */ isLightDescendant(node) { - return this !== node && this.contains(node) && - this.getRootNode() === node.getRootNode(); + const thisNode = /** @type {Node} */ (this); + return thisNode !== node && thisNode.contains(node) && + thisNode.getRootNode() === node.getRootNode(); } /** @@ -628,9 +631,10 @@ * @param {string} property The css property name. * @return {string} Returns the computed css property value for the given * `property`. + * @suppress {invalidCasts} LegacyElementMixin must be applied to an HTMLElement */ getComputedStyleValue(property) { - return styleInterface.getComputedStyleValue(this, property); + return styleInterface.getComputedStyleValue(/** @type {!Element} */(this), property); } // debounce diff --git a/lib/mixins/element-mixin.html b/lib/mixins/element-mixin.html index b04c88fa92..26e1a38c36 100644 --- a/lib/mixins/element-mixin.html +++ b/lib/mixins/element-mixin.html @@ -80,6 +80,7 @@ * @mixinFunction * @polymer * @appliesMixin Polymer.PropertyEffects + * @appliesMixin Polymer.PropertiesMixin * @memberof Polymer * @property rootPath {string} Set to the value of `Polymer.rootPath`, * which defaults to the main document path @@ -96,6 +97,7 @@ * @constructor * @extends {base} * @implements {Polymer_PropertyEffects} + * @implements {Polymer_PropertiesMixin} */ const polymerElementBase = Polymer.PropertiesMixin(Polymer.PropertyEffects(base)); @@ -191,7 +193,7 @@ * and/or provide an advanced api for manipulating them. * Also consider adding warnings when an effect cannot be changed. * - * @param {PolymerElement} proto Element class prototype to add accessors + * @param {!PolymerElement} proto Element class prototype to add accessors * and effects to * @param {string} name Name of the property. * @param {Object} info Info object from which to create property effects. @@ -211,7 +213,7 @@ // setup where multiple triggers for setting a property) // While we do have `hasComputedEffect` this is set on the property's // dependencies rather than itself. - if (info.computed && !proto._hasReadOnlyEffect(name)) { + if (info.computed && !proto._hasReadOnlyEffect(name)) { proto._createComputedProperty(name, info.computed, allProps); } if (info.readOnly && !proto._hasReadOnlyEffect(name)) { @@ -273,7 +275,15 @@ */ class PolymerElement extends polymerElementBase { - static _finalizeClass() { + /** + * Override of PropertiesMixin _finalizeClass to create observers and + * find the template. + * @return {void} + * @protected + * @override + * @suppress {missingProperties} Interfaces in closure do not inherit statics, but classes do + */ + static _finalizeClass() { super._finalizeClass(); if (this.hasOwnProperty( JSCompiler_renameProperty('is', this)) && this.is) { @@ -298,7 +308,14 @@ } - static createProperties(props) { + /** + * Override of PropertiesChanged createProperties to create accessors + * and property effects for all of the properties. + * @return {void} + * @protected + * @override + */ + static createProperties(props) { for (let p in props) { createPropertyFromConfig(this.prototype, p, props[p], props); } @@ -496,7 +513,7 @@ * flushes any pending properties, and updates shimmed CSS properties * when using the ShadyCSS scoping/custom properties polyfill. * - * @suppress {invalidCasts} + * @suppress {missingProperties, invalidCasts} Super may or may not implement the callback */ connectedCallback() { if (window.ShadyCSS && this._template) { diff --git a/lib/mixins/properties-mixin.html b/lib/mixins/properties-mixin.html index 66e6276e32..89a65534d5 100644 --- a/lib/mixins/properties-mixin.html +++ b/lib/mixins/properties-mixin.html @@ -65,8 +65,8 @@ * Returns the super class constructor for the given class, if it is an * instance of the PropertiesMixin. * - * @param {!PropertiesMixin} constructor PropertiesMixin constructor - * @return {PropertiesMixin} Super class constructor + * @param {!PropertiesMixinConstructor} constructor PropertiesMixin constructor + * @return {PropertiesMixinConstructor} Super class constructor */ function superPropertiesClass(constructor) { const superCtor = Object.getPrototypeOf(constructor); @@ -75,7 +75,7 @@ // 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; + /** @type {PropertiesMixinConstructor} */ (superCtor) : null; } /** @@ -83,7 +83,7 @@ * given class. Properties not in object format are converted to at * least {type}. * - * @param {PropertiesMixin} constructor PropertiesMixin constructor + * @param {PropertiesMixinConstructor} constructor PropertiesMixin constructor * @return {Object} Memoized properties object */ function ownProperties(constructor) { @@ -107,6 +107,7 @@ /** * Implements standard custom elements getter to observes the attributes * listed in `properties`. + * @suppress {missingProperties} Interfaces in closure do not inherit statics, but classes do */ static get observedAttributes() { const props = this._properties; @@ -121,7 +122,7 @@ */ static finalize() { if (!this.hasOwnProperty(JSCompiler_renameProperty('__finalized', this))) { - const superCtor = superPropertiesClass(this); + const superCtor = superPropertiesClass(/** @type {PropertiesMixinConstructor} */(this)); if (superCtor) { superCtor.finalize(); } @@ -138,7 +139,7 @@ * @protected */ static _finalizeClass() { - const props = ownProperties(this); + const props = ownProperties(/** @type {PropertiesMixinConstructor} */(this)); if (props) { this.createProperties(props); } @@ -155,10 +156,10 @@ static get _properties() { if (!this.hasOwnProperty( JSCompiler_renameProperty('__properties', this))) { - const superCtor = superPropertiesClass(this); + const superCtor = superPropertiesClass(/** @type {PropertiesMixinConstructor} */(this)); this.__properties = Object.assign({}, superCtor && superCtor._properties, - ownProperties(this)); + ownProperties(/** @type {PropertiesMixinConstructor} */(this))); } return this.__properties; } @@ -190,6 +191,7 @@ * Called when the element is added to a document. * Calls `_enableProperties` to turn on property system from * `PropertiesChanged`. + * @suppress {missingProperties} Super may or may not implement the callback */ connectedCallback() { if (super.connectedCallback) { @@ -200,6 +202,7 @@ /** * Called when the element is removed from a document + * @suppress {missingProperties} Super may or may not implement the callback */ disconnectedCallback() { if (super.disconnectedCallback) { diff --git a/lib/mixins/property-accessors.html b/lib/mixins/property-accessors.html index 52d86f1ed6..67582b4ead 100644 --- a/lib/mixins/property-accessors.html +++ b/lib/mixins/property-accessors.html @@ -253,8 +253,8 @@ } break; case Date: - value = isNaN(value) ? String(value) : Number(value); - outValue = new Date(value); + outValue = isNaN(value) ? String(value) : Number(value); + outValue = new Date(outValue); break; default: outValue = super._deserializeValue(value, type); diff --git a/lib/mixins/property-effects.html b/lib/mixins/property-effects.html index 9ea6470050..7145adc0c4 100644 --- a/lib/mixins/property-effects.html +++ b/lib/mixins/property-effects.html @@ -2048,7 +2048,7 @@ fn: runObserverEffect, info, trigger: {name: property} }); if (dynamicFn) { - this._addPropertyEffect(method, TYPES.OBSERVE, { + this._addPropertyEffect(/** @type {string} */(method), TYPES.OBSERVE, { fn: runObserverEffect, info, trigger: {name: method} }); }