diff --git a/src/css-node.ts b/src/css-node.ts index b4a4613..03268f8 100644 --- a/src/css-node.ts +++ b/src/css-node.ts @@ -37,7 +37,6 @@ import { SUPPORTS_QUERY, LAYER_NAME, PRELUDE_OPERATOR, - FLAG_IMPORTANT, FLAG_HAS_ERROR, FLAG_HAS_BLOCK, FLAG_HAS_DECLARATIONS, @@ -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) diff --git a/src/parse.ts b/src/parse.ts index b375d65..da8fa2e 100644 --- a/src/parse.ts +++ b/src/parse.ts @@ -8,7 +8,6 @@ import { DECLARATION, AT_RULE, BLOCK, - FLAG_IMPORTANT, FLAG_HAS_BLOCK, FLAG_HAS_DECLARATIONS, } from './arena' @@ -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()) { @@ -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 @@ -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