Skip to content

Commit b14b1e7

Browse files
committed
fix scoped css for rules with pseudo classes
1 parent e8611e5 commit b14b1e7

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

lib/style-rewriter.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ var addId = postcss.plugin('add-id', function () {
99
root.each(function (node) {
1010
node.selector = selectorParser(function (selectors) {
1111
selectors.each(function (selector) {
12-
selector.append(selectorParser.attribute({
12+
var node = null
13+
selector.each(function (n) {
14+
if (n.type !== 'pseudo') node = n
15+
})
16+
selector.insertAfter(node, selectorParser.attribute({
1317
attribute: currentId
1418
}))
1519
})

test/fixtures/scoped-css.vue

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
.test {
33
color: yellow;
44
}
5+
.test:after {
6+
content: 'bye!';
7+
}
58
h1 {
69
color: green;
710
}

test/test.js

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ describe('vue-loader', function () {
101101
)
102102
var style = window.document.querySelector('style').textContent
103103
expect(style).to.contain('.test[' + id + '] {\n color: yellow;\n}')
104+
expect(style).to.contain('.test[' + id + ']:after {\n content: \'bye!\';\n}')
104105
expect(style).to.contain('h1[' + id + '] {\n color: green;\n}')
105106
done()
106107
})

0 commit comments

Comments
 (0)