Skip to content

Commit 3cf67ce

Browse files
committed
localized decls in atrules
1 parent cc7f5bc commit 3cf67ce

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,15 @@ module.exports = postcss.plugin('postcss-modules-local-by-default', function (op
211211
} else if(!globalMode) {
212212
atrule.params = ":local(" + atrule.params + ")";
213213
}
214+
} else {
215+
atrule.nodes.forEach(function(decl) {
216+
if(decl.type === "decl") {
217+
localizeDecl(decl, {
218+
options: options,
219+
global: globalMode
220+
});
221+
}
222+
});
214223
}
215224
});
216225
css.eachRule(function(rule) {

test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,8 @@ var tests = [
357357
should: 'rewrite url in local block',
358358
input: '.a { background: url(./image.png); }\n' +
359359
':global .b { background: url(image.png); }\n' +
360-
'.c { background: url("./image.png"); }',
360+
'.c { background: url("./image.png"); }\n' +
361+
'@-webkit-font-face { src: url("./font.woff"); }',
361362
options: {
362363
rewriteUrl: function(global, url) {
363364
var mode = global ? 'global' : 'local';
@@ -366,7 +367,8 @@ var tests = [
366367
},
367368
expected: ':local(.a) { background: url((local\\)./image.png\\\"local\\\"); }\n' +
368369
'.b { background: url((global\\)image.png\\\"global\\\"); }\n' +
369-
':local(.c) { background: url(\"(local)./image.png\\\"local\\\"\"); }'
370+
':local(.c) { background: url(\"(local)./image.png\\\"local\\\"\"); }\n' +
371+
'@-webkit-font-face { src: url(\"(local)./font.woff\\\"local\\\"\"); }'
370372
}
371373

372374
];

0 commit comments

Comments
 (0)