From 8b8b1eb9f2d007f497b44f0cc43fda261d10344b Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Sun, 1 Sep 2013 08:49:16 -0400 Subject: [PATCH] compiles warning-free! --- dygraph.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/dygraph.js b/dygraph.js index 025dfe1..50524b2 100644 --- a/dygraph.js +++ b/dygraph.js @@ -1775,6 +1775,7 @@ Dygraph.prototype.findClosestRow = function(domX) { * @param {number} domX graph-relative DOM X coordinate * @param {number} domY graph-relative DOM Y coordinate * @return {{row: number, seriesName: string, point: !Dygraph.PointType}} + * TODO(danvk): PointType already contains seriesName * @private */ Dygraph.prototype.findClosestPoint = function(domX, domY) { @@ -1796,11 +1797,14 @@ Dygraph.prototype.findClosestPoint = function(domX, domY) { } } } - var name = this.layout_.setNames[closestSeries]; + + // The error cases (-1, null) can't happen because of checks in mouseMove_. + // They're here for the Closure Compiler. + var name = this.layout_.setNames[closestSeries] || ""; return { - row: closestRow, + row: closestRow !== undefined ? closestRow : -1, seriesName: name, - point: closestPoint + point: closestPoint || /**@type{!Dygraph.PointType}*/(null) }; }; @@ -1855,10 +1859,13 @@ Dygraph.prototype.findStackedPoint = function(domX, domY) { } } var name = this.layout_.setNames[closestSeries]; + + // The "point: null" case is here for the Closure Compiler. + // It can't actually happen because of checks in mouseMove_. return { row: row, seriesName: name, - point: closestPoint + point: closestPoint || /**@type{!Dygraph.PointType}*/(null) }; }; @@ -3281,7 +3288,7 @@ Dygraph.prototype.start_ = function() { } if (Dygraph.isArrayLike(data)) { - this.rawData_ = this.parseArray_(data); + this.rawData_ = this.parseArray_(/**@type{!Array}*/(data)); this.predraw_(); } else if (typeof data == 'object' && typeof data.getColumnRange == 'function') { -- 2.7.4