mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Return whether a dispatched command matched a listener
This commit is contained in:
@@ -152,6 +152,7 @@ class CommandRegistry
|
||||
handleCommandEvent: (event) =>
|
||||
propagationStopped = false
|
||||
immediatePropagationStopped = false
|
||||
matched = false
|
||||
currentTarget = event.target
|
||||
|
||||
syntheticEvent = Object.create event,
|
||||
@@ -169,6 +170,8 @@ class CommandRegistry
|
||||
.filter (listener) -> currentTarget.webkitMatchesSelector(listener.selector)
|
||||
.sort (a, b) -> a.compare(b)
|
||||
|
||||
matched = true if matchingListeners.length > 0
|
||||
|
||||
for listener in matchingListeners
|
||||
break if immediatePropagationStopped
|
||||
listener.callback.call(currentTarget, syntheticEvent)
|
||||
@@ -178,6 +181,8 @@ class CommandRegistry
|
||||
break if propagationStopped
|
||||
currentTarget = currentTarget.parentNode
|
||||
|
||||
matched
|
||||
|
||||
class CommandListener
|
||||
constructor: (@selector, @callback) ->
|
||||
@specificity = (SpecificityCache[@selector] ?= specificity(@selector))
|
||||
|
||||
Reference in New Issue
Block a user