Skip to content
This repository was archived by the owner on Feb 21, 2024. It is now read-only.

Commit 9a9c2c6

Browse files
committed
fix(index): exclude only selectors that start with default exclusions
1 parent 011a1c0 commit 9a9c2c6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = postcss.plugin('postcss-selector-scope', (options = {}) => {
2020
* :root
2121
* from, to and percentages used in keyframes
2222
*/
23-
const defaultExclusions = [':root', 'from', 'to', /[0-9]/];
23+
const defaultExclusions = [/^:root/, /^from/, /^to/, /^\d+%/];
2424
const allExclusions = settings.exclude.concat(defaultExclusions);
2525
const excludedSelectors = allExclusions.map((value) => {
2626
if (typeof value === 'string') {

tests/lib/index.spec.js

+16
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,21 @@ describe('postcss-selector-scope', () => {
102102

103103
expect(result.css).toBe(expected);
104104
});
105+
106+
it('adds :not() to selectors that include default exclusions in their name', () => {
107+
const input = stripIndent`
108+
.class-with-numbers-234,
109+
.class-with-from,
110+
.class-with-to {}
111+
`;
112+
const expected = stripIndent`
113+
.class-with-numbers-234:not(.style-scope),
114+
.class-with-from:not(.style-scope),
115+
.class-with-to:not(.style-scope) {}
116+
`;
117+
const result = process(input);
118+
119+
expect(result.css).toBe(expected);
120+
});
105121
});
106122
});

0 commit comments

Comments
 (0)