Skip to content

Commit a1519f8

Browse files
authored
Merge pull request #38 from doplumi/master
[feat] Enable replacements for selectors
2 parents 1e571ab + 4cd23fc commit a1519f8

4 files changed

Lines changed: 17 additions & 0 deletions

File tree

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ module.exports = postcss.plugin('postcss-replace', (opts = defaults) => {
6363
case 'AtRule':
6464
node.params = node.params.replace(...replacementArgs);
6565
break;
66+
67+
case 'Rule':
68+
node.selector = node.selector.replace(...replacementArgs);
69+
break;
6670
}
6771
});
6872
};

test/fixtures/selectors.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.foo {
2+
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.bar {
2+
3+
}

test/index.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,10 @@ it('Should not replace multiple times', () => {
8686
data: { a: 'abc'}
8787
});
8888
});
89+
90+
it('Should replace strings in selectors', () => {
91+
return run('selectors', {
92+
pattern: /(foo)/g,
93+
data: { 'foo': 'bar' },
94+
});
95+
});

0 commit comments

Comments
 (0)