Skip to content

Commit

Permalink
Bug fixed: Setting an empty string or "null" to defaultElement may ca…
Browse files Browse the repository at this point in the history
…use a JavaScript error (#51)
  • Loading branch information
erwanlfrt authored Mar 2, 2022
1 parent 1a59d0b commit 4dd23c6
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions spatial_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,17 +449,21 @@
}

function parseSelector(selector) {
var result;
if ($) {
result = $(selector).get();
} else if (typeof selector === 'string') {
result = [].slice.call(document.querySelectorAll(selector));
} else if (typeof selector === 'object' && selector.length) {
result = [].slice.call(selector);
} else if (typeof selector === 'object' && selector.nodeType === 1) {
result = [selector];
} else {
result = [];
var result = [];
try {
if (selector) {
if ($) {
result = $(selector).get();
} else if (typeof selector === 'string') {
result = [].slice.call(document.querySelectorAll(selector));
} else if (typeof selector === 'object' && selector.length) {
result = [].slice.call(selector);
} else if (typeof selector === 'object' && selector.nodeType === 1) {
result = [selector];
}
}
} catch (err) {
console.error(err);
}
return result;
}
Expand Down

0 comments on commit 4dd23c6

Please sign in to comment.