From b35f7b4b2eb720a3227c512ed14f76747f206ff2 Mon Sep 17 00:00:00 2001 From: Ben Beltran Date: Sat, 21 Apr 2018 03:15:04 -0500 Subject: Correctly emit the node on remove --- lib/serpentity/node_collection.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') 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; -- cgit