Browse Source

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.
runTests
Zachariah Brown 7 years ago
committed by yotamberk
parent
commit
109754b34c
1 changed files with 4 additions and 4 deletions
  1. +4
    -4
      lib/DataSet.js

+ 4
- 4
lib/DataSet.js View File

@ -211,7 +211,7 @@ DataSet.prototype.add = function (data, senderId) {
addedIds.push(id); addedIds.push(id);
} }
} }
else if (data instanceof Object) {
else if (data && typeof data === 'object') {
// Single item // Single item
id = me._addItem(data); id = me._addItem(data);
addedIds.push(id); addedIds.push(id);
@ -261,14 +261,14 @@ DataSet.prototype.update = function (data, senderId) {
if (Array.isArray(data)) { if (Array.isArray(data)) {
// Array // Array
for (var i = 0, len = data.length; i < len; i++) { 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]); addOrUpdate(data[i]);
} else { } else {
console.warn('Ignoring input item, which is not an object at index ' + i); 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 // Single item
addOrUpdate(data); addOrUpdate(data);
} }
@ -707,7 +707,7 @@ DataSet.prototype._remove = function (id) {
if (util.isNumber(id) || util.isString(id)) { if (util.isNumber(id) || util.isString(id)) {
ident = 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 ident = id[this._fieldId]; // look for the identifier field using _fieldId
} }

Loading…
Cancel
Save