From cdd4e204faf88cf640a6d4eeb0f252b3e0c0526e Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Thu, 30 May 2019 15:22:52 -0700 Subject: [PATCH 01/10] Fix GestureEventListeners generated externs name. Due to some compiler weirdness, we recently added some hacky indirection around GestureEventListeners, however this changed the name of that mixin from Analyzer's perspective by adding a leading underscore. This fixes that. --- lib/mixins/gesture-event-listeners.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/mixins/gesture-event-listeners.js b/lib/mixins/gesture-event-listeners.js index b509e8db87..04dc14fd89 100644 --- a/lib/mixins/gesture-event-listeners.js +++ b/lib/mixins/gesture-event-listeners.js @@ -27,7 +27,7 @@ import { addListener, removeListener } from '../utils/gestures.js'; * cross-platform * gesture events to nodes */ -const _GestureEventListeners = dedupingMixin( +const GestureEventListeners = dedupingMixin( /** * @template T * @param {function(new:T)} superClass Class to apply mixin to. @@ -74,13 +74,15 @@ const _GestureEventListeners = dedupingMixin( return GestureEventListeners; }); -// Somehow _GestureEventListeners is incorrectly typed as *. For now add this +// 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); +const _GestureEventListeners = function(superClass) { + return GestureEventListeners(superClass); }; + +export {_GestureEventListeners as GestureEventListeners}; From 54b1d78d226cb42ffa74f728c1b62e74bb3d4dfa Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Thu, 30 May 2019 15:26:27 -0700 Subject: [PATCH 02/10] Add @suppress annotation for use of deprecated cssFromModules --- lib/elements/custom-style.js | 1 + 1 file changed, 1 insertion(+) 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; } /* From fc190dd5d030c820727391a10c368cc5107479cf Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Thu, 30 May 2019 15:27:23 -0700 Subject: [PATCH 03/10] Fix old global namespace type annotation for TemplateInstanceBase --- lib/elements/dom-repeat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From e4e9e2fb525de139dd5cb15556b30a77a61b2751 Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Thu, 30 May 2019 15:29:35 -0700 Subject: [PATCH 04/10] Annotate __dataEnabled in a way analyzer understands --- lib/mixins/properties-changed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mixins/properties-changed.js b/lib/mixins/properties-changed.js index b81844b828..8b71c46c62 100644 --- a/lib/mixins/properties-changed.js +++ b/lib/mixins/properties-changed.js @@ -161,7 +161,7 @@ export const PropertiesChanged = dedupingMixin( constructor() { super(); - /** @protected {boolean} */ + /** @type {boolean} */ this.__dataEnabled = false; this.__dataReady = false; this.__dataInvalid = false; From 3dd189c418ae029555504238cc91e1c2ba485f4c Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Thu, 30 May 2019 15:31:14 -0700 Subject: [PATCH 05/10] Add @return annotation for PROPERTY_EFFECT_TYPES getter --- lib/mixins/property-effects.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/mixins/property-effects.js b/lib/mixins/property-effects.js index c12c9870d7..3affb2661b 100644 --- a/lib/mixins/property-effects.js +++ b/lib/mixins/property-effects.js @@ -1150,6 +1150,9 @@ export const PropertyEffects = dedupingMixin(superClass => { this.__templateInfo; } + /** + * @return {!Object} + */ get PROPERTY_EFFECT_TYPES() { return TYPES; } From 4cc6c339218a1d66be69e9f764383f3cc6de8205 Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Thu, 30 May 2019 15:38:35 -0700 Subject: [PATCH 06/10] Align signatures of attributeChangedCallback --- lib/elements/dom-bind.js | 6 +++++- lib/mixins/disable-upgrade-mixin.js | 4 ++-- lib/mixins/properties-changed.js | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/elements/dom-bind.js b/lib/elements/dom-bind.js index cc9b4f70ba..a897a92ab8 100644 --- a/lib/elements/dom-bind.js +++ b/lib/elements/dom-bind.js @@ -64,9 +64,13 @@ export class DomBind extends domBindBase { /** * @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/mixins/disable-upgrade-mixin.js b/lib/mixins/disable-upgrade-mixin.js index a97aa9e9ba..7cb9e894fa 100644 --- a/lib/mixins/disable-upgrade-mixin.js +++ b/lib/mixins/disable-upgrade-mixin.js @@ -67,8 +67,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/properties-changed.js b/lib/mixins/properties-changed.js index 8b71c46c62..363138b1ac 100644 --- a/lib/mixins/properties-changed.js +++ b/lib/mixins/properties-changed.js @@ -426,7 +426,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 From 0ae14b9c4be19a9beae6da4ec2dada818c0af44d Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Fri, 31 May 2019 16:38:05 -0700 Subject: [PATCH 07/10] Add new mixin annotations, remove GestureEventListeners alias --- lib/mixins/dir-mixin.js | 3 + lib/mixins/disable-upgrade-mixin.js | 3 + lib/mixins/element-mixin.js | 3 + lib/mixins/gesture-event-listeners.js | 95 +++++++++++---------------- lib/mixins/mutable-data.js | 3 + lib/mixins/properties-changed.js | 3 + lib/mixins/properties-mixin.js | 3 + lib/mixins/property-accessors.js | 3 + lib/mixins/property-effects.js | 3 + lib/mixins/strict-binding-parser.js | 3 + lib/mixins/template-stamp.js | 3 + 11 files changed, 69 insertions(+), 56 deletions(-) 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 7cb9e894fa..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) => { /** 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 04dc14fd89..71a4577ff7 100644 --- a/lib/mixins/gesture-event-listeners.js +++ b/lib/mixins/gesture-event-listeners.js @@ -24,65 +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; - }); - -// 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. - */ -const _GestureEventListeners = function(superClass) { - return GestureEventListeners(superClass); -}; + /** + * 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); + } + } + } -export {_GestureEventListeners as GestureEventListeners}; + 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 363138b1ac..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( /** 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 3affb2661b..af8968606a 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 => { 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( /** From 10d43ce8495156b754c751735f3a57981eb1312e Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Mon, 3 Jun 2019 13:54:47 -0700 Subject: [PATCH 08/10] Add some casts for places Closure doesn't understand constructor --- lib/utils/templatize.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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. From 6dfaa5f08435db21a4b1674f1268d8f87bbfa067 Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Thu, 6 Jun 2019 08:44:54 -0700 Subject: [PATCH 09/10] Fix eslint errors. --- lib/elements/dom-bind.js | 1 + lib/mixins/property-effects.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/elements/dom-bind.js b/lib/elements/dom-bind.js index a897a92ab8..33e7293b09 100644 --- a/lib/elements/dom-bind.js +++ b/lib/elements/dom-bind.js @@ -62,6 +62,7 @@ export class DomBind extends domBindBase { this.__children = null; } + /* eslint-disable no-unused-vars */ /** * @override * @param {string} name Name of attribute that changed diff --git a/lib/mixins/property-effects.js b/lib/mixins/property-effects.js index af8968606a..7fd90836d8 100644 --- a/lib/mixins/property-effects.js +++ b/lib/mixins/property-effects.js @@ -1154,7 +1154,7 @@ export const PropertyEffects = dedupingMixin(superClass => { } /** - * @return {!Object} + * @return {!Object} Effect prototype property name map. */ get PROPERTY_EFFECT_TYPES() { return TYPES; From f0fb532d0609cbbbb361c5aba3232f2957a5fa9b Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Thu, 6 Jun 2019 09:42:56 -0700 Subject: [PATCH 10/10] Pin to firefox 66 because of selenium error --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: