(ast: any, env: TransformerEnv)
| 775 | } |
| 776 | |
| 777 | function transformMarko(ast: any, env: TransformerEnv) { |
| 778 | let { matcher } = env |
| 779 | |
| 780 | const nodesToVisit = [ast] |
| 781 | while (nodesToVisit.length > 0) { |
| 782 | const currentNode = nodesToVisit.pop() |
| 783 | switch (currentNode.type) { |
| 784 | case 'File': |
| 785 | nodesToVisit.push(currentNode.program) |
| 786 | break |
| 787 | case 'Program': |
| 788 | nodesToVisit.push(...currentNode.body) |
| 789 | break |
| 790 | case 'MarkoTag': |
| 791 | nodesToVisit.push(...currentNode.attributes) |
| 792 | nodesToVisit.push(currentNode.body) |
| 793 | break |
| 794 | case 'MarkoTagBody': |
| 795 | nodesToVisit.push(...currentNode.body) |
| 796 | break |
| 797 | case 'MarkoAttribute': |
| 798 | if (!matcher.hasStaticAttr(currentNode.name)) break |
| 799 | switch (currentNode.value.type) { |
| 800 | case 'ArrayExpression': |
| 801 | const classList = currentNode.value.elements |
| 802 | for (const node of classList) { |
| 803 | if (node.type === 'StringLiteral') { |
| 804 | node.value = sortClasses(node.value, { env }) |
| 805 | } |
| 806 | } |
| 807 | break |
| 808 | case 'StringLiteral': |
| 809 | currentNode.value.value = sortClasses(currentNode.value.value, { |
| 810 | env, |
| 811 | }) |
| 812 | break |
| 813 | } |
| 814 | break |
| 815 | } |
| 816 | } |
| 817 | } |
| 818 | |
| 819 | function transformTwig(ast: any, env: TransformerEnv) { |
| 820 | let { matcher } = env |
nothing calls this directly
no test coverage detected
searching dependent graphs…