Skip to content

Commit 9018b18

Browse files
committed
support /deep/ alias
1 parent 98751d8 commit 9018b18

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,24 @@ 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
25+
// ">>>" combinator
2626
if (n.type === 'combinator' && n.value === '>>>') {
2727
n.value = ' '
2828
n.spaces.before = n.spaces.after = ''
2929
return false
3030
}
31-
if (n.type !== 'pseudo') node = n
31+
// /deep/ alias for >>>, since >>> doesn't work in SASS
32+
if (n.type === 'tag' && n.value === '/deep/') {
33+
var next = n.next()
34+
if (next.type === 'combinator' && next.value === ' ') {
35+
next.remove()
36+
}
37+
n.remove()
38+
return false
39+
}
40+
if (n.type !== 'pseudo' && n.type !== 'combinator') {
41+
node = n
42+
}
3243
})
3344
selector.insertAfter(node, selectorParser.attribute({
3445
attribute: opts.id
@@ -67,3 +78,9 @@ module.exports = postcss.plugin('add-id', function (opts) {
6778
}
6879
}
6980
})
81+
82+
function tryRemove (node) {
83+
if (node.value === ' ') {
84+
85+
}
86+
}

0 commit comments

Comments
 (0)