Skip to content

Commit 4954d4a

Browse files
committed
make fokus.dev test work after massive rebase
1 parent b263928 commit 4954d4a

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

src/index.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,21 @@ export function layer_tree_from_ast(ast) {
3333
if (node.type !== NODE_AT_RULE) return
3434

3535
if (node.name === 'layer') {
36-
if (node.has_prelude) {
37-
let has_block = node.has_children && node.children.some((c) => c.type !== NODE_PRELUDE_LAYER_NAME)
38-
if (!has_block) {
39-
for (let child of node.children) {
40-
if (child.type === NODE_PRELUDE_LAYER_NAME) {
41-
root.add_child(current_stack, child.text, create_location(node))
36+
if (node.prelude !== null) {
37+
let groups = node.prelude.split(',').map((s) => s.trim())
38+
if (!node.has_block) {
39+
for (let name of groups) {
40+
let parts = get_layer_names(name)
41+
// Ensure all parent layers exist and add them to the tree
42+
for (let i = 0; i < parts.length; i++) {
43+
let path = parts.slice(0, i)
44+
let layer_name = parts[i]
45+
if (layer_name) {
46+
// Only add location to the final layer in dotted notation
47+
// Create a new copy to avoid sharing references
48+
let loc = i === parts.length - 1 ? create_location(node) : undefined
49+
root.add_child(path, layer_name, loc)
50+
}
4251
}
4352
}
4453
} else {

test/global.spec.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ test('mixed imports and layers', () => {
5858
{
5959
name: '__anonymous-2__',
6060
is_anonymous: true,
61-
locations: [{ line: 10, column: 3, start: 176, end: 185 }],
61+
locations: [{ line: 10, column: 3, start: 176 }],
6262
children: [],
6363
},
6464
]
@@ -76,70 +76,70 @@ test('the fokus.dev boilerplate', () => {
7676
{
7777
name: 'core',
7878
is_anonymous: false,
79-
locations: [{ line: 2, column: 3, start: 3, end: 49 }],
79+
locations: [{ line: 2, column: 3, start: 3 }],
8080
children: [
8181
{
8282
name: 'reset',
8383
is_anonymous: false,
84-
locations: [{ line: 3, column: 3, start: 52, end: 94 }],
84+
locations: [{ line: 3, column: 3, start: 52 }],
8585
children: [],
8686
},
8787
{
8888
name: 'tokens',
8989
is_anonymous: false,
90-
locations: [{ line: 3, column: 3, start: 52, end: 94 }],
90+
locations: [{ line: 3, column: 3, start: 52 }],
9191
children: [],
9292
},
9393
{
9494
name: 'base',
9595
is_anonymous: false,
96-
locations: [{ line: 3, column: 3, start: 52, end: 94 }],
96+
locations: [{ line: 3, column: 3, start: 52 }],
9797
children: [],
9898
},
9999
],
100100
},
101101
{
102102
name: 'third-party',
103103
is_anonymous: false,
104-
locations: [{ line: 2, column: 3, start: 3, end: 49 }],
104+
locations: [{ line: 2, column: 3, start: 3 }],
105105
children: [
106106
{
107107
name: 'imports',
108108
is_anonymous: false,
109-
locations: [{ line: 4, column: 3, start: 97, end: 147 }],
109+
locations: [{ line: 4, column: 3, start: 97 }],
110110
children: [],
111111
},
112112
{
113113
name: 'overrides',
114114
is_anonymous: false,
115-
locations: [{ line: 4, column: 3, start: 97, end: 147 }],
115+
locations: [{ line: 4, column: 3, start: 97 }],
116116
children: [],
117117
},
118118
],
119119
},
120120
{
121121
name: 'components',
122122
is_anonymous: false,
123-
locations: [{ line: 2, column: 3, start: 3, end: 49 }],
123+
locations: [{ line: 2, column: 3, start: 3 }],
124124
children: [
125125
{
126126
name: 'base',
127127
is_anonymous: false,
128-
locations: [{ line: 5, column: 3, start: 150, end: 196 }],
128+
locations: [{ line: 5, column: 3, start: 150 }],
129129
children: [],
130130
},
131131
{
132132
name: 'variations',
133133
is_anonymous: false,
134-
locations: [{ line: 5, column: 3, start: 150, end: 196 }],
134+
locations: [{ line: 5, column: 3, start: 150 }],
135135
children: [],
136136
},
137137
],
138138
},
139139
{
140140
name: 'utility',
141141
is_anonymous: false,
142-
locations: [{ line: 2, column: 3, start: 3, end: 49 }],
142+
locations: [{ line: 2, column: 3, start: 3 }],
143143
children: [],
144144
},
145145
]

0 commit comments

Comments
 (0)