csstree/csstree (css-tree)
### [`v3.0.0`](https://redirect.github.com/csstree/csstree/blob/HEAD/CHANGELOG.md#300-September-11-2024)
[Compare Source](https://redirect.github.com/csstree/csstree/compare/v2.3.1...v3.0.0)
- Added support for the [`@container`](https://drafts.csswg.org/css-contain-3/#container-rule) at-rule
- Added support for the [`@starting-style`](https://drafts.csswg.org/css-transitions-2/#defining-before-change-style) at-rule
- Added support for the [`@scope`](https://drafts.csswg.org/css-cascade-6/#scoped-styles) at-rule
- Added support for the [`@position-try`](https://developer.mozilla.org/en-US/docs/Web/CSS/@position-try) at-rule
- Added support for the [`@layer`](https://drafts.csswg.org/css-cascade-5/#at-layer) at-rule
- Added support for `layer`, `layer()` and `supports()` in the `@media` at-rule (according to [the @import rule](https://drafts.csswg.org/css-cascade-5/#at-import) in Cascading and Inheritance 5)
- Added `Layer` and `LayerList` node types
- Added `TokenStream#lookupTypeNonSC()` method
- Added `` to generic types
- Bumped `mdn/data` to `2.10.0`
- Aligned `<'font'>` to [CSS Fonts 4](https://drafts.csswg.org/css-fonts-4/)
- Aligned `` to [CSS Color 5](https://drafts.csswg.org/css-color-5/)
- Fixed initialization when `Object.prototype` is extended or polluted ([#262](https://redirect.github.com/csstree/csstree/issues/262))
- Fixed `fork()` method to consider the `generic` option when creating a Lexer instance ([#266](https://redirect.github.com/csstree/csstree/issues/266))
- Fixed crash on parse error when custom `line` or `offset` is specified via options ([#251](https://redirect.github.com/csstree/csstree/issues/251))
- Fixed `speak` syntax patch ([#241](https://redirect.github.com/csstree/csstree/issues/241))
- Fixed `:lang()` to accept a list of `` or `` per [spec](https://drafts.csswg.org/selectors/#the-lang-pseudo) ([#265](https://redirect.github.com/csstree/csstree/issues/265))
- Fixed lexer matching for syntaxes referred to as `<'property'>`, when the syntax has a top-level `#`-multiplier ([#102](https://redirect.github.com/csstree/csstree/issues/102))
- Relaxed parsing of syntax definition to allow whitespaces in range multiplier ([#270](https://redirect.github.com/csstree/csstree/issues/270))
- Changed `parseWithFallback()` to rollback `tokenIndex` before calling a fallback
- Changed `Block` to not include `{` and `}`
- Changed `Atrule` and `Rule` to include `{` and `}` for a block
- Changed `Ratio` parsing:
- Left and right parts contain nodes instead of strings
- Both left and right parts of a ratio can now be any number; validation of number range is no longer within the parser's scope.
- Both parts can now be functions. Although not explicitly mentioned in the specification, mathematical functions can replace numbers, addressing potential use cases ([#162](https://redirect.github.com/csstree/csstree/issues/162)).
- As per the [CSS Values and Units Level 4](https://drafts.csswg.org/css-values-4/#ratios) specification, the right part of `Ratio` can be omitted. While this can't be a parser output (which would produce a `Number` node), it's feasible during `Ratio` node construction or transformation.
- Changes to query-related at-rules:
- Added new node types:
- [`Feature`](./docs/ast.md#feature): represents features like `(feature)` and `(feature: value)`, fundamental for both `@media` and `@container` at-rules
- [`FeatureRange`](./docs/ast.md#featurerange): represents [features in a range context](https://www.w3.org/TR/mediaqueries-4/#mq-range-context)
- [`FeatureFunction`](./docs/ast.md#featurefunction): represents functional features such as `@supports`'s `selector()` or `@container`'s `style()`
- [`Condition`](./docs/ast.md#condition): used across all query-like at-rules, encapsulating queries with features and the `not`, `and`, and `or` operators
- [`GeneralEnclosure`](./docs/ast.md#condition): represents the [``](https://www.w3.org/TR/mediaqueries-4/#typedef-general-enclosed) production, which caters to unparsed parentheses or functional expressions
> Note: All new nodes include a `kind` property to define the at-rule type. Supported kinds are `media`, `supports`, and `container`.
- Added support for functions for features and features in a range context, e.g. `(width: calc(100cm / 6))`
- Added a `condition` value for the parser's context option to parse queries. Use the `kind` option to specify the condition type, e.g., `parse('...', { context: 'condition', kind: 'media' })`.
- Introduced a `features` section in the syntax configuration for defining functional features of at-rules. Expand definitions using the `fork()` method. The current definition is as follows:
```js
features: {
supports: { selector() { /* ... */ } },
container: { style() { /* ... */ } }
}
```
- Changes for `@media` at-rule:
- Enhanced prelude parsing for complex queries. Parentheses with errors will be parsed as `GeneralEnclosed`.
- Added support for features in a range context, e.g. `(width > 100px)` or `(100px < height < 400px)`
- Transitioned from `MediaFeature` node type to the `Feature` node type with `kind: "media"`.
- Changed `MediaQuery` node structure into the following form:
```ts
type MediaQuery = {
type: "MediaQuery";
modifier: string | null; // e.g. "not", "only", etc.
mediaType: string | null; // e.g. "all", "screen", etc.
condition: Condition | null;
}
```
- Changes for `@supports` at-rule:
- Enhanced prelude parsing for complex queries. Parentheses with errors will be parsed as `GeneralEnclosed`.
- Added support for features in a range context, e.g. `(width > 100px)` or `(100px < height < 400px)`
- Added `SupportsDeclaration` node type to encapsulate a declaration in a query, replacing `Parentheses`.
- Parsing now employs `Condition` or `SupportsDeclaration` nodes of kind `supports` instead of `Parentheses`.
- Added support for the [`selector()`](https://drafts.csswg.org/css-conditional-4/#at-supports-ext) feature via the `FeatureFunction` node (configured in `features.supports.selector`).
### [`v2.3.1`](https://redirect.github.com/csstree/csstree/blob/HEAD/CHANGELOG.md#231-December-14-2022)
[Compare Source](https://redirect.github.com/csstree/csstree/compare/v2.3.0...v2.3.1)
- Added `:host`, `:host()` and `:host-context()` pseudo class support ([#216](https://redirect.github.com/csstree/csstree/issues/216))
- Fixed `generator`, `parse` and `parse-selector` entry points by adding missed `NestedSelector` node type
- Removed npm > 7 version requirement ([#218](https://redirect.github.com/csstree/csstree/issues/218))
### [`v2.3.0`](https://redirect.github.com/csstree/csstree/blob/HEAD/CHANGELOG.md#230-November-30-2022)
[Compare Source](https://redirect.github.com/csstree/csstree/compare/v2.2.1...v2.3.0)
- Added [CSS Nesting](https://www.w3.org/TR/css-nesting-1/) support:
- Added `NestingSelector` node type for `&` (a nesting selector) in selectors
- Added `@nest` at-rule
- Changed behaviour for `@media` inside a `Rule` to parse its block content as a `Declaration` first
- Changed `DeclarationList` behaviour to follow the rules for `Rule`'s block
- Added the dimension units introspection & customisation:
- Added `Lexer#units` dictionary to provide unit groups (`length`, `angle`, etc.) used for matching
- Changed Lexer's constructor to take into consideration `config.units` to override default units
- Extended lexer's dump to contain a units dictionary
- Bumped `mdn-data` to `2.0.30`
### [`v2.2.1`](https://redirect.github.com/csstree/csstree/blob/HEAD/CHANGELOG.md#221-August-14-2022)
[Compare Source](https://redirect.github.com/csstree/csstree/compare/v2.2.0...v2.2.1)
- Fixed a regression added in `2.2.0` for at-rule syntax matching when at-rule has no prelude
### [`v2.2.0`](https://redirect.github.com/csstree/csstree/blob/HEAD/CHANGELOG.md#220-August-10-2022)
[Compare Source](https://redirect.github.com/csstree/csstree/compare/v2.1.0...v2.2.0)
- Bumped `mdn-data` to `2.0.28`
- Added support for CSS wide keywords `revert` and `revert-layer`
- Dropped support for `expression()` the same way as CSS wide keywords
- Patched `background-clip` property definition to match [Backgrounds and Borders 4](https://drafts.csswg.org/css-backgrounds-4/#background-clip) ([#190](https://redirect.github.com/csstree/csstree/issues/190))
- Patched `content` property definition to allow `attr()` ([#201](https://redirect.github.com/csstree/csstree/issues/201))
- Fixed definition syntax matching when a comma is expected before a ``
- Fixed at-rule validation fail when no prelude is specified and its syntax allows an empty prelude, that's the case for `@page` at-rule ([#191](https://redirect.github.com/csstree/csstree/issues/191))
- Added new units according to current state of [CSS Values and Units 4](https://drafts.csswg.org/css-values-4/): `rex`, `cap`, `rcap`, `rch`, `ic`, `ric`, `lh`, `rlh`, `vi`, `vb`, `sv*`, `lv*`, `dv*`
- Added container relative length units from [CSS Containment 3](https://drafts.csswg.org/css-contain-3/#container-lengths): `cqw`, `cqh`, `cqi`, `cqb`, `cqmin`, `cqmax`
- Removed `vm` unit (supposed to be an old IE versions supported this unit instead of `vmax`)
- Value definition syntax:
- Added support for stacked multipliers `+#` and `#?` according to spec ([#199](https://redirect.github.com/csstree/csstree/issues/199))
- Added parsing of a dimension in range definition notations, however, a validation for such ranges is not supported yet ([#192](https://redirect.github.com/csstree/csstree/issues/192))
- Changed parsing of range definition notation to not omitting `[-∞,∞]` ranges
### [`v2.1.0`](https://redirect.github.com/csstree/csstree/blob/HEAD/CHANGELOG.md#210-February-17-2022)
[Compare Source](https://redirect.github.com/csstree/csstree/compare/v2.0.4...v2.1.0)
- Bumped `mdn-data` to `2.0.27`
- Added `module` field to `package.json`
- Fixed minor issues in CommonJS version
- Fixed `css-tree/utils` export ([#181](https://redirect.github.com/csstree/csstree/issues/181))
- Added `css-tree/convertor` export
- Added `css-tree/selector-parser` export (~27kb when bundled, [#183](https://redirect.github.com/csstree/csstree/issues/183))
- Reduced bundle size:
- `css-tree/parser` 50kb -> 41kb
- `css-tree/generator` 46kb -> 23kb
- Renamed `syntaxes` into `types` in `css-tree/definition-syntax-data-patch`
- Added parsing support for `:is()`, `:-moz-any()`, `:-webkit-any()` and `:where()` ([#182](https://redirect.github.com/csstree/csstree/issues/182), [#184](https://redirect.github.com/csstree/csstree/issues/184))
### [`v2.0.4`](https://redirect.github.com/csstree/csstree/blob/HEAD/CHANGELOG.md#204-December-17-2021)
[Compare Source](https://redirect.github.com/csstree/csstree/compare/v2.0.3...v2.0.4)
- Extended Node.js support to include `^10`
- Fixed `generate()` in safe mode to add a whitespace between `` and ``, otherwise some values are broken in IE11, e.g. `border` properties ([#173](https://redirect.github.com/csstree/csstree/issues/173))
- Removed allowance for `:` for an attribute name on `AttributeSelector` parsing as it does not meet the CSS specs ([details](https://redirect.github.com/csstree/csstree/discussions/149))
### [`v2.0.3`](https://redirect.github.com/csstree/csstree/blob/HEAD/CHANGELOG.md#203-December-14-2021)
[Compare Source](https://redirect.github.com/csstree/csstree/compare/v2.0.2...v2.0.3)
- Fixed unintended whitespace on `generate()` in `safe` mode between `type-selector` and `id-selector` (e.g. `a#id`). A regression was introduces in `2.0.2` since IE11 fails on values when `` goes after `` without a whitespace in the middle, e.g. `1px solid#000`. Thus, in one case, a space between the `` and the `` is required, and in the other, vice versa. Until a better solution found, a workaround is used on `id-selector` generation by producing a `` instead of ``.
### [`v2.0.2`](https://redirect.github.com/csstree/csstree/blob/HEAD/CHANGELOG.md#202-December-10-2021)
[Compare Source](https://redirect.github.com/csstree/csstree/compare/v2.0.1...v2.0.2)
- Updated `width`, `min-width` and `max-width` syntax definitions
- Patched counter related syntaxes to match specs until updated in `mdn-data`
- Replaced `source-map` with `source-map-js` which reduce install size by ~700KB
- Fixed `calc()` function consumption on definition syntax matching
- Fixed `generate()` auto emitting a whitespace edge cases when next token starts with a dash (minus)
- Fixed `generate()` safe mode to cover more cases for IE11
- Fixed CommonJS bundling by adding browser files `dist/data.cjs` and `dist/version.cjs`
- Added exports:
- `css-tree/definition-syntax-data`
- `css-tree/definition-syntax-data-patch`
### [`v2.0.1`](https://redirect.github.com/csstree/csstree/blob/HEAD/CHANGELOG.md#201-December-4-2021)
[Compare Source](https://redirect.github.com/csstree/csstree/compare/v2.0.0...v2.0.1)
- Extended Node.js support to include `^12.20.0` and `^14.13.0` versions
### [`v2.0.0`](https://redirect.github.com/csstree/csstree/blob/HEAD/CHANGELOG.md#200-December-3-2021)
[Compare Source](https://redirect.github.com/csstree/csstree/compare/v1.1.3...v2.0.0)
- Package
- Dropped support for Node.js prior 14.16 (following patch versions changed it to `^10 || ^12.20.0 || ^14.13.0 || >=15.0.0`)
- Converted to ES modules. However, CommonJS is supported as well (dual module)
- Added exports for standalone parts instead of internal paths usage (use as `import * as parser from "css-tree/parser"` or `require("css-tree/parser")`):
- `css-tree/tokenizer`
- `css-tree/parser`
- `css-tree/walker`
- `css-tree/generator`
- `css-tree/lexer`
- `css-tree/definition-syntax`
- `css-tree/utils`
- Changed bundle set to provide `dist/csstree.js` (an IIFE version with `csstree` as a global name) and `dist/csstree.esm.js` (as ES module). Both are minified
- Bumped `mdn-data` to `2.0.23`
- Tokenizer
- Changed `tokenize()` to take a function as second argument, which will be called for every token. No stream instance is creating when second argument is ommited.
- Changed `TokenStream#getRawLength()` to take second parameter as a function (rule) that check a char code to stop a scanning
- Added `TokenStream#forEachToken(fn)` method
- Removed `TokenStream#skipWS()` method
- Removed `TokenStream#getTokenLength()` method
- Parser
- Moved `SyntaxError` (custom parser's error class) from root of public API to parser via `parse.SyntaxError`
- Removed `parseError` field in parser's `SyntaxError`
- Changed selector parsing to produce `{ type: 'Combinator', name: ' ' }` node instead of `WhiteSpace` node
- Removed producing of `WhiteSpace` nodes with the single exception for a custom property declaration with a single white space token as a value
- Parser adds a whitespace to `+` and `-` operators, when a whitespace is before and/or after an operator
- Exposed parser's inner configuration as `parse.config`
- Added `consumeUntilBalanceEnd()`, `consumeUntilLeftCurlyBracket()`, `consumeUntilLeftCurlyBracketOrSemicolon()`, `consumeUntilExclamationMarkOrSemicolon()` and `consumeUntilSemicolonIncluded()` methods to parser's inner API to use with `Raw` instead of `Raw.mode`
- Changed `Nth` to always consume `of` clause when presented, so it became more general and moves validation to lexer
- Changed `String` node type to store decoded string value, i.e. with no quotes and escape sequences
- Changed `Url` node type to store decoded url value as a string instead of `String` or `Raw` node, i.e. with no quotes, escape sequences and `url()` wrapper
- Generator
- Generator is now determines itself when a white space required between emitting tokens
- Changed `chunk()` handler to `token()` (output a single token) and `tokenize()` (split a string into tokens and output each of them)
- Added `mode` option for `generate()` to specify a mode of token separation: `spec` or `safe` (by default)
- Added `emit(token, type, auto)` handler as implementation specific token processor
- Changed `Nth` to serialize `+n` as `n`
- Added auto-encoding for a `string` and `url` tokens on serialization
- Lexer
- Removed `Lexer#matchDeclaration()` method
- Utils
- Added `ident`, `string` and `url` helpers to decode/encode corresponding values, e.g. `url.decode('url("image.jpg")')` === `'image.jpg'`
- List
- Changed `List` to be iterable (iterates data)
- Changed `List#first`, `List#last` and `List#isEmpty` to getters
- Changed `List#getSize()` method to `List#size` getter
- Removed `List#each()` and `List#eachRight()` methods, `List#forEach()` and `List#forEachRight()` should be used instead
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Never, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
[ ] If you want to rebase/retry this PR, check this box
This PR contains the following updates:
^1.1.3
->^3.0.0
Release Notes
csstree/csstree (css-tree)
### [`v3.0.0`](https://redirect.github.com/csstree/csstree/blob/HEAD/CHANGELOG.md#300-September-11-2024) [Compare Source](https://redirect.github.com/csstree/csstree/compare/v2.3.1...v3.0.0) - Added support for the [`@container`](https://drafts.csswg.org/css-contain-3/#container-rule) at-rule - Added support for the [`@starting-style`](https://drafts.csswg.org/css-transitions-2/#defining-before-change-style) at-rule - Added support for the [`@scope`](https://drafts.csswg.org/css-cascade-6/#scoped-styles) at-rule - Added support for the [`@position-try`](https://developer.mozilla.org/en-US/docs/Web/CSS/@position-try) at-rule - Added support for the [`@layer`](https://drafts.csswg.org/css-cascade-5/#at-layer) at-rule - Added support for `layer`, `layer()` and `supports()` in the `@media` at-rule (according to [the @import rule](https://drafts.csswg.org/css-cascade-5/#at-import) in Cascading and Inheritance 5) - Added `Layer` and `LayerList` node types - Added `TokenStream#lookupTypeNonSC()` method - Added `Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Never, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.