From f8724eb0404eb65ed5d624b97ac721ce0f3f9f2c Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 28 Jul 2017 21:26:44 +0200 Subject: [PATCH] Fix undefined check --- Chart/ChartAbstract.js | 20 ++++++++++---------- Module/ModuleManager.js | 2 +- Utils/oLib.js | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Chart/ChartAbstract.js b/Chart/ChartAbstract.js index c75eb69..53be9dd 100644 --- a/Chart/ChartAbstract.js +++ b/Chart/ChartAbstract.js @@ -247,7 +247,7 @@ { let self = this; - if (this.legend !== undefined && this.legend.visible) { + if (typeof this.legend !== 'undefined' && this.legend.visible) { dataPointEnter.append("text").attr('class', 'dataPoint-name'); dataPoint.select("text.dataPoint-name").attr("x", this.dimension.width @@ -340,7 +340,7 @@ let temp, pos = 0, topmargin = 0; /* No subtitle without title */ - if (this.subtitle !== undefined && this.subtitle.text !== '' && this.subtitle.visible && this.title !== undefined && this.title.text !== '' && this.title.visible) { + if (typeof this.subtitle !== 'undefined' && this.subtitle.text !== '' && this.subtitle.visible && typeof this.title !== 'undefined' && this.title.text !== '' && this.title.visible) { pos = this.calculateHorizontalPosition(this.subtitle.position); temp = svg.append("text") @@ -361,7 +361,7 @@ } } - if (this.title !== undefined && this.title.text !== '' && this.title.visible) { + if (typeof this.title !== 'undefined' && this.title.text !== '' && this.title.visible) { pos = this.calculateHorizontalPosition(this.title.position); temp = svg.append("text") @@ -379,7 +379,7 @@ } } - if (this.footer !== undefined && this.footer.text !== '' && this.footer.visible) { + if (typeof this.footer !== 'undefined' && this.footer.text !== '' && this.footer.visible) { let spacer = 0; // if no x axis available an element less will be drawn and the footer @@ -424,7 +424,7 @@ - this.margin.bottom ); - if (this.axis.x !== undefined && this.axis.x.visible) { + if (typeof this.axis.x !== 'undefined' && this.axis.x.visible) { temp = svg.append("g") .attr("class", "x axis") .attr("transform", "translate(0," + ( @@ -451,7 +451,7 @@ } } - if (this.axis.y !== undefined && this.axis.y.visible) { + if (typeof this.axis.y !== 'undefined' && this.axis.y.visible) { temp = svg.append("g") .attr("class", "y axis") .attr("transform", "translate(0,0)") @@ -475,25 +475,25 @@ } } - if (this.axis.x2 !== undefined) { + if (typeof this.axis.x2 !== 'undefined') { } - if (this.axis.y2 !== undefined) { + if (typeof this.axis.y2 !== 'undefined') { } }; jsOMS.Chart.ChartAbstract.prototype.drawGrid = function (svg, xGrid, yGrid) { - if (this.grid.x !== undefined && this.grid.x.visible) { + if (typeof this.grid.x !== 'undefined' && this.grid.x.visible) { svg.append("g") .attr("class", "x grid") .attr("transform", "translate(0," + (this.dimension.height - this.margin.top - this.margin.bottom) + ")") .call(xGrid); } - if (this.grid.y !== undefined && this.grid.y.visible) { + if (typeof this.grid.y !== 'undefined' && this.grid.y.visible) { svg.append("g") .attr("class", "y grid") .call(yGrid); diff --git a/Module/ModuleManager.js b/Module/ModuleManager.js index a41cc55..7748d75 100644 --- a/Module/ModuleManager.js +++ b/Module/ModuleManager.js @@ -37,7 +37,7 @@ */ jsOMS.Module.ModuleManager.prototype.get = function (module) { - if (this.modules[module] === undefined) { + if (typeof this.modules[module] === 'undefined') { this.modules[module] = jsOMS.Module.ModuleFactory.getInstance(module, this.app); } diff --git a/Utils/oLib.js b/Utils/oLib.js index dc7974e..00f6f9f 100644 --- a/Utils/oLib.js +++ b/Utils/oLib.js @@ -117,7 +117,7 @@ */ jsOMS.hasClass = function (ele, cls) { - return ele !== undefined && ele !== null && ele.className !== undefined && ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)')); + return typeof ele !== 'undefined' && ele !== null && typeof ele.className !== 'undefined' && ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)')); }; /**