From 2195b0e9d024b72737561044eb4e3c4a9c34b9e4 Mon Sep 17 00:00:00 2001 From: Mark Nadal Date: Wed, 17 Jun 2015 14:05:40 -0700 Subject: [PATCH] no false positive null emit FIXED with test --- gun.js | 3 ++- test/common.js | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/gun.js b/gun.js index 87afb441..2ed57fc9 100644 --- a/gun.js +++ b/gun.js @@ -297,7 +297,8 @@ if(err){ return cb.call(gun, err, data) } if(!data){ if(ctx.soul){ return } - return cb.call(gun, null, null), gun._.at('null').emit() + cb.call(gun, null, null); + return gun._.at('null').emit(); } if(ctx.soul = Gun.is.soul.on(data)){ gun._.at('soul').emit({soul: ctx.soul}); diff --git a/test/common.js b/test/common.js index 942558ce..9a269cce 100644 --- a/test/common.js +++ b/test/common.js @@ -1321,5 +1321,25 @@ describe('Gun', function(){ done(); }, 'qwertyasdfzxcv'); }); + + it('no false positive null emit', function(done){ + var gun = Gun({hooks: {get: function(key, cb){ + cb(null, {_: {'#': soul, '>': {'a': 0}}, + 'a': 'b' + }); + cb(null, {_: {'#': soul }}); + cb(); // false trigger! + }}}), soul = Gun.text.random(); + + gun.get('me').not(function(){ + done.fail = true; + }).val(function(val){ + setTimeout(function(){ + expect(val.a).to.be('b'); + expect(done.fail).to.not.be.ok(); + done(); + },5); + }); + }); }); }); \ No newline at end of file