From cfeb46ef62f5a848d955ba2f576655826f7d2584 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Thu, 24 Jul 2014 20:02:00 -0700 Subject: [PATCH] Prefer Array.isArray() to "instanceof Array" tests --- examples/multidom/index.js | 2 +- src/dom-driver.js | 2 +- src/minimart.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/multidom/index.js b/examples/multidom/index.js index 852c47a..e1fc398 100644 --- a/examples/multidom/index.js +++ b/examples/multidom/index.js @@ -33,7 +33,7 @@ $(document).ready(function () { console.log(JSON.stringify(e)); if (e.type === "message" && e.message[0] === "broker" - && e.message[2] instanceof Array + && Array.isArray(e.message[2]) && e.message[2][0] === "multidom" && e.message[2][1] === "jQuery") { diff --git a/src/dom-driver.js b/src/dom-driver.js index 6f065f2..39dcf1f 100644 --- a/src/dom-driver.js +++ b/src/dom-driver.js @@ -69,7 +69,7 @@ DOMFragment.prototype.handleEvent = function (e) { }; function isAttributes(x) { - return (x instanceof Array) && ((x.length === 0) || (x[0] instanceof Array)); + return Array.isArray(x) && ((x.length === 0) || Array.isArray(x[0])); } DOMFragment.prototype.interpretSpec = function (spec) { diff --git a/src/minimart.js b/src/minimart.js index d91572a..dd6c9fc 100644 --- a/src/minimart.js +++ b/src/minimart.js @@ -355,7 +355,7 @@ World.prototype.textProcessTree = function (ownPid) { var lines = []; function dumpProcess(prefix, pid, p) { - if (p instanceof Array) { + if (Array.isArray(p)) { lines.push(prefix + '--+ ' + pid); for (var i = 0; i < p.length; i++) { dumpProcess(prefix + ' |', p[i][0], p[i][1]);