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 | // if it's not a combinator, then it's not a standard combinator
|
11 | if (node.type !== 'combinator') {
|
12 | return false;
|
13 | }
|
14 |
|
15 | // Ignore reference combinators like `/deep/`
|
16 | if (node.value.startsWith('/') || node.value.endsWith('/')) {
|
17 | return false;
|
18 | }
|
19 |
|
20 | // ignore the combinators that are the first or last node in their container
|
21 | if (node.parent !== undefined && node.parent !== null) {
|
22 | let parent = node.parent;
|
23 |
|
24 | if (node === parent.first) {
|
25 | return false;
|
26 | }
|
27 |
|
28 | if (node === parent.last) {
|
29 | return false;
|
30 | }
|
31 | }
|
32 |
|
33 | return true;
|
34 | };
|