From b794a4672f1eb97604af7d114ffa28e65b24d7f5 Mon Sep 17 00:00:00 2001 From: Mathias Rangel Wulff Date: Mon, 12 Sep 2016 09:43:46 +0000 Subject: [PATCH] Correct check for undefined variable The code was comparing the result of `typeof` with a variable named `undefined`. As typeof returns a string it should compare to `'undefined'`. --- AUTHORS.md | 1 + src/octoprint/static/js/app/helpers.js | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index f26b59a1..13a7552e 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -71,6 +71,7 @@ date of first contribution): * ["MirceaDan"](https://github.com/ByReaL) * [Ovidiu Hossu](https://github.com/MoonshineSG) * [Eyck Jentzsch](https://github.com/eyck) + * [Mathias Rangel Wulff](https://github.com/mathiasrw) OctoPrint started off as a fork of [Cura](https://github.com/daid/Cura) by [Daid Braam](https://github.com/daid). Parts of its communication layer and diff --git a/src/octoprint/static/js/app/helpers.js b/src/octoprint/static/js/app/helpers.js index d7a186b9..aa2a6550 100644 --- a/src/octoprint/static/js/app/helpers.js +++ b/src/octoprint/static/js/app/helpers.js @@ -242,7 +242,7 @@ function ItemListHelper(listType, supportedSorting, supportedFilters, defaultSor // determine comparator var comparator = undefined; var currentSorting = self.currentSorting(); - if (typeof currentSorting !== undefined && typeof self.supportedSorting[currentSorting] !== undefined) { + if (typeof currentSorting !== 'undefined' && typeof self.supportedSorting[currentSorting] !== 'undefined') { comparator = self.supportedSorting[currentSorting]; } @@ -252,17 +252,17 @@ function ItemListHelper(listType, supportedSorting, supportedFilters, defaultSor // filter if necessary var filters = self.currentFilters(); _.each(filters, function(filter) { - if (typeof filter !== undefined && typeof supportedFilters[filter] !== undefined) + if (typeof filter !== 'undefined' && typeof supportedFilters[filter] !== 'undefined') result = _.filter(result, supportedFilters[filter]); }); // search if necessary - if (typeof self.searchFunction !== undefined && self.searchFunction) { + if (typeof self.searchFunction !== 'undefined' && self.searchFunction) { result = _.filter(result, self.searchFunction); } // sort if necessary - if (typeof comparator !== undefined) + if (typeof comparator !== 'undefined') result.sort(comparator); // set result list