Skip to content
Closed
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
8 changes: 5 additions & 3 deletions src/css-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {
SUPPORTS_QUERY,
LAYER_NAME,
PRELUDE_OPERATOR,
FLAG_IMPORTANT,
FLAG_HAS_ERROR,
FLAG_HAS_BLOCK,
FLAG_HAS_DECLARATIONS,
Expand Down Expand Up @@ -305,10 +304,13 @@ export class CSSNode {
return parse_dimension(this.text).unit
}

// Check if this declaration has !important
// Check if this declaration has !important (computed on-demand)
get is_important(): boolean | null {
if (this.type !== DECLARATION) return null
return this.arena.has_flag(this.index, FLAG_IMPORTANT)
// Check if full declaration text contains ! followed by identifier
// This matches !important, !ie (historic), and any other ! + identifier
// (value property excludes the ! part, so we check the full text)
return /!\s*\w+/.test(this.text)
}

// Check if this has a vendor prefix (computed on-demand)
Expand Down
8 changes: 0 additions & 8 deletions src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
DECLARATION,
AT_RULE,
BLOCK,
FLAG_IMPORTANT,
FLAG_HAS_BLOCK,
FLAG_HAS_DECLARATIONS,
} from './arena'
Expand Down Expand Up @@ -325,7 +324,6 @@ export class Parser {
let value_end = value_start

// Parse value (everything until ';' or '}')
let has_important = false
let last_end = this.lexer.token_end

while (!this.is_eof()) {
Expand All @@ -346,7 +344,6 @@ export class Parser {
// Check if next token is an identifier
let next_type = this.lexer.next_token_fast()
if (next_type === TOKEN_IDENT) {
has_important = true
last_end = this.lexer.token_end
this.next_token() // Advance to next token after "important"
break
Expand Down Expand Up @@ -374,11 +371,6 @@ export class Parser {
}
}

// Set !important flag if found
if (has_important) {
this.arena.set_flag(declaration, FLAG_IMPORTANT)
}

// Consume ';' if present
if (this.peek_type() === TOKEN_SEMICOLON) {
last_end = this.lexer.token_end
Expand Down