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'`.
This commit is contained in:
1 parent
b6fbbb353a
commit
b794a4672f
2 files changed
+5
-4
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user