Skip to content

Commit

Permalink
Merge pull request #4837 from Polymer/no-cast-in-return
Browse files Browse the repository at this point in the history
No cast in return
  • Loading branch information
Steve Orvell authored Sep 13, 2017
2 parents 4a2d427 + f6f0a3b commit 21ff471
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 21 deletions.
3 changes: 2 additions & 1 deletion lib/legacy/class.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 behavior is extending a class with
// legacy element api. This is necessary since behaviors expect to be able
Expand Down
9 changes: 6 additions & 3 deletions lib/legacy/legacy-element-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,8 @@
* @return {Array<Node>} List of effective child nodes.
*/
getEffectiveChildNodes() {
return /** @type {Polymer.DomApi} */ (Polymer.dom(this)).getEffectiveChildNodes();
const domApi = /** @type {Polymer.DomApi} */(Polymer.dom(this));
return domApi.getEffectiveChildNodes();
}

/**
Expand All @@ -491,7 +492,8 @@
* @return {Array<Node>} 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);
}

/**
Expand Down Expand Up @@ -581,9 +583,10 @@
* @suppress {invalidCasts}
*/
getContentChildren(slctr) {
return /** @type {Array<HTMLElement>} */(this.getContentChildNodes(slctr).filter(function(n) {
let children = /** @type {Array<HTMLElement>} */(this.getContentChildNodes(slctr).filter(function(n) {
return (n.nodeType === Node.ELEMENT_NODE);
}));
return children;
}

/**
Expand Down
5 changes: 2 additions & 3 deletions lib/legacy/mutable-data-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
'use strict';

let mutablePropertyChange;
(
/** @suppress {missingProperties} */
function() {
/** @suppress {missingProperties} */
(() => {
mutablePropertyChange = Polymer.MutableData._mutablePropertyChange;
})();

Expand Down
6 changes: 4 additions & 2 deletions lib/legacy/polymer.dom.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand All @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions lib/mixins/property-accessors.html
Original file line number Diff line number Diff line change
Expand Up @@ -605,12 +605,8 @@
* @protected
*/
_shouldPropertyChange(property, value, old) {
return (
// Strict equality check
(old !== value &&
// This ensures (old==NaN, value==NaN) always returns false
(old === old || value === value))
);
// check equality, and ensure (old == NaN, value == NaN) always returns false
return old !== value && (old === old || value === value);
}

}
Expand Down
3 changes: 2 additions & 1 deletion lib/mixins/template-stamp.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
8 changes: 5 additions & 3 deletions lib/utils/flattened-nodes-observer.html
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/gestures.html
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,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;
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/templatize.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},

/**
Expand Down

0 comments on commit 21ff471

Please sign in to comment.