Skip to content

Commit

Permalink
fix: purge instanceof Array from the codebase (#1131)
Browse files Browse the repository at this point in the history
Array.isArray works with arrays that came from other contexts like web
workers, instanceof Array wouldn't consider such array to be an array
even though it is perfectly valid array.
  • Loading branch information
Thomaash committed Oct 24, 2020
1 parent 181c85b commit 3b0a2b7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/shared/Configurator.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Configurator {
let enabled = true;
if (typeof options === "string") {
this.options.filter = options;
} else if (options instanceof Array) {
} else if (Array.isArray(options)) {
this.options.filter = options.join();
} else if (typeof options === "object") {
if (options == null) {
Expand Down Expand Up @@ -616,7 +616,7 @@ class Configurator {
// if needed we must go deeper into the object.
if (show === false) {
if (
!(item instanceof Array) &&
!Array.isArray(item) &&
typeof item !== "string" &&
typeof item !== "boolean" &&
item instanceof Object
Expand All @@ -632,7 +632,7 @@ class Configurator {
visibleInSet = true;
const value = this._getValue(newPath);

if (item instanceof Array) {
if (Array.isArray(item)) {
this._handleArray(item, value, newPath);
} else if (typeof item === "string") {
this._makeTextInput(item, value, newPath);
Expand Down
2 changes: 1 addition & 1 deletion test/Network.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function merge(a, b) {
* Load legacy-style (i.e. not module) javascript files into the given context.
*/
function include(list, context) {
if (!(list instanceof Array)) {
if (!Array.isArray(list)) {
list = [list];
}

Expand Down

0 comments on commit 3b0a2b7

Please sign in to comment.