diff --git a/index.js b/index.js index 0e8ee03..2cdea49 100644 --- a/index.js +++ b/index.js @@ -459,6 +459,15 @@ module.exports = postcss.plugin('postcss-modules-local-by-default', function( return; } + if ( + rule.nodes && + rule.selector.slice(0, 2) === '--' && + rule.selector.slice(-1) === ':' + ) { + // ignore custom property set + return; + } + const context = localizeNode(rule, options.mode); context.options = options; diff --git a/test.js b/test.js index 53123cb..98baf64 100644 --- a/test.js +++ b/test.js @@ -512,6 +512,11 @@ const tests = [ input: '.a { content: "\\2193 \\2193 \\2193" }', expected: ':local(.a) { content: "\\2193 \\2193 \\2193" }', }, + { + should: 'not ignore custom property set', + input: ':root { --title-align: center; --sr-only: { position: absolute; } }', + expected: ':root { --title-align: center; --sr-only: { position: absolute; } }', + }, ]; function process(css, options) {