source: frontend/node_modules/tailwindcss/src/lib/partitionApplyAtRules.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1009 bytes
RevLine 
[9af201e]1function partitionRules(root) {
2 if (!root.walkAtRules) return
3
4 let applyParents = new Set()
5
6 root.walkAtRules('apply', (rule) => {
7 applyParents.add(rule.parent)
8 })
9
10 if (applyParents.size === 0) {
11 return
12 }
13
14 for (let rule of applyParents) {
15 let nodeGroups = []
16 let lastGroup = []
17
18 for (let node of rule.nodes) {
19 if (node.type === 'atrule' && node.name === 'apply') {
20 if (lastGroup.length > 0) {
21 nodeGroups.push(lastGroup)
22 lastGroup = []
23 }
24 nodeGroups.push([node])
25 } else {
26 lastGroup.push(node)
27 }
28 }
29
30 if (lastGroup.length > 0) {
31 nodeGroups.push(lastGroup)
32 }
33
34 if (nodeGroups.length === 1) {
35 continue
36 }
37
38 for (let group of [...nodeGroups].reverse()) {
39 let clone = rule.clone({ nodes: [] })
40 clone.append(group)
41 rule.after(clone)
42 }
43
44 rule.remove()
45 }
46}
47
48export default function expandApplyAtRules() {
49 return (root) => {
50 partitionRules(root)
51 }
52}
Note: See TracBrowser for help on using the repository browser.