Skip to content

Commit 7b81a46

Browse files
committed
Ignore null source maps
fixes #84 closes #90
1 parent 446b6ef commit 7b81a46

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

lib/loader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module.exports = function(content, map) {
1414
var root = query.root;
1515
var moduleMode = query.modules || query.module;
1616

17-
if(typeof map !== "string") {
17+
if(map !== null && typeof map !== "string") {
1818
map = JSON.stringify(map);
1919
}
2020

test/helpers.js

+20
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,26 @@ exports.test = function test(name, input, result, query, modules) {
5252
});
5353
};
5454

55+
exports.testWithMap = function test(name, input, map, result, query, modules) {
56+
it(name, function() {
57+
var output = cssLoader.call({
58+
options: {
59+
context: ""
60+
},
61+
loaders: [{request: "loader"}],
62+
loaderIndex: 0,
63+
context: "",
64+
resource: "test.css",
65+
request: "css-loader!test.css",
66+
query: query,
67+
emitError: function(message) {
68+
throw new Error(message);
69+
}
70+
}, input, map);
71+
assetEvaluated(output, result, modules);
72+
});
73+
};
74+
5575
exports.testLocals = function testLocals(name, input, result, query, modules) {
5676
it(name, function() {
5777
var output = cssLoaderLocals.call({

test/sourceMapTest.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*globals describe */
2+
3+
var testWithMap = require("./helpers").testWithMap;
4+
5+
describe("falsy source maps", function() {
6+
testWithMap("null map doesn't cause an error", ".class { a: b c d; }", null, [
7+
[1, ".class { a: b c d; }", ""]
8+
]);
9+
testWithMap("undefined map doesn't cause an error", ".class { a: b c d; }", undefined, [
10+
[1, ".class { a: b c d; }", ""]
11+
]);
12+
});

0 commit comments

Comments
 (0)