Skip to content

Commit b592cd2

Browse files
committed
fix: generate two rules instead of one with coma
angular/angular-cli#20015 (comment)
1 parent bddb4cb commit b592cd2

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function pluginFn(fn = () => {}){
22
return {
3-
postcssPlugin: 'postcss-ng-tailwind-dark',
3+
postcssPlugin: 'postcss-ng-tailwind-in-components',
44
Rule: fn,
55
}
66
}
@@ -28,7 +28,10 @@ module.exports = ({parentSelector} = {}) => {
2828
}
2929
}
3030
if(hostContextCSS.length){
31-
rule.selectors = rule.selectors.concat(hostContextCSS)
31+
const clone = rule.clone({ selectors: hostContextCSS });
32+
// console.log(clone);
33+
rule.parent.insertAfter(rule, rule.clone({ selectors: hostContextCSS }))
34+
// rule.selectors = rule.selectors.concat(hostContextCSS)
3235
}
3336
}
3437
})

index.test.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,33 @@ describe('Check errors', () => {
3232
describe('PostCSS', () => {
3333
it('should add :host-context', async () => {
3434
await run(
35-
'.dark .test {}',
36-
'.dark .test, :host-context(.dark) .test {}',
35+
`
36+
.test {}
37+
.any {}
38+
.dark .test {}
39+
.string {}`,
40+
`
41+
.test {}
42+
.any {}
43+
.dark .test {}
44+
:host-context(.dark) .test {}
45+
.string {}`,
3746
{parentSelector: '.dark'}
3847
)
3948
})
4049

4150
it('should add :host-context to "some-parent-class"', async () => {
4251
await run(
4352
'.some-parent-class .test {}',
44-
'.some-parent-class .test, :host-context(.some-parent-class) .test {}',
53+
`.some-parent-class .test {}:host-context(.some-parent-class) .test {}`,
4554
{parentSelector: '.some-parent-class'}
4655
)
4756
})
4857

4958
it('should work with id "#some-parent-id"', async () => {
5059
await run(
5160
'#some-parent-id .test {}',
52-
'#some-parent-id .test, :host-context(#some-parent-id) .test {}',
61+
`#some-parent-id .test {}:host-context(#some-parent-id) .test {}`,
5362
{parentSelector: '#some-parent-id'}
5463
)
5564
})

0 commit comments

Comments
 (0)