Skip to content

Commit 9eb769d

Browse files
authored
Clears empty selector after comma (#118)
1 parent 5d382e6 commit 9eb769d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

index.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@ function selectors (parent, child) {
4343
let parentNode = parse(i, parent)
4444

4545
child.selectors.forEach(j => {
46-
let node = parse(j, child)
47-
let replaced = replace(node, parentNode)
48-
if (!replaced) {
49-
node.prepend(parser.combinator({ value: ' ' }))
50-
node.prepend(parentNode.clone())
46+
if (j.length) {
47+
let node = parse(j, child)
48+
let replaced = replace(node, parentNode)
49+
if (!replaced) {
50+
node.prepend(parser.combinator({ value: ' ' }))
51+
node.prepend(parentNode.clone())
52+
}
53+
result.push(node.toString())
5154
}
52-
result.push(node.toString())
5355
})
5456
})
5557
return result

index.test.js

+4
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ it('processes comma inside', () => {
133133
run('a, b { .one, .two {} }', 'a .one, a .two, b .one, b .two {}')
134134
})
135135

136+
it('clears empty selector after comma', () => {
137+
run('a, b { .one, .two, {} }', 'a .one, a .two, b .one, b .two {}')
138+
})
139+
136140
it('moves comment with rule', () => {
137141
run('a { /*B*/ b {} }', '/*B*/ a b {}')
138142
})

0 commit comments

Comments
 (0)