3.0.0
- Added support for the
@container
at-rule - Added support for the
@starting-style
at-rule - Added support for the
@scope
at-rule - Added support for the
@position-try
at-rule - Added support for the
@layer
at-rule - Added support for
layer
,layer()
andsupports()
in the@media
at-rule (according to the @import rule in Cascading and Inheritance 5) - Added
Layer
andLayerList
node types - Added
TokenStream#lookupTypeNonSC()
method - Added
<dashed-ident>
to generic types - Bumped
mdn/data
to2.10.0
- Aligned
<'font'>
to CSS Fonts 4 - Aligned
<color>
to CSS Color 5 - Fixed initialization when
Object.prototype
is extended or polluted (#262) - Fixed
fork()
method to consider thegeneric
option when creating a Lexer instance (#266) - Fixed crash on parse error when custom
line
oroffset
is specified via options (#251) - Fixed
speak
syntax patch (#241) - Fixed
:lang()
to accept a list of<ident>
or<string>
per spec (#265) - Fixed lexer matching for syntaxes referred to as
<'property'>
, when the syntax has a top-level#
-multiplier (#102) - Relaxed parsing of syntax definition to allow whitespaces in range multiplier (#270)
- Changed
parseWithFallback()
to rollbacktokenIndex
before calling a fallback - Changed
Block
to not include{
and}
- Changed
Atrule
andRule
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).
- As per the CSS Values and Units Level 4 specification, the right part of
Ratio
can be omitted. While this can't be a parser output (which would produce aNumber
node), it's feasible duringRatio
node construction or transformation.
- Changes to query-related at-rules:
- Added new node types:
Feature
: represents features like(feature)
and(feature: value)
, fundamental for both@media
and@container
at-rulesFeatureRange
: represents features in a range contextFeatureFunction
: represents functional features such as@supports
'sselector()
or@container
'sstyle()
Condition
: used across all query-like at-rules, encapsulating queries with features and thenot
,and
, andor
operatorsGeneralEnclosure
: represents the<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 aremedia
,supports
, andcontainer
- 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 thekind
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 thefork()
method. The current definition is as follows: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 theFeature
node type withkind: "media"
- Changed
MediaQuery
node structure into the following form:type MediaQuery = { type: "MediaQuery"; modifier: string | null; // e.g. "not", "only", etc. mediaType: string | null; // e.g. "all", "screen", etc. condition: Condition | null; }
- Enhanced prelude parsing for complex queries. Parentheses with errors will be parsed as
- 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, replacingParentheses
- Parsing now employs
Condition
orSupportsDeclaration
nodes of kindsupports
instead ofParentheses
- Added support for the
selector()
feature via theFeatureFunction
node (configured infeatures.supports.selector
)
- Enhanced prelude parsing for complex queries. Parentheses with errors will be parsed as
- Added new node types: