From 481e444ffe37427c348e1a0ddf11210b34ba8a1a Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 7 Nov 2014 18:00:38 -0700 Subject: [PATCH] Reassign context to undefined because CoffeeScript needs a var keyword Fixes #4100 --- .../stylesheets/{3.css => 3.test-context.css} | 0 .../stylesheets/{4.test-context.css => 4.css} | 0 spec/package-manager-spec.coffee | 29 ++++++++++++++++--- src/package.coffee | 3 +- 4 files changed, 27 insertions(+), 5 deletions(-) rename spec/fixtures/packages/package-with-stylesheets/stylesheets/{3.css => 3.test-context.css} (100%) rename spec/fixtures/packages/package-with-stylesheets/stylesheets/{4.test-context.css => 4.css} (100%) diff --git a/spec/fixtures/packages/package-with-stylesheets/stylesheets/3.css b/spec/fixtures/packages/package-with-stylesheets/stylesheets/3.test-context.css similarity index 100% rename from spec/fixtures/packages/package-with-stylesheets/stylesheets/3.css rename to spec/fixtures/packages/package-with-stylesheets/stylesheets/3.test-context.css diff --git a/spec/fixtures/packages/package-with-stylesheets/stylesheets/4.test-context.css b/spec/fixtures/packages/package-with-stylesheets/stylesheets/4.css similarity index 100% rename from spec/fixtures/packages/package-with-stylesheets/stylesheets/4.test-context.css rename to spec/fixtures/packages/package-with-stylesheets/stylesheets/4.css diff --git a/spec/package-manager-spec.coffee b/spec/package-manager-spec.coffee index d460591b7..2badac3b2 100644 --- a/spec/package-manager-spec.coffee +++ b/spec/package-manager-spec.coffee @@ -294,16 +294,18 @@ describe "PackageManager", -> it "loads all stylesheets from the stylesheets directory", -> one = require.resolve("./fixtures/packages/package-with-stylesheets/stylesheets/1.css") two = require.resolve("./fixtures/packages/package-with-stylesheets/stylesheets/2.less") - three = require.resolve("./fixtures/packages/package-with-stylesheets/stylesheets/3.css") - + three = require.resolve("./fixtures/packages/package-with-stylesheets/stylesheets/3.test-context.css") + four = require.resolve("./fixtures/packages/package-with-stylesheets/stylesheets/4.css") one = atom.themes.stringToId(one) two = atom.themes.stringToId(two) three = atom.themes.stringToId(three) + four = atom.themes.stringToId(four) expect(atom.themes.stylesheetElementForId(one)).toBeNull() expect(atom.themes.stylesheetElementForId(two)).toBeNull() expect(atom.themes.stylesheetElementForId(three)).toBeNull() + expect(atom.themes.stylesheetElementForId(four)).toBeNull() waitsForPromise -> atom.packages.activatePackage("package-with-stylesheets") @@ -312,6 +314,7 @@ describe "PackageManager", -> expect(atom.themes.stylesheetElementForId(one)).not.toBeNull() expect(atom.themes.stylesheetElementForId(two)).not.toBeNull() expect(atom.themes.stylesheetElementForId(three)).not.toBeNull() + expect(atom.themes.stylesheetElementForId(four)).not.toBeNull() expect($('#jasmine-content').css('font-size')).toBe '3px' it "assigns the stylesheet's context based on the filename", -> @@ -319,8 +322,26 @@ describe "PackageManager", -> atom.packages.activatePackage("package-with-stylesheets") runs -> - element = atom.styles.getStyleElements().find (element) -> element.context is 'test-context' - expect(element).toBeDefined() + count = 0 + + for styleElement in atom.styles.getStyleElements() + if styleElement.sourcePath.match /1.css/ + expect(styleElement.context).toBe undefined + count++ + + if styleElement.sourcePath.match /2.less/ + expect(styleElement.context).toBe undefined + count++ + + if styleElement.sourcePath.match /3.test-context.css/ + expect(styleElement.context).toBe 'test-context' + count++ + + if styleElement.sourcePath.match /4.css/ + expect(styleElement.context).toBe undefined + count++ + + expect(count).toBe 4 describe "grammar loading", -> it "loads the package's grammars", -> diff --git a/src/package.coffee b/src/package.coffee index 79485da69..9bb6ed9d0 100644 --- a/src/package.coffee +++ b/src/package.coffee @@ -176,7 +176,6 @@ class Package activateStylesheets: -> return if @stylesheetsActivated - group = @getStylesheetType() @stylesheetDisposables = new CompositeDisposable for [sourcePath, source] in @stylesheets @@ -184,6 +183,8 @@ class Package context = match[1] else if @metadata.theme is 'syntax' context = 'atom-text-editor' + else + context = undefined @stylesheetDisposables.add(atom.styles.addStyleSheet(source, {sourcePath, group, context})) @stylesheetsActivated = true