From 6d55bab4c87c244af7515fbe4b54b615b56cf4a8 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Wed, 24 Sep 2014 15:26:38 -0600 Subject: [PATCH] Fix CommandRegistry::get/restoreSnapshot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I didn’t realize that deepClone was not handling functions correctly. I’ve implemented clone manually to the exact depth needed instead. --- src/command-registry.coffee | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/command-registry.coffee b/src/command-registry.coffee index abeaa155e..c97534398 100644 --- a/src/command-registry.coffee +++ b/src/command-registry.coffee @@ -152,12 +152,17 @@ class CommandRegistry @handleCommandEvent(eventWithTarget) getSnapshot: -> - _.deepClone(@listenersByCommandName) + snapshot = {} + for commandName, listeners of @listenersByCommandName + snapshot[commandName] = listeners.slice() + snapshot restoreSnapshot: (snapshot) -> rootNode = @getRootNode() @setRootNode(null) # clear listeners for current commands - @listenersByCommandName = _.deepClone(snapshot) + @listenersByCommandName = {} + for commandName, listeners of snapshot + @listenersByCommandName[commandName] = listeners.slice() @setRootNode(rootNode) # restore listeners for commands in snapshot handleCommandEvent: (originalEvent) =>