diff --git a/.travis.yml b/.travis.yml index 35dbe4f181..c3c05030e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ sudo: false dist: trusty node_js: '9' addons: - firefox: latest + firefox: "66.0" chrome: stable cache: directories: diff --git a/lib/elements/custom-style.js b/lib/elements/custom-style.js index f675393118..1a43b318e0 100644 --- a/lib/elements/custom-style.js +++ b/lib/elements/custom-style.js @@ -87,6 +87,7 @@ export class CustomStyle extends HTMLElement { const include = style.getAttribute(attr); if (include) { style.removeAttribute(attr); + /** @suppress {deprecated} */ style.textContent = cssFromModules(include) + style.textContent; } /* diff --git a/lib/elements/dom-bind.js b/lib/elements/dom-bind.js index cc9b4f70ba..33e7293b09 100644 --- a/lib/elements/dom-bind.js +++ b/lib/elements/dom-bind.js @@ -62,11 +62,16 @@ export class DomBind extends domBindBase { this.__children = null; } + /* eslint-disable no-unused-vars */ /** * @override + * @param {string} name Name of attribute that changed + * @param {?string} old Old attribute value + * @param {?string} value New attribute value + * @param {?string} namespace Attribute namespace. * @return {void} */ - attributeChangedCallback() { + attributeChangedCallback(name, old, value, namespace) { // assumes only one observed attribute this.mutableData = true; } diff --git a/lib/elements/dom-repeat.js b/lib/elements/dom-repeat.js index 7b0407d2e0..2983e4ba36 100644 --- a/lib/elements/dom-repeat.js +++ b/lib/elements/dom-repeat.js @@ -297,7 +297,7 @@ export class DomRepeat extends domRepeatBase { this.__sortFn = null; this.__filterFn = null; this.__observePaths = null; - /** @type {?function(new:Polymer.TemplateInstanceBase, *)} */ + /** @type {?function(new:TemplateInstanceBase, *)} */ this.__ctor = null; this.__isDetached = true; this.template = null; diff --git a/lib/mixins/dir-mixin.js b/lib/mixins/dir-mixin.js index 0b2326fdc4..1957bb489c 100644 --- a/lib/mixins/dir-mixin.js +++ b/lib/mixins/dir-mixin.js @@ -83,6 +83,9 @@ function takeRecords() { * @mixinFunction * @polymer * @appliesMixin PropertyAccessors + * @template T + * @param {function(new:T)} superClass Class to apply mixin to. + * @return {function(new:T)} superClass with mixin applied. */ export const DirMixin = dedupingMixin((base) => { diff --git a/lib/mixins/disable-upgrade-mixin.js b/lib/mixins/disable-upgrade-mixin.js index a97aa9e9ba..8b2022a6eb 100644 --- a/lib/mixins/disable-upgrade-mixin.js +++ b/lib/mixins/disable-upgrade-mixin.js @@ -38,6 +38,9 @@ const DISABLED_ATTR = 'disable-upgrade'; * @mixinFunction * @polymer * @appliesMixin ElementMixin + * @template T + * @param {function(new:T)} superClass Class to apply mixin to. + * @return {function(new:T)} superClass with mixin applied. */ export const DisableUpgradeMixin = dedupingMixin((base) => { /** @@ -67,8 +70,8 @@ export const DisableUpgradeMixin = dedupingMixin((base) => { * @param {string} name Attribute name. * @param {?string} old The previous value for the attribute. * @param {?string} value The new value for the attribute. - * @param {?string=} namespace The XML namespace for the attribute. - * @return {undefined} + * @param {?string} namespace The XML namespace for the attribute. + * @return {void} */ attributeChangedCallback(name, old, value, namespace) { if (name == DISABLED_ATTR) { diff --git a/lib/mixins/element-mixin.js b/lib/mixins/element-mixin.js index ab10624cc2..522914b33b 100644 --- a/lib/mixins/element-mixin.js +++ b/lib/mixins/element-mixin.js @@ -95,6 +95,9 @@ const builtCSS = window.ShadyCSS && window.ShadyCSS['cssBuild']; * import strategies. * @summary Element class mixin that provides the core API for Polymer's * meta-programming features. + * @template T + * @param {function(new:T)} superClass Class to apply mixin to. + * @return {function(new:T)} superClass with mixin applied. */ export const ElementMixin = dedupingMixin(base => { /** diff --git a/lib/mixins/gesture-event-listeners.js b/lib/mixins/gesture-event-listeners.js index b509e8db87..71a4577ff7 100644 --- a/lib/mixins/gesture-event-listeners.js +++ b/lib/mixins/gesture-event-listeners.js @@ -24,63 +24,48 @@ import { addListener, removeListener } from '../utils/gestures.js'; * @mixinFunction * @polymer * @summary Element class mixin that provides API for adding Polymer's - * cross-platform - * gesture events to nodes + * cross-platform gesture events to nodes + * @template T + * @param {function(new:T)} superClass Class to apply mixin to. + * @return {function(new:T)} superClass with mixin applied. */ -const _GestureEventListeners = dedupingMixin( +export const GestureEventListeners = dedupingMixin((superClass) => { + /** + * @polymer + * @mixinClass + * @implements {Polymer_GestureEventListeners} + */ + class GestureEventListeners extends superClass { /** - * @template T - * @param {function(new:T)} superClass Class to apply mixin to. - * @return {function(new:T)} superClass with mixin applied. + * Add the event listener to the node if it is a gestures event. + * + * @param {!EventTarget} node Node to add event listener to + * @param {string} eventName Name of event + * @param {function(!Event):void} handler Listener function to add + * @return {void} + * @override */ - (superClass) => { - /** - * @polymer - * @mixinClass - * @implements {Polymer_GestureEventListeners} - */ - class GestureEventListeners extends superClass { - /** - * Add the event listener to the node if it is a gestures event. - * - * @param {!EventTarget} node Node to add event listener to - * @param {string} eventName Name of event - * @param {function(!Event):void} handler Listener function to add - * @return {void} - * @override - */ - _addEventListenerToNode(node, eventName, handler) { - if (!addListener(node, eventName, handler)) { - super._addEventListenerToNode(node, eventName, handler); - } - } - - /** - * Remove the event listener to the node if it is a gestures event. - * - * @param {!EventTarget} node Node to remove event listener from - * @param {string} eventName Name of event - * @param {function(!Event):void} handler Listener function to remove - * @return {void} - * @override - */ - _removeEventListenerFromNode(node, eventName, handler) { - if (!removeListener(node, eventName, handler)) { - super._removeEventListenerFromNode(node, eventName, handler); - } - } + _addEventListenerToNode(node, eventName, handler) { + if (!addListener(node, eventName, handler)) { + super._addEventListenerToNode(node, eventName, handler); } + } - return GestureEventListeners; - }); + /** + * Remove the event listener to the node if it is a gestures event. + * + * @param {!EventTarget} node Node to remove event listener from + * @param {string} eventName Name of event + * @param {function(!Event):void} handler Listener function to remove + * @return {void} + * @override + */ + _removeEventListenerFromNode(node, eventName, handler) { + if (!removeListener(node, eventName, handler)) { + super._removeEventListenerFromNode(node, eventName, handler); + } + } + } -// Somehow _GestureEventListeners is incorrectly typed as *. For now add this -// cast. -/** - * @template T - * @param {function(new:T)} superClass Class to apply mixin to. - * @return {function(new:T)} superClass with mixin applied. - */ -export const GestureEventListeners = function(superClass) { - return _GestureEventListeners(superClass); -}; + return GestureEventListeners; +}); diff --git a/lib/mixins/mutable-data.js b/lib/mixins/mutable-data.js index d38b5119b9..12072ac47a 100644 --- a/lib/mixins/mutable-data.js +++ b/lib/mixins/mutable-data.js @@ -67,6 +67,9 @@ function mutablePropertyChange(inst, property, value, old, mutableData) { * @polymer * @summary Element class mixin to skip strict dirty-checking for objects * and arrays + * @template T + * @param {function(new:T)} superClass Class to apply mixin to. + * @return {function(new:T)} superClass with mixin applied. */ export const MutableData = dedupingMixin(superClass => { diff --git a/lib/mixins/properties-changed.js b/lib/mixins/properties-changed.js index b81844b828..ff49a5746b 100644 --- a/lib/mixins/properties-changed.js +++ b/lib/mixins/properties-changed.js @@ -33,6 +33,9 @@ const microtask = microTask; * @polymer * @summary Element class mixin for reacting to property changes from * generated property accessors. + * @template T + * @param {function(new:T)} superClass Class to apply mixin to. + * @return {function(new:T)} superClass with mixin applied. */ export const PropertiesChanged = dedupingMixin( /** @@ -161,7 +164,7 @@ export const PropertiesChanged = dedupingMixin( constructor() { super(); - /** @protected {boolean} */ + /** @type {boolean} */ this.__dataEnabled = false; this.__dataReady = false; this.__dataInvalid = false; @@ -426,7 +429,7 @@ export const PropertiesChanged = dedupingMixin( * @param {string} name Name of attribute that changed * @param {?string} old Old attribute value * @param {?string} value New attribute value - * @param {?string=} namespace Attribute namespace. + * @param {?string} namespace Attribute namespace. * @return {void} * @suppress {missingProperties} Super may or may not implement the callback * @override diff --git a/lib/mixins/properties-mixin.js b/lib/mixins/properties-mixin.js index d450cfd299..06fe449d38 100644 --- a/lib/mixins/properties-mixin.js +++ b/lib/mixins/properties-mixin.js @@ -47,6 +47,9 @@ function normalizeProperties(props) { * @appliesMixin PropertiesChanged * @summary Mixin that provides a minimal starting point for using * the PropertiesChanged mixin by providing a declarative `properties` object. + * @template T + * @param {function(new:T)} superClass Class to apply mixin to. + * @return {function(new:T)} superClass with mixin applied. */ export const PropertiesMixin = dedupingMixin(superClass => { diff --git a/lib/mixins/property-accessors.js b/lib/mixins/property-accessors.js index 16d039ef82..2590165c03 100644 --- a/lib/mixins/property-accessors.js +++ b/lib/mixins/property-accessors.js @@ -91,6 +91,9 @@ function saveAccessorValue(model, property) { * @appliesMixin PropertiesChanged * @summary Element class mixin for reacting to property changes from * generated property accessors. + * @template T + * @param {function(new:T)} superClass Class to apply mixin to. + * @return {function(new:T)} superClass with mixin applied. */ export const PropertyAccessors = dedupingMixin(superClass => { diff --git a/lib/mixins/property-effects.js b/lib/mixins/property-effects.js index c12c9870d7..7fd90836d8 100644 --- a/lib/mixins/property-effects.js +++ b/lib/mixins/property-effects.js @@ -1079,6 +1079,9 @@ function upper(name) { * @appliesMixin PropertyAccessors * @summary Element class mixin that provides meta-programming for Polymer's * template binding and data observation system. + * @template T + * @param {function(new:T)} superClass Class to apply mixin to. + * @return {function(new:T)} superClass with mixin applied. */ export const PropertyEffects = dedupingMixin(superClass => { @@ -1150,6 +1153,9 @@ export const PropertyEffects = dedupingMixin(superClass => { this.__templateInfo; } + /** + * @return {!Object} Effect prototype property name map. + */ get PROPERTY_EFFECT_TYPES() { return TYPES; } diff --git a/lib/mixins/strict-binding-parser.js b/lib/mixins/strict-binding-parser.js index 924c69c70f..6027fee112 100644 --- a/lib/mixins/strict-binding-parser.js +++ b/lib/mixins/strict-binding-parser.js @@ -115,6 +115,9 @@ function storeMethodNumber(bindingData, text, i) { * @appliesMixin PropertyEffects * @polymer * @summary Mixin that parses binding expressions and generates corresponding metadata. + * @template T + * @param {function(new:T)} superClass Class to apply mixin to. + * @return {function(new:T)} superClass with mixin applied. */ const StrictBindingParser = dedupingMixin((base) => { diff --git a/lib/mixins/template-stamp.js b/lib/mixins/template-stamp.js index 99313a1165..e7a576ec2a 100644 --- a/lib/mixins/template-stamp.js +++ b/lib/mixins/template-stamp.js @@ -104,6 +104,9 @@ function createNodeEventHandler(context, eventName, methodName) { * @mixinFunction * @polymer * @summary Element class mixin that provides basic template parsing and stamping + * @template T + * @param {function(new:T)} superClass Class to apply mixin to. + * @return {function(new:T)} superClass with mixin applied. */ export const TemplateStamp = dedupingMixin( /** diff --git a/lib/utils/templatize.js b/lib/utils/templatize.js index 7d4ed9dd3f..ff488c15d9 100644 --- a/lib/utils/templatize.js +++ b/lib/utils/templatize.js @@ -101,7 +101,10 @@ function upgradeTemplate(template, constructor) { * @implements {Polymer_PropertyEffects} * @private */ -const templateInstanceBase = PropertyEffects(class {}); +const templateInstanceBase = PropertyEffects( + // This cast shouldn't be neccessary, but Closure doesn't understand that + // "class {}" is a constructor function. + /** @type {function(new:Object)} */(class {})); /** * @polymer @@ -317,7 +320,10 @@ TemplateInstanceBase.prototype.__hostProps; * @implements {Polymer_MutableData} * @private */ -const MutableTemplateInstanceBase = MutableData(TemplateInstanceBase); +const MutableTemplateInstanceBase = MutableData( + // This cast shouldn't be necessary, but Closure doesn't seem to understand + // this constructor. + /** @type {function(new:TemplateInstanceBase)} */(TemplateInstanceBase)); function findMethodHost(template) { // Technically this should be the owner of the outermost template.