From 8a6915e7a60a852fa6683b7e779d5357495075ed Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 21 Oct 2015 10:56:31 -0700 Subject: [PATCH] Pass application delegate to PaneElement --- spec/pane-element-spec.coffee | 8 ++++---- src/pane-element.coffee | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/pane-element-spec.coffee b/spec/pane-element-spec.coffee index 3fcdc4ffb..0f19cf595 100644 --- a/spec/pane-element-spec.coffee +++ b/spec/pane-element-spec.coffee @@ -4,7 +4,7 @@ describe "PaneElement", -> [paneElement, container, pane] = [] beforeEach -> - spyOn(atom, "open") + spyOn(atom.applicationDelegate, "open") container = new PaneContainer(config: atom.config, confirm: atom.confirm.bind(atom)) pane = container.getActivePane() @@ -187,11 +187,11 @@ describe "PaneElement", -> it "opens it", -> event = buildDragEvent("drop", [{path: "/fake1"}, {path: "/fake2"}]) paneElement.dispatchEvent(event) - expect(atom.open.callCount).toBe 1 - expect(atom.open.argsForCall[0][0]).toEqual pathsToOpen: ['/fake1', '/fake2'] + expect(atom.applicationDelegate.open.callCount).toBe 1 + expect(atom.applicationDelegate.open.argsForCall[0][0]).toEqual pathsToOpen: ['/fake1', '/fake2'] describe "when a non-file is dragged to the pane", -> it "does nothing", -> event = buildDragEvent("drop", []) paneElement.dispatchEvent(event) - expect(atom.open).not.toHaveBeenCalled() + expect(atom.applicationDelegate.open).not.toHaveBeenCalled() diff --git a/src/pane-element.coffee b/src/pane-element.coffee index 59f003300..a0113d127 100644 --- a/src/pane-element.coffee +++ b/src/pane-element.coffee @@ -44,16 +44,16 @@ class PaneElement extends HTMLElement event.stopPropagation() @getModel().activate() pathsToOpen = Array::map.call event.dataTransfer.files, (file) -> file.path - @open({pathsToOpen}) if pathsToOpen.length > 0 + @applicationDelegate.open({pathsToOpen}) if pathsToOpen.length > 0 @addEventListener 'focus', handleFocus, true @addEventListener 'blur', handleBlur, true @addEventListener 'dragover', handleDragOver @addEventListener 'drop', handleDrop - initialize: (@model, {@views, @open}) -> + initialize: (@model, {@views, @applicationDelegate}) -> throw new Error("Must pass a views parameter when initializing PaneElements") unless @views? - throw new Error("Must pass a open parameter when initializing PaneElements") unless @open? + throw new Error("Must pass an applicationDelegate parameter when initializing PaneElements") unless @applicationDelegate? @subscriptions.add @model.onDidActivate(@activated.bind(this)) @subscriptions.add @model.observeActive(@activeStatusChanged.bind(this))