From 109754b34c5cbfd40f3d2ade062ac5c3a3e922d3 Mon Sep 17 00:00:00 2001 From: Zachariah Brown Date: Thu, 2 Feb 2017 14:25:46 -0500 Subject: [PATCH] Fixes instanceof Object statements for objects from other windows and iFrames. (#2631) * Replaces instanceof Object checks with typeof to prevent cross tab issues. * Adds missing space. --- lib/DataSet.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/DataSet.js b/lib/DataSet.js index 8ebee256..ca1ef887 100644 --- a/lib/DataSet.js +++ b/lib/DataSet.js @@ -211,7 +211,7 @@ DataSet.prototype.add = function (data, senderId) { addedIds.push(id); } } - else if (data instanceof Object) { + else if (data && typeof data === 'object') { // Single item id = me._addItem(data); addedIds.push(id); @@ -261,14 +261,14 @@ DataSet.prototype.update = function (data, senderId) { if (Array.isArray(data)) { // Array for (var i = 0, len = data.length; i < len; i++) { - if (data[i] instanceof Object){ + if (data[i] && typeof data[i] === 'object'){ addOrUpdate(data[i]); } else { console.warn('Ignoring input item, which is not an object at index ' + i); } } } - else if (data instanceof Object) { + else if (data && typeof data === 'object') { // Single item addOrUpdate(data); } @@ -707,7 +707,7 @@ DataSet.prototype._remove = function (id) { if (util.isNumber(id) || util.isString(id)) { ident = id; } - else if (id instanceof Object) { + else if (id && typeof id === 'object') { ident = id[this._fieldId]; // look for the identifier field using _fieldId }