mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Allow CommandRegistry::rootNode to be reassigned
This commit is contained in:
@@ -9,11 +9,13 @@ class CommandRegistry
|
||||
constructor: (@rootNode) ->
|
||||
@listenersByCommandName = {}
|
||||
|
||||
setRootNode: (rootNode) ->
|
||||
throw new Error("Already assigned root node.") if @rootNode?
|
||||
@rootNode = rootNode
|
||||
setRootNode: (newRootNode) ->
|
||||
oldRootNode = @rootNode
|
||||
@rootNode = newRootNode
|
||||
|
||||
for commandName of @listenersByCommandName
|
||||
@rootNode?.addEventListener(commandName, @dispatchCommand, true)
|
||||
oldRootNode?.removeEventListener(commandName, @dispatchCommand, true)
|
||||
newRootNode?.addEventListener(commandName, @dispatchCommand, true)
|
||||
|
||||
add: (selector, commandName, callback) ->
|
||||
if typeof commandName is 'object'
|
||||
|
||||
Reference in New Issue
Block a user