Skip to content

Commit 6c1e3d8

Browse files
author
Jed Mao
committed
Fix issue #9
1 parent 0a7e619 commit 6c1e3d8

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/plugin.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const PostCssNestedProps = postcss.plugin('postcss-nested-props', () => {
1010
};
1111
});
1212

13+
const STARTS_WITH_COLON = /^:/;
1314
const HAS_COLON = /:/;
1415
const ALL_PSEUDO = pseudoClasses().concat(pseudoElements());
1516
const VENDOR_PSEUDO_ELEMENTS = '-(\\w|-)+';
@@ -18,6 +19,9 @@ const HAS_PSEUDO_CLASSES_ELEMENTS = new RegExp(
1819
);
1920

2021
function unwrapRule(namespace: string[], rule: postcss.Rule) {
22+
if (STARTS_WITH_COLON.test(rule.selector)) {
23+
return;
24+
}
2125
if (!HAS_COLON.test(rule.selector)) {
2226
return;
2327
}

test/plugin.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,20 @@ describe('postcss-nested-props plugin', () => {
4242
);
4343
});
4444

45+
it('preserves a rule with a :global pseudo-selector', () => {
46+
check(
47+
`:global .a{b:c;d:e;}`,
48+
`:global .a{b:c;d:e;}`
49+
);
50+
});
51+
52+
it('preserves a rule with a :local pseudo-selector', () => {
53+
check(
54+
`:local .a{b:c;d:e;}`,
55+
`:local .a{b:c;d:e;}`
56+
);
57+
});
58+
4559
describe('pseudo classes', () => {
4660
pseudoClasses().forEach((pseudoClass: string) => {
4761
it(`preserves the :${pseudoClass}() pseudo-class`, () => {

0 commit comments

Comments
 (0)