Include all inline commands on the bubble path in ::findCommands

This commit is contained in:
Nathan Sobo
2014-11-10 09:37:19 -07:00
parent aa46e3d26f
commit 832e7113f7
2 changed files with 10 additions and 12 deletions

View File

@@ -156,16 +156,16 @@ describe "CommandRegistry", ->
registry.add '.grandchild.no-match', 'namespace:command-4', ->
registry.add grandchild, 'namespace:inline-command-1', ->
registry.add child, 'namespace:inlined-command-2', ->
registry.add child, 'namespace:inline-command-2', ->
commands = registry.findCommands(target: grandchild)
nonJqueryCommands = _.reject commands, (cmd) -> cmd.jQuery
expect(nonJqueryCommands).toEqual [
{name: 'namespace:inline-command-1', displayName: 'Namespace: Inline Command 1'}
{name: 'namespace:command-3', displayName: 'Namespace: Command 3'}
{name: 'namespace:inline-command-2', displayName: 'Namespace: Inline Command 2'}
{name: 'namespace:command-2', displayName: 'Namespace: Command 2'}
{name: 'namespace:command-1', displayName: 'Namespace: Command 1'}
{name: 'namespace:inline-command-1', displayName: 'Namespace: Inline Command 1'}
]
describe "::dispatch(target, commandName)", ->

View File

@@ -134,6 +134,11 @@ class CommandRegistry
commands = []
currentTarget = target
loop
for name, listeners of @inlineListenersByCommandName
if listeners.has(currentTarget) and not commandNames.has(name)
commandNames.add(name)
commands.push({name, displayName: _.humanizeEventName(name)})
for commandName, listeners of @selectorBasedListenersByCommandName
for listener in listeners
if currentTarget.webkitMatchesSelector?(listener.selector)
@@ -143,15 +148,8 @@ class CommandRegistry
name: commandName
displayName: _.humanizeEventName(commandName)
break if currentTarget is @rootNode
currentTarget = currentTarget.parentNode
break unless currentTarget?
for name, listeners of @inlineListenersByCommandName
if listeners.has(target)
unless commandNames.has(name)
commandNames.add(name)
commands.push({name, displayName: _.humanizeEventName(name)})
break if currentTarget is window
currentTarget = currentTarget.parentNode ? window
commands