Skip to content

Variable: CSSDOC_MODIFIER_ATTRIBUTE ​

ts
const CSSDOC_MODIFIER_ATTRIBUTE: Regex<"\\[(?<name>[\\w-]+)(?:=(?<value>[\"']?[^\\]]*?)(?<quote>[\"'])?)\\?\\]", {
  flags: "u";
  names: {
     name: string;
     quote?: string;
     value?: string;
  };
}>;

Defined in: packages/regex/src/tiers/css-doc-grammar.ts:112

CssDoc Modifier Name - Attribute Form from grammar. Alternative form: attribute selector on the base (e.g., .base[disabled]). Grammar rule: AttributeModifier :: '[' ... ']'

Note: Simplified to avoid backreferences for better compatibility.

Examples ​

ts
const match = CSSDOC_MODIFIER_ATTRIBUTE.exec("[disabled]");
match?.groups?.name // "disabled"
match?.groups?.value // undefined
ts
const match = CSSDOC_MODIFIER_ATTRIBUTE.exec("[aria-pressed=true]");
match?.groups?.name // "aria-pressed"
match?.groups?.value // "true"

Released under the MIT License