From c802b8b2f37105e123535fce3d990426f33dfd40 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Thu, 7 Sep 2017 15:02:53 -0700 Subject: [PATCH] Don't have `return /** comment */` lines This breaks espree AST generation with automatic semicolon insertion and becomes ``` return /** comment */ thing; ``` --- lib/legacy/class.html | 3 ++- lib/legacy/legacy-element-mixin.html | 9 ++++++--- lib/legacy/polymer.dom.html | 6 ++++-- lib/mixins/template-stamp.html | 3 ++- lib/utils/flattened-nodes-observer.html | 8 +++++--- lib/utils/gestures.html | 3 ++- lib/utils/templatize.html | 3 ++- 7 files changed, 23 insertions(+), 12 deletions(-) diff --git a/lib/legacy/class.html b/lib/legacy/class.html index f52f042c09..b7377fa7b6 100644 --- a/lib/legacy/class.html +++ b/lib/legacy/class.html @@ -42,7 +42,8 @@ */ function mixinBehaviors(behaviors, klass) { if (!behaviors) { - return /** @type {HTMLElement} */(klass); + klass = /** @type {HTMLElement} */(klass); // eslint-disable-line no-self-assign + return klass; } // NOTE: ensure the bahevior is extending a class with // legacy element api. This is necessary since behaviors expect to be able diff --git a/lib/legacy/legacy-element-mixin.html b/lib/legacy/legacy-element-mixin.html index 84df920ed0..22c0038ad2 100644 --- a/lib/legacy/legacy-element-mixin.html +++ b/lib/legacy/legacy-element-mixin.html @@ -479,7 +479,8 @@ * @return {Array} List of effctive child nodes. */ getEffectiveChildNodes() { - return /** @type {Polymer.DomApi} */ (Polymer.dom(this)).getEffectiveChildNodes(); + const domApi = /** @type {Polymer.DomApi} */(Polymer.dom(this)); + return domApi.getEffectiveChildNodes(); } /** @@ -491,7 +492,8 @@ * @return {Array} List of distributed elements that match selector. */ queryDistributedElements(selector) { - return /** @type {Polymer.DomApi} */ (Polymer.dom(this)).queryDistributedElements(selector); + const domApi = /** @type {Polymer.DomApi} */(Polymer.dom(this)); + return domApi.queryDistributedElements(selector); } /** @@ -581,9 +583,10 @@ * @suppress {invalidCasts} */ getContentChildren(slctr) { - return /** @type {Array} */(this.getContentChildNodes(slctr).filter(function(n) { + let children = /** @type {Array} */(this.getContentChildNodes(slctr).filter(function(n) { return (n.nodeType === Node.ELEMENT_NODE); })); + return children; } /** diff --git a/lib/legacy/polymer.dom.html b/lib/legacy/polymer.dom.html index c15820c430..f86596b1e9 100644 --- a/lib/legacy/polymer.dom.html +++ b/lib/legacy/polymer.dom.html @@ -205,7 +205,8 @@ let name = properties[i]; Object.defineProperty(proto, name, { get: function() { - return /** @type {DomApi} */ (this).node[name]; + const domApi = /** @type {DomApi} */(this); + return domApi.node[name]; }, configurable: true }); @@ -217,7 +218,8 @@ let name = properties[i]; Object.defineProperty(proto, name, { get: function() { - return /** @type {DomApi} */ (this).node[name]; + const domApi = /** @type {DomApi} */(this); + return domApi.node[name]; }, set: function(value) { /** @type {DomApi} */ (this).node[name] = value; diff --git a/lib/mixins/template-stamp.html b/lib/mixins/template-stamp.html index ffbadc4ac4..e20823634d 100644 --- a/lib/mixins/template-stamp.html +++ b/lib/mixins/template-stamp.html @@ -429,7 +429,8 @@ applyTemplateContent(this, node, info); applyEventListener(this, node, info); } - return /** @type {!StampedTemplate} */(dom); + dom = /** @type {!StampedTemplate} */(dom); // eslint-disable-line no-self-assign + return dom; } /** diff --git a/lib/utils/flattened-nodes-observer.html b/lib/utils/flattened-nodes-observer.html index 78742e3578..5ea0085a4e 100644 --- a/lib/utils/flattened-nodes-observer.html +++ b/lib/utils/flattened-nodes-observer.html @@ -64,11 +64,13 @@ */ static getFlattenedNodes(node) { if (isSlot(node)) { - return /** @type {HTMLSlotElement} */ (node).assignedNodes({flatten: true}); + node = /** @type {HTMLSlotElement} */(node); // eslint-disable-line no-self-assign + return node.assignedNodes({flatten: true}); } else { - return Array.from(node.childNodes).map(node => { + return Array.from(node.childNodes).map((node) => { if (isSlot(node)) { - return /** @type {HTMLSlotElement} */ (node).assignedNodes({flatten: true}); + node = /** @type {HTMLSlotElement} */(node); // eslint-disable-line no-self-assign + return node.assignedNodes({flatten: true}); } else { return [node]; } diff --git a/lib/utils/gestures.html b/lib/utils/gestures.html index 451433a639..ca78f2d2af 100644 --- a/lib/utils/gestures.html +++ b/lib/utils/gestures.html @@ -289,7 +289,8 @@ _findOriginalTarget: function(ev) { // shadowdom if (ev.composedPath) { - return /** @type {EventTarget} */(ev.composedPath()[0]); + const target = /** @type {EventTarget} */(ev.composedPath()[0]); + return target; } // shadydom return ev.target; diff --git a/lib/utils/templatize.html b/lib/utils/templatize.html index b146c67510..4fc220305f 100644 --- a/lib/utils/templatize.html +++ b/lib/utils/templatize.html @@ -466,7 +466,8 @@ klass.prototype.__dataHost = template; klass.prototype.__templatizeOwner = owner; klass.prototype.__hostProps = templateInfo.hostProps; - return /** @type {function(new:TemplateInstanceBase)} */(klass); + klass = /** @type {function(new:TemplateInstanceBase)} */(klass); //eslint-disable-line no-self-assign + return klass; }, /**