Skip to content

Commit

Permalink
fix #320 for @leemuro
Browse files Browse the repository at this point in the history
  • Loading branch information
amark committed Feb 21, 2017
1 parent 8aa649e commit a700afb
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
4 changes: 2 additions & 2 deletions gun.js
Original file line number Diff line number Diff line change
Expand Up @@ -1874,7 +1874,7 @@
if(u === data){
return;
}
if(data[rel._] && (tmp = rel.is(data))){
if(data && data[rel._] && (tmp = rel.is(data))){
tmp = (cat.root.get(tmp)._);
if(u === tmp.put){
return;
Expand Down Expand Up @@ -1924,7 +1924,7 @@
if(u === data){
return;
}
if(data[rel._] && (tmp = rel.is(data))){
if(data && data[rel._] && (tmp = rel.is(data))){
tmp = (cat.root.get(tmp)._);
if(u === tmp.put){
return;
Expand Down
2 changes: 1 addition & 1 deletion gun.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gun",
"version": "0.6.2",
"version": "0.6.3",
"description": "Graph engine",
"main": "index.js",
"browser": "gun.min.js",
Expand Down
4 changes: 2 additions & 2 deletions src/on.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function ok(at, ev){ var opt = this;
if(u === data){
return;
}
if(data[rel._] && (tmp = rel.is(data))){
if(data && data[rel._] && (tmp = rel.is(data))){
tmp = (cat.root.get(tmp)._);
if(u === tmp.put){
return;
Expand Down Expand Up @@ -79,7 +79,7 @@ function val(at, ev, to){
if(u === data){
return;
}
if(data[rel._] && (tmp = rel.is(data))){
if(data && data[rel._] && (tmp = rel.is(data))){
tmp = (cat.root.get(tmp)._);
if(u === tmp.put){
return;
Expand Down
19 changes: 19 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3437,6 +3437,25 @@ describe('Gun', function(){
done.last = true;
},300);
});

it('check null on map', function(done){
var list = gun.get('myList');
list.map(function(value, id){
if("hello world" === value){
done.one = true;
}
if(null === value){
done.two = true;
}
if(done.one && done.two){
if(done.c){ return } done.c = 1;
done();
}
});
list.path('message').put('hello world'); // outputs "message: hello world"
list.path('message').put(null); // throws Uncaught TypeError: Cannot read property '#' of null
});

return;
it.only('Custom extensions are chainable', function(done){
Gun.chain.filter = function(filter){
Expand Down

1 comment on commit a700afb

@leemuro
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I see why it was throwing without the extra check on data. Thanks for the quick fix again.

Please sign in to comment.