Skip to content

Commit 3d58cb1

Browse files
authored
fix: custom property is not a browserhack (#91)
1 parent 2e3b881 commit 3d58cb1

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/parse-declaration.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ describe('parse_declaration', () => {
206206
const node = parse_declaration('-o-color: red')
207207
expect(node.is_browserhack).toBe(false)
208208
})
209+
210+
test('custom property is not a browserhack', () => {
211+
const node = parse_declaration('--custom: red')
212+
expect(node.is_browserhack).toBe(false)
213+
})
209214
})
210215

211216
describe('Value Parsing', () => {

src/parse-declaration.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,13 @@ export class DeclarationParser {
7474
browser_hack_line = lexer.token_line
7575
browser_hack_column = lexer.token_column
7676
} else if (first_char === 45) {
77-
// '-' - hyphen prefix could be vendor prefix or browser hack
77+
// '-' - hyphen prefix could be vendor prefix, custom property, or browser hack
78+
// Check if it's a custom property (starts with --)
79+
const second_char = this.source.charCodeAt(lexer.token_start + 1)
80+
const is_custom_property = second_char === 45 // '--'
81+
7882
// Use fast vendor prefix check (no allocations)
79-
if (!is_vendor_prefixed(this.source, lexer.token_start, lexer.token_end)) {
83+
if (!is_custom_property && !is_vendor_prefixed(this.source, lexer.token_start, lexer.token_end)) {
8084
// This is a browser hack like -property
8185
has_browser_hack = true
8286
browser_hack_start = lexer.token_start

0 commit comments

Comments
 (0)