Skip to content

Commit 4f5ec11

Browse files
committedJan 8, 2018
Do not replace selectors
1 parent 0e553ea commit 4f5ec11

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed
 

‎index.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const postcss = require('postcss');
22
const path = require('path');
33
const promisify = require('es6-promisify');
44
const { CachedInputFileSystem, NodeJsInputFileSystem, ResolverFactory } = require('enhanced-resolve');
5-
const { replaceSymbols, replaceValueSymbols } = require('icss-utils');
5+
const { replaceValueSymbols } = require('icss-utils');
66

77
const matchImports = /^(.+?|\([\s\S]+?\))\s+from\s+("[^"]*"|'[^']*'|[\w-]+)$/;
88
const matchValueDefinition = /(?:\s+|^)([\w-]+)(:?\s+)(.+?)(\s*)$/g;
@@ -135,7 +135,13 @@ const factory = ({ fs = nodeFs, resolve: options = {} } = {}) => async (root, ro
135135
type: 'values',
136136
values: definitions,
137137
});
138-
replaceSymbols(root, definitions);
138+
139+
root.walk((node) => {
140+
if (node.type === 'decl') {
141+
// eslint-disable-next-line no-param-reassign
142+
node.value = replaceValueSymbols(node.value, definitions);
143+
}
144+
});
139145
};
140146

141147

‎test.js

+8
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ test('should replace constants within the file', async (t) => {
5656
);
5757
});
5858

59+
test('shouldn\'t replace selector', async (t) => {
60+
await run(
61+
t,
62+
'@value blue red; .blue { color: blue; }',
63+
'@value blue red; .blue { color: red; }',
64+
);
65+
});
66+
5967
test('should replace two constants with same name within the file and the latter should win', async (t) => {
6068
await run(
6169
t,

0 commit comments

Comments
 (0)
Please sign in to comment.