Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/parse-declaration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ describe('parse_declaration', () => {
const node = parse_declaration('-o-color: red')
expect(node.is_browserhack).toBe(false)
})

test('custom property is not a browserhack', () => {
const node = parse_declaration('--custom: red')
expect(node.is_browserhack).toBe(false)
})
})

describe('Value Parsing', () => {
Expand Down
8 changes: 6 additions & 2 deletions src/parse-declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,13 @@ export class DeclarationParser {
browser_hack_line = lexer.token_line
browser_hack_column = lexer.token_column
} else if (first_char === 45) {
// '-' - hyphen prefix could be vendor prefix or browser hack
// '-' - hyphen prefix could be vendor prefix, custom property, or browser hack
// Check if it's a custom property (starts with --)
const second_char = this.source.charCodeAt(lexer.token_start + 1)
const is_custom_property = second_char === 45 // '--'

// Use fast vendor prefix check (no allocations)
if (!is_vendor_prefixed(this.source, lexer.token_start, lexer.token_end)) {
if (!is_custom_property && !is_vendor_prefixed(this.source, lexer.token_start, lexer.token_end)) {
// This is a browser hack like -property
has_browser_hack = true
browser_hack_start = lexer.token_start
Expand Down