Packages

css-tree

3.2.1 · 5 Mar 2026MIT183.3M / weekRepositoryHomepagenpmAtom feed

Your version

3.2.0

5 Mar 2026Where it was published

3.2.1 is the newest release of 3.x.

In short

7 new1 fixed7 changed

Release note

  • Added "sideEffects": false in package.json

  • Added list option to the parse() method to specify whether the parser should produce a List (by default, list: true) or an array (list: false) for node's children (e.g., SelectorList, Block, etc.)

  • Added support for Functional Notation in definition syntax (for now by wrapping function arguments into an implicit group when necessary, see #292)

  • Added support for stacked multipliers {A}? and {A,B}? according to spec in definition syntax parsing

  • Added math functions support in syntax matching (e.g., min(), max(), etc.)

  • Added onToken option to the parse() method, which can be either an array or a function:

    • When the value is an array, it is populated with objects { type, start, end } (token type, and its start and end offsets).

    • When the value is a function, it accepts type, start, end, and index parameters, and is invoked with a token API as this, enabling advanced token handling (see onToken). For example, the following demonstrates checking if all block tokens have matching pairs:

      parse(css, {
          onToken(type, start, end, index) {
              if (this.isBlockOpenerTokenType(type)) {
                  if (this.getBlockPairTokenIndex(index) === -1) {
                      console.warn('No closing pair for', this.getTokenValue(index), this.getRangeLocation(start, end));
                  }
              } else if (this.isBlockCloserTokenType(type)) {
                  if (this.getBlockPairTokenIndex(index) === -1) {
                      console.warn('No opening pair for', this.getTokenValue(index), this.getRangeLocation(start, end));
                  }
              }
          }
      });
  • Extended TokenStream with the following methods:

    • getTokenEnd(tokenIndex) – returns the token's end offset by index, complementing getTokenStart(tokenIndex)

    • getTokenType(tokenIndex) – returns the token's type by index

    • isBlockOpenerTokenType(tokenType) – returns true for <function-token>, <(-token>, <[-token>, and <{-token>

    • isBlockCloserTokenType(tokenType) – returns true for <)-token>, <]-token>, and <}-token>

    • getBlockTokenPairIndex(tokenIndex) – returns the index of the pair token for a block, or -1 if no pair exists

  • Changed generate() to not auto insert whitespaces between tokens for raw values

  • Fixed fork() to extend node definitions instead of overriding them. For example, fork({ node: { Dimension: { generate() { /* ... */ } } } }) will now update only the generate() method on the Dimension node, while inheriting all other properties from the previous syntax definition.

  • Bumped mdn/data to 2.27.1 and various fixes in syntaxes

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.