From 8e46bc52411e495c5cc303b0ef5879fccdb94e64 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 19 Nov 2013 14:15:23 -0800 Subject: [PATCH] Add shim for atom.rootView vs. window.rootView --- src/atom-package.coffee | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/atom-package.coffee b/src/atom-package.coffee index a49d1087d..a53bcb414 100644 --- a/src/atom-package.coffee +++ b/src/atom-package.coffee @@ -216,14 +216,18 @@ class AtomPackage extends Package @activateStylesheets() @requireMainModule() + # Private: TODO remove once packages have been updated + getRootView: -> + atom?.rootView ? window.rootView + subscribeToActivationEvents: -> return unless @metadata.activationEvents? if _.isArray(@metadata.activationEvents) - atom.rootView.command(event, @handleActivationEvent) for event in @metadata.activationEvents + @getRootView().command(event, @handleActivationEvent) for event in @metadata.activationEvents else if _.isString(@metadata.activationEvents) - atom.rootView.command(@metadata.activationEvents, @handleActivationEvent) + @getRootView().command(@metadata.activationEvents, @handleActivationEvent) else - atom.rootView.command(event, selector, @handleActivationEvent) for event, selector of @metadata.activationEvents + @getRootView().command(event, selector, @handleActivationEvent) for event, selector of @metadata.activationEvents handleActivationEvent: (event) => bubblePathEventHandlers = @disableEventHandlersOnBubblePath(event) @@ -234,11 +238,11 @@ class AtomPackage extends Package unsubscribeFromActivationEvents: -> if _.isArray(@metadata.activationEvents) - atom.rootView.off(event, @handleActivationEvent) for event in @metadata.activationEvents + @getRootView().off(event, @handleActivationEvent) for event in @metadata.activationEvents else if _.isString(@metadata.activationEvents) - atom.rootView.off(@metadata.activationEvents, @handleActivationEvent) + @getRootView().off(@metadata.activationEvents, @handleActivationEvent) else - atom.rootView.off(event, selector, @handleActivationEvent) for event, selector of @metadata.activationEvents + @getRootView().off(event, selector, @handleActivationEvent) for event, selector of @metadata.activationEvents disableEventHandlersOnBubblePath: (event) -> bubblePathEventHandlers = []