Skip to content

Commit 9087f9f

Browse files
committed
support >>> combinator
1 parent e07ac33 commit 9087f9f

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

lib/style-compiler/plugins/scope-id.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ module.exports = postcss.plugin('add-id', function (opts) {
2222
selectors.each(function (selector) {
2323
var node = null
2424
selector.each(function (n) {
25+
// "deep" combinator
26+
if (n.type === 'combinator' && n.value === '>>>') {
27+
n.value = ' '
28+
n.spaces.before = n.spaces.after = ''
29+
return false
30+
}
2531
if (n.type !== 'pseudo') node = n
2632
})
2733
selector.insertAfter(node, selectorParser.attribute({

test/fixtures/scoped-css.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ h1 {
1919
from { color: red; }
2020
to { color: green; }
2121
}
22+
.foo p >>> .bar {
23+
color: red;
24+
}
2225
</style>
2326

2427
<template>

test/test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ describe('vue-loader', function () {
227227
expect(style).to.contain(`.anim[${id}] {\n animation: color-${id} 5s infinite, other 5s;`)
228228
expect(style).to.contain(`.anim-2[${id}] {\n animation-name: color-${id}`)
229229
expect(style).to.contain(`@keyframes color-${id} {`)
230+
// >>> combinator
231+
expect(style).to.contain(`.foo p[${id}] .bar {\n color: red;\n}`)
230232
done()
231233
})
232234
})

0 commit comments

Comments
 (0)