Activate stylesheets from deferred deserializer

This commit is contained in:
Kevin Sawicki 2013-10-02 19:10:53 -07:00
parent e4b55c4210
commit ea2779b029
2 changed files with 8 additions and 1 deletions

View File

@ -11,11 +11,13 @@ describe "the `atom` global", ->
describe "when the package has deferred deserializers", ->
it "requires the package's main module if one of its deferred deserializers is referenced", ->
pack = atom.loadPackage('package-with-activation-events')
spyOn(pack, 'activateStylesheets').andCallThrough()
expect(pack.mainModule).toBeNull()
object = deserialize({deserializer: 'Foo', data: 5})
expect(pack.mainModule).toBeDefined()
expect(object.constructor.name).toBe 'Foo'
expect(object.data).toBe 5
expect(pack.activateStylesheets).toHaveBeenCalled()
describe ".unloadPackage(name)", ->
describe "when the package is active", ->

View File

@ -82,9 +82,12 @@ class AtomPackage extends Package
@configActivated = true
activateStylesheets: ->
return if @stylesheetsActivated
type = if @metadata.theme then 'theme' else 'bundled'
for [stylesheetPath, content] in @stylesheets
atom.themes.applyStylesheet(stylesheetPath, content, type)
@stylesheetsActivated = true
activateResources: ->
keymap.add(keymapPath, map) for [keymapPath, map] in @keymaps
@ -196,7 +199,9 @@ class AtomPackage extends Package
registerDeferredDeserializers: ->
for deserializerName in @metadata.deferredDeserializers ? []
registerDeferredDeserializer deserializerName, => @requireMainModule()
registerDeferredDeserializer deserializerName, =>
@activateStylesheets()
@requireMainModule()
subscribeToActivationEvents: ->
return unless @metadata.activationEvents?