Skip to content

Commit 8ab7051

Browse files
fix: ignore custom property set (#11)
1 parent 04f7b12 commit 8ab7051

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,15 @@ module.exports = postcss.plugin('postcss-modules-local-by-default', function(
459459
return;
460460
}
461461

462+
if (
463+
rule.nodes &&
464+
rule.selector.slice(0, 2) === '--' &&
465+
rule.selector.slice(-1) === ':'
466+
) {
467+
// ignore custom property set
468+
return;
469+
}
470+
462471
const context = localizeNode(rule, options.mode);
463472

464473
context.options = options;

test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,11 @@ const tests = [
512512
input: '.a { content: "\\2193 \\2193 \\2193" }',
513513
expected: ':local(.a) { content: "\\2193 \\2193 \\2193" }',
514514
},
515+
{
516+
should: 'not ignore custom property set',
517+
input: ':root { --title-align: center; --sr-only: { position: absolute; } }',
518+
expected: ':root { --title-align: center; --sr-only: { position: absolute; } }',
519+
},
515520
];
516521

517522
function process(css, options) {

0 commit comments

Comments
 (0)