Handle .stopPropagation() being called on command events

This commit is contained in:
Nathan Sobo
2014-09-05 09:10:22 -06:00
parent 5eb22520f1
commit fbaf956e1f
2 changed files with 15 additions and 1 deletions

View File

@@ -16,11 +16,14 @@ class CommandRegistry
@listenersByCommandName[commandName].push(new CommandListener(selector, callback))
dispatchCommand: (event) =>
propagationStopped = false
currentTarget = event.target
syntheticEvent = Object.create event,
eventPhase: value: Event.BUBBLING_PHASE
currentTarget: get: -> currentTarget
stopPropagation: value: -> propagationStopped = true
currentTarget = event.target
loop
matchingListeners =
@listenersByCommandName[event.type]
@@ -30,6 +33,7 @@ class CommandRegistry
for listener in matchingListeners
listener.callback.call(currentTarget, syntheticEvent)
break if propagationStopped
break if currentTarget is @rootNode
currentTarget = currentTarget.parentNode