Ignore jQuery and duplicates in CommandRegistry::findCommands

Now that jQuery has been patched to add inline listeners and inline
listeners are reported from findCommands, there’s no reason to include
commands based on $.fn.events. Also, we need to ensure the same command
doesn’t get added to the list twice since it could get added by both
inline and selector-based listeners.
This commit is contained in:
Nathan Sobo
2014-11-10 08:48:35 -07:00
parent 0c40a1ef92
commit d48719ab1c

View File

@@ -130,15 +130,18 @@ class CommandRegistry
# * `jQuery` Present if the command was registered with the legacy
# `$::command` method.
findCommands: ({target}) ->
commandNames = new Set
commands = []
currentTarget = target
loop
for commandName, listeners of @selectorBasedListenersByCommandName
for listener in listeners
if currentTarget.webkitMatchesSelector?(listener.selector)
commands.push
name: commandName
displayName: _.humanizeEventName(commandName)
unless commandNames.has(commandName)
commandNames.add(commandName)
commands.push
name: commandName
displayName: _.humanizeEventName(commandName)
break if currentTarget is @rootNode
currentTarget = currentTarget.parentNode
@@ -146,13 +149,9 @@ class CommandRegistry
for name, listeners of @inlineListenersByCommandName
if listeners.has(target)
commands.push({name, displayName: _.humanizeEventName(name)})
for name, displayName of $(target).events() when displayName
commands.push({name, displayName, jQuery: true})
for name, displayName of $(window).events() when displayName
commands.push({name, displayName, jQuery: true})
unless commandNames.has(name)
commandNames.add(name)
commands.push({name, displayName: _.humanizeEventName(name)})
commands