Skip to content

Commit b792845

Browse files
authored
fix: make value property work for Layer name in artrule prelude (#93)
1 parent 70f30c2 commit b792845

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/css-node.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,10 @@ export class CSSNode {
189189
this.index = index
190190
}
191191

192-
/** Get the arena (for internal/advanced use only) */
192+
/**
193+
* @internal
194+
* Get the arena (for internal/advanced use only)
195+
*/
193196
__get_arena(): CSSDataArena {
194197
return this.arena
195198
}

src/parse-atrule-prelude.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,7 @@ describe('At-Rule Prelude Nodes', () => {
518518
expect(children.some((c) => c.type === SUPPORTS_QUERY)).toBe(true)
519519

520520
const query = children.find((c) => c.type === SUPPORTS_QUERY)
521-
expect(query?.value).toContain('display')
522-
expect(query?.value).toContain('flex')
521+
expect(query?.value).toContain('display: flex')
523522
})
524523

525524
it('should trim whitespace and comments from supports queries', () => {
@@ -560,7 +559,9 @@ describe('At-Rule Prelude Nodes', () => {
560559
const children = atRule?.children.filter((c) => c.type !== BLOCK) || []
561560
expect(children.length).toBe(1)
562561
expect(children[0].type).toBe(LAYER_NAME)
562+
expect(children[0].type_name).toBe('Layer')
563563
expect(children[0].text).toBe('base')
564+
expect(children[0].value).toBe('base')
564565
})
565566

566567
it('should parse comma-separated layer names', () => {
@@ -573,12 +574,15 @@ describe('At-Rule Prelude Nodes', () => {
573574

574575
expect(children[0].type).toBe(LAYER_NAME)
575576
expect(children[0].text).toBe('base')
577+
expect(children[0].value).toBe('base')
576578

577579
expect(children[1].type).toBe(LAYER_NAME)
578580
expect(children[1].text).toBe('components')
581+
expect(children[1].value).toBe('components')
579582

580583
expect(children[2].type).toBe(LAYER_NAME)
581584
expect(children[2].text).toBe('utilities')
585+
expect(children[2].value).toBe('utilities')
582586
})
583587
})
584588

src/parse-atrule-prelude.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@ export class AtRulePreludeParser {
346346
if (token_type === TOKEN_IDENT) {
347347
// Layer name
348348
let layer = this.create_node(LAYER_NAME, this.lexer.token_start, this.lexer.token_end)
349+
// Set value to the layer name text (same as the full node text)
350+
this.arena.set_value_start_delta(layer, 0)
351+
this.arena.set_value_length(layer, this.lexer.token_end - this.lexer.token_start)
349352
nodes.push(layer)
350353
} else if (token_type === TOKEN_COMMA) {
351354
// Skip comma separator

0 commit comments

Comments
 (0)