Merge pull request #7851 from rodrigopalhares/7850-observer-sequence_null_values

observe-sequence: Bug, array with null values. fixes #7850
This commit is contained in:
Ben Newman
2016-10-11 18:59:26 -04:00
committed by GitHub
2 changed files with 12 additions and 2 deletions

View File

@@ -289,7 +289,8 @@ seqChangedToArray = function (lastSeqArray, array, callbacks) {
id = "-" + item;
} else if (typeof item === 'number' ||
typeof item === 'boolean' ||
item === undefined) {
item === undefined ||
item === null) {
id = item;
} else if (typeof item === 'object') {
id = (item && ('_id' in item)) ? item._id : index;
@@ -300,7 +301,7 @@ seqChangedToArray = function (lastSeqArray, array, callbacks) {
var idString = idStringify(id);
if (idsUsed[idString]) {
if (typeof item === 'object' && '_id' in item)
if (item && typeof item === 'object' && '_id' in item)
warn("duplicate id " + id + " in", array);
id = Random.id();
} else {

View File

@@ -177,6 +177,15 @@ Tinytest.add('observe-sequence - array to other array, strings', function (test)
]);
});
Tinytest.add('observe-sequence - bug #7850 array with null values', function (test) {
runOneObserveSequenceTestCase(test, function () {
return [1, null];
}, function () {}, [
{addedAt: [1, 1, 0, null]},
{addedAt: [null, null, 1, null]}
]);
});
Tinytest.add('observe-sequence - array to other array, objects without ids', function (test) {
var dep = new Tracker.Dependency;
var seq = [{foo: 1}, {bar: 2}];