|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
969 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | /**
|
|---|
| 4 | * @param {import('postcss').AnyNode} nodeA
|
|---|
| 5 | * @param {import('postcss').AnyNode} nodeB
|
|---|
| 6 | * @return {boolean}
|
|---|
| 7 | */
|
|---|
| 8 | function checkMatch(nodeA, nodeB) {
|
|---|
| 9 | if (nodeA.type === 'atrule' && nodeB.type === 'atrule') {
|
|---|
| 10 | return (
|
|---|
| 11 | nodeA.params === nodeB.params &&
|
|---|
| 12 | nodeA.name.toLowerCase() === nodeB.name.toLowerCase()
|
|---|
| 13 | );
|
|---|
| 14 | }
|
|---|
| 15 | return nodeA.type === nodeB.type;
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | /** @typedef {import('postcss').AnyNode & {parent?: Child}} Child */
|
|---|
| 19 | /**
|
|---|
| 20 | * @param {Child} nodeA
|
|---|
| 21 | * @param {Child} nodeB
|
|---|
| 22 | * @return {boolean}
|
|---|
| 23 | */
|
|---|
| 24 | function sameParent(nodeA, nodeB) {
|
|---|
| 25 | if (!nodeA.parent) {
|
|---|
| 26 | // A is orphaned, return if B is orphaned as well
|
|---|
| 27 | return !nodeB.parent;
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | if (!nodeB.parent) {
|
|---|
| 31 | // B is orphaned and A is not
|
|---|
| 32 | return false;
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | // Check if parents match
|
|---|
| 36 | if (!checkMatch(nodeA.parent, nodeB.parent)) {
|
|---|
| 37 | return false;
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | // Check parents' parents
|
|---|
| 41 | return sameParent(nodeA.parent, nodeB.parent);
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | module.exports = sameParent;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.