Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/css-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = function(useSourceMap) {
var alreadyImportedModules = {};
for(var i = 0; i < this.length; i++) {
var id = this[i][0];
if(typeof id === "number")
if(id != null)
alreadyImportedModules[id] = true;
}
for(i = 0; i < modules.length; i++) {
Expand All @@ -34,7 +34,7 @@ module.exports = function(useSourceMap) {
// this implementation is not 100% perfect for weird media query combinations
// when a module is imported multiple times with different media queries.
// I hope this will never occur (Hey this way we have smaller bundles)
if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
if(item[0] == null || !alreadyImportedModules[item[0]]) {
if(mediaQuery && !item[2]) {
item[2] = mediaQuery;
} else if(mediaQuery) {
Expand Down
15 changes: 15 additions & 0 deletions test/cssBaseTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ describe("css-base", function() {
"@media print{body { d: 4; }}" +
"@media screen{body { a: 1; }}");
});
it("should import named modules", function() {
var m = base();
var m1 = ["./module1", "body { a: 1; }", "screen"];
var m2 = ["./module2", "body { b: 2; }", ""];
var m3 = ["./module3", "body { c: 3; }", ""];
var m4 = ["./module4", "body { d: 4; }", ""];
m.i([m2, m3], "");
m.i([m2], "");
m.i([m2, m4], "print");
m.push(m1);
m.toString().should.be.eql("body { b: 2; }" +
"body { c: 3; }" +
"@media print{body { d: 4; }}" +
"@media screen{body { a: 1; }}");
});
it("should toString with source mapping", function() {
var m = base(true);
m.push([1, "body { a: 1; }", "", {
Expand Down