Skip to content

Commit f73ce72

Browse files
committed
fixed bug with empty atrule
1 parent dc43089 commit f73ce72

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ module.exports = postcss.plugin('postcss-modules-local-by-default', function (op
211211
} else if(!globalMode) {
212212
atrule.params = ":local(" + atrule.params + ")";
213213
}
214-
} else {
214+
} else if(atrule.nodes) {
215215
atrule.nodes.forEach(function(decl) {
216216
if(decl.type === "decl") {
217217
localizeDecl(decl, {

test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ var tests = [
358358
input: '.a { background: url(./image.png); }\n' +
359359
':global .b { background: url(image.png); }\n' +
360360
'.c { background: url("./image.png"); }\n' +
361+
'@font-face { src: url("./font.woff"); }\n' +
361362
'@-webkit-font-face { src: url("./font.woff"); }',
362363
options: {
363364
rewriteUrl: function(global, url) {
@@ -368,7 +369,13 @@ var tests = [
368369
expected: ':local(.a) { background: url((local\\)./image.png\\\"local\\\"); }\n' +
369370
'.b { background: url((global\\)image.png\\\"global\\\"); }\n' +
370371
':local(.c) { background: url(\"(local)./image.png\\\"local\\\"\"); }\n' +
372+
'@font-face { src: url(\"(local)./font.woff\\\"local\\\"\"); }\n' +
371373
'@-webkit-font-face { src: url(\"(local)./font.woff\\\"local\\\"\"); }'
374+
},
375+
{
376+
should: 'not crash on atrule without nodes',
377+
input: '@charset "utf-8";',
378+
expected: '@charset "utf-8";'
372379
}
373380

374381
];

0 commit comments

Comments
 (0)