From: Ben Beltran Date: Sat, 21 Apr 2018 08:15:04 +0000 (-0500) Subject: Correctly emit the node on remove X-Git-Tag: 2.1.0^2~3 X-Git-Url: https://git.r.bdr.sh/rbdr/serpentity/commitdiff_plain/b35f7b4b2eb720a3227c512ed14f76747f206ff2?ds=inline;hp=-c Correctly emit the node on remove --- b35f7b4b2eb720a3227c512ed14f76747f206ff2 diff --git a/lib/serpentity/node_collection.js b/lib/serpentity/node_collection.js index 7c2c627..deeb26d 100644 --- a/lib/serpentity/node_collection.js +++ b/lib/serpentity/node_collection.js @@ -59,18 +59,20 @@ const NodeCollection = class NodeCollection extends Events { remove(entity) { let foundIndex = -1; + let foundNode = null; const found = this.nodes.some((node, i) => { if (node.entity === entity) { foundIndex = i; + foundNode = node; return true; } }); if (found) { this.nodes.splice(foundIndex, 1); - this.emit('nodeRemoved', { node }); + this.emit('nodeRemoved', { foundNode }); } return found;