]> git.r.bdr.sh - rbdr/serpentity/commitdiff
Correctly emit the node on remove
authorBen Beltran <redacted>
Sat, 21 Apr 2018 08:15:04 +0000 (03:15 -0500)
committerBen Beltran <redacted>
Sat, 21 Apr 2018 08:15:04 +0000 (03:15 -0500)
lib/serpentity/node_collection.js

index 7c2c627e13424acf4ca880f6cf90f1be0e964ce5..deeb26deae1dc155ab4e19ade7e382d425548006 100644 (file)
@@ -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;