mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
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:
@@ -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 {
|
||||
|
||||
@@ -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}];
|
||||
|
||||
Reference in New Issue
Block a user