mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Don't register CommandRegistry's window listeners in AtomEnvironment constructor
This commit is contained in:
@@ -589,6 +589,8 @@ class AtomEnvironment extends Model
|
||||
@setAutoHideMenuBar(newValue)
|
||||
@setAutoHideMenuBar(true) if @config.get('core.autoHideMenuBar')
|
||||
|
||||
@commands.attach(window)
|
||||
|
||||
@openInitialEmptyEditorIfNecessary()
|
||||
|
||||
unloadEditorWindow: ->
|
||||
|
||||
@@ -44,7 +44,8 @@ SequenceCount = 0
|
||||
# ```
|
||||
module.exports =
|
||||
class CommandRegistry
|
||||
constructor: (@rootNode) ->
|
||||
constructor: ->
|
||||
@rootNode = null
|
||||
@clear()
|
||||
|
||||
clear: ->
|
||||
@@ -53,9 +54,13 @@ class CommandRegistry
|
||||
@inlineListenersByCommandName = {}
|
||||
@emitter = new Emitter
|
||||
|
||||
attach: (@rootNode) ->
|
||||
@commandRegistered(command) for command of @selectorBasedListenersByCommandName
|
||||
@commandRegistered(command) for command of @inlineListenersByCommandName
|
||||
|
||||
destroy: ->
|
||||
for commandName of @registeredCommands
|
||||
window.removeEventListener(commandName, @handleCommandEvent, true)
|
||||
@rootNode.removeEventListener(commandName, @handleCommandEvent, true)
|
||||
return
|
||||
|
||||
# Public: Add one or more command listeners associated with a selector.
|
||||
@@ -256,8 +261,8 @@ class CommandRegistry
|
||||
matched
|
||||
|
||||
commandRegistered: (commandName) ->
|
||||
unless @registeredCommands[commandName]
|
||||
window.addEventListener(commandName, @handleCommandEvent, true)
|
||||
if @rootNode? and not @registeredCommands[commandName]
|
||||
@rootNode.addEventListener(commandName, @handleCommandEvent, true)
|
||||
@registeredCommands[commandName] = true
|
||||
|
||||
class SelectorBasedListener
|
||||
|
||||
Reference in New Issue
Block a user