Include all inline commands on the bubble path in ::findCommands
Esse commit está contido em:
@@ -156,16 +156,16 @@ describe "CommandRegistry", ->
|
|||||||
registry.add '.grandchild.no-match', 'namespace:command-4', ->
|
registry.add '.grandchild.no-match', 'namespace:command-4', ->
|
||||||
|
|
||||||
registry.add grandchild, 'namespace:inline-command-1', ->
|
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)
|
commands = registry.findCommands(target: grandchild)
|
||||||
nonJqueryCommands = _.reject commands, (cmd) -> cmd.jQuery
|
nonJqueryCommands = _.reject commands, (cmd) -> cmd.jQuery
|
||||||
|
|
||||||
expect(nonJqueryCommands).toEqual [
|
expect(nonJqueryCommands).toEqual [
|
||||||
|
{name: 'namespace:inline-command-1', displayName: 'Namespace: Inline Command 1'}
|
||||||
{name: 'namespace:command-3', displayName: 'Namespace: Command 3'}
|
{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-2', displayName: 'Namespace: Command 2'}
|
||||||
{name: 'namespace:command-1', displayName: 'Namespace: Command 1'}
|
{name: 'namespace:command-1', displayName: 'Namespace: Command 1'}
|
||||||
{name: 'namespace:inline-command-1', displayName: 'Namespace: Inline Command 1'}
|
|
||||||
]
|
]
|
||||||
|
|
||||||
describe "::dispatch(target, commandName)", ->
|
describe "::dispatch(target, commandName)", ->
|
||||||
|
|||||||
@@ -134,6 +134,11 @@ class CommandRegistry
|
|||||||
commands = []
|
commands = []
|
||||||
currentTarget = target
|
currentTarget = target
|
||||||
loop
|
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 commandName, listeners of @selectorBasedListenersByCommandName
|
||||||
for listener in listeners
|
for listener in listeners
|
||||||
if currentTarget.webkitMatchesSelector?(listener.selector)
|
if currentTarget.webkitMatchesSelector?(listener.selector)
|
||||||
@@ -143,15 +148,8 @@ class CommandRegistry
|
|||||||
name: commandName
|
name: commandName
|
||||||
displayName: _.humanizeEventName(commandName)
|
displayName: _.humanizeEventName(commandName)
|
||||||
|
|
||||||
break if currentTarget is @rootNode
|
break if currentTarget is window
|
||||||
currentTarget = currentTarget.parentNode
|
currentTarget = currentTarget.parentNode ? window
|
||||||
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)})
|
|
||||||
|
|
||||||
commands
|
commands
|
||||||
|
|
||||||
|
|||||||
Referência em uma Nova Issue
Bloquear um usuário