1 | ;
|
2 |
|
3 | /**
|
4 | * Check whether a combinator is standard
|
5 | *
|
6 | * @param {import('postcss-selector-parser').Combinator} node postcss-selector-parser node (of type combinator)
|
7 | * @return {boolean} If `true`, the combinator is standard
|
8 | */
|
9 | module.exports = function(node) {
|
10 | // Ghost descendant combinators around reference combinators like `/deep/`
|
11 | // postcss-selector-parser parsers references combinators as tag selectors surrounded
|
12 | // by descendant combinators
|
13 | const prev = node.prev();
|
14 | const next = node.next();
|
15 |
|
16 | if (
|
17 | (prev &&
|
18 | prev.type === 'tag' &&
|
19 | typeof prev.value === 'string' &&
|
20 | prev.value.startsWith('/') &&
|
21 | prev.value.endsWith('/')) ||
|
22 | (next &&
|
23 | next.type === 'tag' &&
|
24 | typeof next.value === 'string' &&
|
25 | next.value.startsWith('/') &&
|
26 | next.value.endsWith('/'))
|
27 | ) {
|
28 | return false;
|
29 | }
|
30 |
|
31 | return true;
|
32 | };
|