Last change
on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
988 bytes
|
Line | |
---|
1 | "use strict";
|
---|
2 |
|
---|
3 | Object.defineProperty(exports, "__esModule", {
|
---|
4 | value: true
|
---|
5 | });
|
---|
6 | exports.default = sameParent;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * @param {postcss.ChildNode} nodeA
|
---|
10 | * @param {postcss.ChildNode} nodeB
|
---|
11 | * @return {boolean}
|
---|
12 | */
|
---|
13 | function checkMatch(nodeA, nodeB) {
|
---|
14 | if (nodeA.type === 'atrule' && nodeB.type === 'atrule') {
|
---|
15 | return nodeA.params === nodeB.params && nodeA.name.toLowerCase() === nodeB.name.toLowerCase();
|
---|
16 | }
|
---|
17 |
|
---|
18 | return nodeA.type === nodeB.type;
|
---|
19 | }
|
---|
20 | /**
|
---|
21 | * @param {postcss.ChildNode} nodeA
|
---|
22 | * @param {postcss.ChildNode} nodeB
|
---|
23 | * @return {boolean}
|
---|
24 | */
|
---|
25 |
|
---|
26 |
|
---|
27 | function sameParent(nodeA, nodeB) {
|
---|
28 | if (!nodeA.parent) {
|
---|
29 | // A is orphaned, return if B is orphaned as well
|
---|
30 | return !nodeB.parent;
|
---|
31 | }
|
---|
32 |
|
---|
33 | if (!nodeB.parent) {
|
---|
34 | // B is orphaned and A is not
|
---|
35 | return false;
|
---|
36 | } // Check if parents match
|
---|
37 |
|
---|
38 |
|
---|
39 | if (!checkMatch(nodeA.parent, nodeB.parent)) {
|
---|
40 | return false;
|
---|
41 | } // Check parents' parents
|
---|
42 |
|
---|
43 |
|
---|
44 | return sameParent(nodeA.parent, nodeB.parent);
|
---|
45 | }
|
---|
46 |
|
---|
47 | module.exports = exports.default; |
---|
Note:
See
TracBrowser
for help on using the repository browser.