From 6eea8b1d595934ef144f00f3eb268fe37c360ea1 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Wed, 20 Feb 2019 18:34:07 +0300 Subject: [PATCH] fix: ignore custom property set --- index.js | 9 +++++++++ test.js | 5 +++++ 2 files changed, 14 insertions(+) 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) {