Skip to content

Commit

Permalink
fix: purge instanceof Array from the codebase (#750)
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 authored Oct 24, 2020
1 parent 97d3f16 commit c57effa
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 @@ -63,7 +63,7 @@ class Configurator {
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') {
Expand Down Expand Up @@ -588,7 +588,7 @@ class Configurator {

// if needed we must go deeper into the object.
if (show === false) {
if (!(item instanceof Array) && typeof item !== 'string' && typeof item !== 'boolean' && item instanceof Object) {
if (!Array.isArray(item) && typeof item !== 'string' && typeof item !== 'boolean' && item instanceof Object) {
this.allowCreation = false;
show = this._handleObject(item, newPath, true);
this.allowCreation = checkOnly === false;
Expand All @@ -600,7 +600,7 @@ class Configurator {
visibleInSet = true;
let value = this._getValue(newPath);

if (item instanceof Array) {
if (Array.isArray(item)) {
this._handleArray(item, value, newPath);
}
else if (typeof item === 'string') {
Expand Down
2 changes: 1 addition & 1 deletion lib/timeline/Timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export default class Timeline extends Core {
}
else {
// If groups is array, turn to DataSet & build dataview from that
if (groups instanceof Array) groups = new DataSet(groups);
if (Array.isArray(groups)) groups = new DataSet(groups);

newDataSet = new DataView(groups,{filter});
}
Expand Down

0 comments on commit c57effa

Please sign in to comment.