fix null doc

This commit is contained in:
negue 2019-07-17 18:51:47 +02:00 committed by GitHub
parent 68ba4dcc65
commit 959e8e36bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,15 +35,19 @@ Gun.chain.open = function(cb, opt, at){
}
var tmp = this, id;
Gun.obj.map(data, function(val, key){
var doc = at || opt.doc;
if (!doc) {
return;
}
if(!(id = Gun.val.link.is(val))){
(at || opt.doc)[key] = val;
doc[key] = val;
return;
}
if(opt.ids[id]){
(at || opt.doc)[key] = opt.ids[id];
doc[key] = opt.ids[id];
return;
}
tmp.get(key).open(opt.any, opt, opt.ids[id] = (at || opt.doc)[key] = {});
tmp.get(key).open(opt.any, opt, opt.ids[id] = doc[key] = {});
});
})
}
}