mirror of
https://github.com/atom/atom.git
synced 2026-02-08 21:55:05 -05:00
Key binding selectors match events on descendants
This commit is contained in:
committed by
Corey Johnson & Nathan Sobo
parent
18e614e88d
commit
9c98e971fc
@@ -15,7 +15,7 @@ class BindingSet
|
||||
constructor: (@selector, @bindings) ->
|
||||
|
||||
commandForEvent: (event) ->
|
||||
if $(event.target).is(@selector)
|
||||
if @selectorMatchesEvent(event)
|
||||
for pattern, command of @bindings
|
||||
return command if @eventMatchesPattern(event, pattern)
|
||||
null
|
||||
@@ -44,3 +44,10 @@ class BindingSet
|
||||
which: charCode
|
||||
key: key
|
||||
|
||||
selectorMatchesEvent: (event) ->
|
||||
currentNode = event.target
|
||||
while currentNode
|
||||
return true if $(currentNode).is(@selector)
|
||||
currentNode = currentNode.parentNode
|
||||
false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user