Skip to content

Commit

Permalink
fixed bug with empty atrule
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Jun 16, 2015
1 parent dc43089 commit f73ce72
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ module.exports = postcss.plugin('postcss-modules-local-by-default', function (op
} else if(!globalMode) {
atrule.params = ":local(" + atrule.params + ")";
}
} else {
} else if(atrule.nodes) {
atrule.nodes.forEach(function(decl) {
if(decl.type === "decl") {
localizeDecl(decl, {
Expand Down
7 changes: 7 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ var tests = [
input: '.a { background: url(./image.png); }\n' +
':global .b { background: url(image.png); }\n' +
'.c { background: url("./image.png"); }\n' +
'@font-face { src: url("./font.woff"); }\n' +
'@-webkit-font-face { src: url("./font.woff"); }',
options: {
rewriteUrl: function(global, url) {
Expand All @@ -368,7 +369,13 @@ var tests = [
expected: ':local(.a) { background: url((local\\)./image.png\\\"local\\\"); }\n' +
'.b { background: url((global\\)image.png\\\"global\\\"); }\n' +
':local(.c) { background: url(\"(local)./image.png\\\"local\\\"\"); }\n' +
'@font-face { src: url(\"(local)./font.woff\\\"local\\\"\"); }\n' +
'@-webkit-font-face { src: url(\"(local)./font.woff\\\"local\\\"\"); }'
},
{
should: 'not crash on atrule without nodes',
input: '@charset "utf-8";',
expected: '@charset "utf-8";'
}

];
Expand Down

0 comments on commit f73ce72

Please sign in to comment.