1 |
|
2 | import transformDecl from './transform-decl';
|
3 | import transformAtrule from './transform-atrule';
|
4 | import transformEachAtrule from './transform-each-atrule';
|
5 | import transformForAtrule from './transform-for-atrule';
|
6 | import transformIfAtrule from './transform-if-atrule';
|
7 | import transformRule from './transform-rule';
|
8 |
|
9 |
|
10 | export default function transformNode(node, result, opts) {
|
11 |
|
12 | getNodesArray(node).forEach(
|
13 | childNode => {
|
14 | if ('atrule' === childNode.type) {
|
15 | if ('each' === childNode.name) {
|
16 |
|
17 | transformEachAtrule(childNode, result, opts);
|
18 | } else if ('if' === childNode.name) {
|
19 |
|
20 | transformIfAtrule(childNode, result, opts);
|
21 | } else if ('for' === childNode.name) {
|
22 |
|
23 | transformForAtrule(childNode, result, opts);
|
24 | } else {
|
25 |
|
26 | transformAtrule(childNode, result, opts);
|
27 | }
|
28 | } else if ('decl' === childNode.type) {
|
29 |
|
30 | transformDecl(childNode, result, opts);
|
31 | } else if ('rule' === childNode.type) {
|
32 |
|
33 | transformRule(childNode, result, opts);
|
34 | }
|
35 |
|
36 |
|
37 | if (childNode.parent) {
|
38 | transformNode(childNode, result, opts);
|
39 | }
|
40 | }
|
41 | );
|
42 | }
|
43 |
|
44 |
|
45 | const getNodesArray = node => Array.from(Object(node).nodes || []);
|