- 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
- Changed
- Parser
- Changed selector parsing to produce
{ type: 'Combinator', name: ' ' }
node instead ofWhiteSpace
node - Don't produce
WhiteSpace
nodes anymore, with the single exception: 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()
andconsumeUntilSemicolonIncluded()
methods to parser's inner API to use withRaw
instead ofRaw.mode
- Changed selector parsing to produce
- Generator
- Generator is now determines itself when a white space required between emitting tokens
- Changed
chunk()
handler totoken()
(output a single token) andtokenize()
(split a string into tokens and output each of them) - Added
mode
option forgenerate()
to specify a mode of token separation:spec
orsafe
(by default) - Added
emit(token, type, auto)
handler as implementation specific token processor - Changed
Nth
serialiation to serialize+n
asn
- Lexer
- Removed
Lexer#matchDeclaration()
method - Fixed
Lexer#dump()
to dump atrules syntaxes as well
- Removed
- List
- Changed
List
to be iterable (iterates data) - Changed
List#first
,List#last
andList#isEmpty
to getters - Changed
List#getSize()
method toList#size
getter - Removed
List#each()
andList#eachRight()
methods,List#forEach()
andList#forEachRight()
should be used instead
- Changed
- Bumped
mdn-data
to 2.0.14 - Extended
fork()
method to allow append syntax instead of overriding fortypes
,properties
andatrules
, e.g.csstree.fork({ types: { color: '| foo | bar' } })
- Extended lexer API for validation
- Added
Lexer#checkAtruleName(atruleName)
,Lexer#checkAtrulePrelude(atruleName, prelude)
,Lexer#checkAtruleDescriptorName(atruleName, descriptorName)
andLexer#checkPropertyName(propertyName)
- Added
Lexer#getAtrule(atruleName, fallbackBasename)
method - Extended
Lexer#getAtrulePrelude()
andLexer#getProperty()
methods to takefallbackBasename
parameter - Improved SyntaxMatchError location details
- Changed error messages
- Added
- Fixed edge cases for parsing of custom property value with a single whitespace when
parseCustomProperty:true
- Added
onComment
option to parser config - Added support for
break
andskip
values inwalk()
to control traversal - Added
List#reduce()
andList#reduceRight()
methods - Bumped
mdn-data
to 2.0.12 - Exposed version of the lib (i.e.
import { version } from 'css-tree'
) - Fixed
Lexer#dump()
to dump atrules syntaxes as well - Fixed matching comma separated
<urange>
list (#135) - Renamed
HexColor
node type intoHash
- Removed
element()
specific parsing rules - Removed
dist/default-syntax.json
from package
- Fixed walker with
visit: "Declaration"
to iterateDeclarationList
(#114)
- Bumped
mdn-data
to2.0.6
- Added initial implmentation for at-rule matching via
Lexer#matchAtrulePrelude()
andLexer#matchAtruleDescriptor()
methods - Added
-moz-control-character-visibility
,-ms-grid-columns
,-ms-grid-rows
and-ms-hyphenate-limit-last
properties to patch (#111) - Added
flow
,flow-root
andtable-caption
values to patcheddisplay
(#112)
- Bumped
source-map
version to^0.6.1
to fix source map generation inconsistency across node.js versions due to mappings sorting bug and v8 moving to a stable Array#sort (fix commit insource-map
)
- Dropped support for Node < 8
- Updated dev deps (fixed
npm audit
issues) - Reworked build pipeline
- Package provides
dist/csstree.js
anddist/csstree.min.js
now (instead of singledist/csstree.js
that was a min version) - Bundle size (min version) reduced from 191Kb to 158Kb due to some optimisations
- Package provides
- Definition syntax
- Renamed
grammar
intodefinitionSyntax
(named per spec) - Added
compact
option togenerate()
method to avoid formatting (spaces) when possible
- Renamed
- Lexer
- Changed
dump()
method to produce syntaxes in compact form by default
- Changed
- Walker
- Changed implementation to avoid runtime compilation due to CSP issues (see #91, #109)
- Added
find()
,findLast()
andfindAll()
methods (e.g.csstree.find(ast, node => node.type === 'ClassSelector')
)
- Tokenizer
- Added
isBOM()
function - Added
charCodeCategory()
function - Removed
firstCharOffset()
function (useisBOM()
instead) - Removed
CHARCODE
dictionary - Removed
INPUT_STREAM_CODE*
dictionaries
- Added
- Lexer
- Allowed comments in matching value (just ignore them like whitespaces)
- Increased iteration count in value matching from 10k up to 15k
- Fixed missed
debugger
(#104)
- Lexer
- Fixed low priority productions matching by changing an approach for robust one (#103)
- Lexer
- Fixed low priority productions matching in long
||-
and&&-
groups (#103)
- Fixed low priority productions matching in long
- Bumped
mdn/data
to2.0.4
(#99) - Lexer
- Added bracketed range notation support and related refactoring
- Removed
<number-zero-one>
,<number-one-or-greater>
and<positive-integer>
from generic types. In fact, types moved to patch, because those types can be expressed in a regular grammar due to bracketed range notation implemented - Added support for multiple token string matching
- Improved
<custom-ident>
production matching to claim the keyword only if no other unfulfilled production can claim it (#101) - Improved
<length>
production matching to claim "unitless zero" only if no other unfulfilled production can claim it - Changed lexer's constructor to prevent generic types override when used
- Fixed large
||
- and&&
-group matching, matching continues from the beginning on term match (#85) - Fixed checking that value has
var()
occurrences when value is a string (such values can't be matched on syntax currently and fail with specific error that can be used for ignorance in validation tools) - Fixed
<declaration-value>
and<any-value>
matching when a value contains a function, parentheses or braces
- Bumped
mdn/data
to~2.0.3
- Removed type removals from
mdn/data
due to lack of some generic types and specific lexer restictions (since lexer was reworked, see below) - Reduced and updated patches
- Removed type removals from
- Tokenizer
- Reworked tokenizer itself to compliment CSS Syntax Module Level 3
Tokenizer
class splitted into several abstractions:- Added
TokenStream
class - Added
OffsetToLocation
class - Added
tokenize()
function that createsTokenStream
instance for given string or updates aTokenStream
instance passed as second parameter - Removed
Tokenizer
class
- Added
- Removed
Raw
token type - Renamed
Identifier
token type toIdent
- Added token types:
Hash
,BadString
,BadUrl
,Delim
,Percentage
,Dimension
,Colon
,Semicolon
,Comma
,LeftSquareBracket
,RightSquareBracket
,LeftParenthesis
,RightParenthesis
,LeftCurlyBracket
,RightCurlyBracket
- Replaced
Punctuator
withDelim
token type, that excludes specific characters with its own token type likeColon
,Semicolon
etc - Removed
findCommentEnd
,findStringEnd
,findDecimalNumberEnd
,findNumberEnd
,findEscapeEnd
,findIdentifierEnd
andfindUrlRawEnd
helper function - Removed
SYMBOL_TYPE
,PUNCTUATION
andSTOP_URL_RAW
dictionaries - Added
isDigit
,isHexDigit
,isUppercaseLetter
,isLowercaseLetter
,isLetter
,isNonAscii
,isNameStart
,isName
,isNonPrintable
,isNewline
,isWhiteSpace
,isValidEscape
,isIdentifierStart
,isNumberStart
,consumeEscaped
,consumeName
,consumeNumber
andconsumeBadUrlRemnants
helper functions
- Parser
- Changed parsing algorithms to work with new token type set
- Changed
HexColor
consumption in way to relax checking a value, i.e. nowvalue
is a sequence of one or more name chars - Added
&
as a property hack - Relaxed
var()
parsing to only check that a first arguments is an identifier (not a custom property name as before)
- Lexer
- Reworked syntax matching to relay on token set only (having AST is optional now)
- Extended
Lexer#match()
,Lexer#matchType()
andLexer#matchProperty()
methods to take a string as value, beside AST as a value - Extended
Lexer#match()
method to take a string as a syntax, beside of syntax descriptor - Reworked generic types:
- Removed
<attr()>
,<url>
(moved to patch) and<progid>
types - Added types:
- Related to token types:
<ident-token>
,<function-token>
,<at-keyword-token>
,<hash-token>
,<string-token>
,<bad-string-token>
,<url-token>
,<bad-url-token>
,<delim-token>
,<number-token>
,<percentage-token>
,<dimension-token>
,<whitespace-token>
,<CDO-token>
,<CDC-token>
,<colon-token>
,<semicolon-token>
,<comma-token>
,<[-token>
,<]-token>
,<(-token>
,<)-token>
,<{-token>
and<}-token>
- Complex types:
<an-plus-b>
,<urange>
,<custom-property-name>
,<declaration-value>
,<any-value>
and<zero>
- Related to token types:
- Renamed
<unicode-range>
to<urange>
as per spec - Renamed
<expression>
(IE legacy extension) to<-ms-legacy-expression>
and may to be removed in next releases
- Removed
- Lexer
- Syntax matching was completely reworked. Now it's token-based and uses state machine. Public API has not changed. However, some internal data structures have changed. Most significal change in syntax match result tree structure, it's became token-based instead of node-based.
- Grammar
- Changed grammar tree format:
- Added
Token
node type to represent a single code point (<delim-token>
) - Added
Multiplier
that wraps a single node (term
property) - Added
AtKeyword
to represent<at-keyword-token>
- Removed
Slash
andPercent
node types, they are replaced for a node withToken
type - Changed
Function
to represent<function-token>
with no children - Removed
multiplier
property fromGroup
- Added
- Changed
generate()
method:- Method takes an
options
as second argument now (generate(node, forceBraces, decorator)
->generate(node, options)
). Two options are supported:forceBraces
anddecorator
- When a second parameter is a function it treats as
decorate
option value, i.e.generate(node, fn)
->generate(node, { decorate: fn })
- Decorate function invokes with additional parameter – a reference to a node
- Method takes an
- Changed grammar tree format:
- Tokenizer
- Renamed
Atrule
const toAtKeyword
- Renamed
- Renamed
lexer.grammar.translate()
method intogenerate()
- Fixed
<'-webkit-font-smoothing'>
and<'-moz-osx-font-smoothing'>
syntaxes (#75) - Added vendor keywords for
<'overflow'>
property syntax (#76) - Pinned
mdn-data
to~1.1.0
and fixed issues with some updated property syntaxes
- Generator
- Changed node's
generate()
methods invocation, methods now take a node as a single argument and context (i.e.this
) that have methods:chunk()
,node()
andchildren()
- Renamed
translate()
togenerate()
and changed to takeoptions
argument - Removed
translateMarkup(ast, enter, leave)
method, usegenerate(ast, { decorator: (handlers) => { ... }})
instead - Removed
translateWithSourceMap(ast)
, usegenerate(ast, { sourceMap: true })
instead - Changed to support for children as an array
- Changed node's
- Walker
- Changed
walk()
to take anoptions
argument instead of handler, withenter
,leave
,visit
andreverse
options (walk(ast, fn)
is still works and equivalent towalk(ast, { enter: fn })
) - Removed
walkUp(ast, fn)
, usewalk(ast, { leave: fn })
- Removed
walkRules(ast, fn)
, usewalk(ast, { visit: 'Rule', enter: fn })
instead - Removed
walkRulesRight(ast, fn)
, usewalk(ast, { visit: 'Rule', reverse: true, enter: fn })
instead - Removed
walkDeclarations(ast, fn)
, usewalk(ast, { visit: 'Declaration', enter: fn })
instead - Changed to support for children as array in most cases (
reverse: true
will fail on arrays since they have noforEachRight()
method)
- Changed
- Misc
- List
- Added
List#forEach()
method - Added
List#forEachRight()
method - Added
List#filter()
method - Changed
List#map()
method to return aList
instance instead ofArray
- Added
List#push()
method, similar toList#appendData()
but returns nothing - Added
List#pop()
method - Added
List#unshift()
method, similar toList#prependData()
but returns nothing - Added
List#shift()
method - Added
List#prependList()
method - Changed
List#insert()
,List#insertData()
,List#appendList()
andList#insertList()
methods to return a list that performed an operation
- Added
- Changed
keyword()
method- Changed
name
field to include a vendor prefix - Added
basename
field to contain a name without a vendor prefix - Added
custom
field that contain atrue
when keyword is a custom property reference
- Changed
- Changed
property()
method- Changed
name
field to include a vendor prefix - Added
basename
field to contain a name without any prefixes, i.e. a hack and a vendor prefix
- Changed
- Added
vendorPrefix()
method - Added
isCustomProperty()
method
- List
- Tokenizer
- Added
Tokenizer#isBalanceEdge()
method - Removed
Tokenizer.endsWith()
method
- Added
- Parser
- Made the parser tolerant to errors by default
- Removed
tolerant
parser option (no parsing modes anymore) - Removed
property
parser option (a value parsing does not depend on property name anymore) - Canceled error for a handing semicolon in a block
- Canceled error for unclosed
Brackets
,Function
andParentheses
when EOF is reached - Fixed error when prelude ends with a comment for at-rules with custom prelude consumer
- Relaxed at-rule parsing:
- Canceled error when EOF is reached after a prelude
- Canceled error for an at-rule with custom block consumer when at-rule has no block (just don't apply consumer in that case)
- Canceled error on at-rule parsing when it occurs outside prelude or block (at-rule is converting to
Raw
node) - Allowed for any at-rule to have a prelude and a block, even if it's invalid per at-rule syntax (the responsibility for this check is moved to lexer, since it's possible to construct a AST with such errors)
- Made a declaration value a safe parsing point (i.e. error on value parsing lead to a value is turning into
Raw
node, not a declaration as before) - Excluded surrounding white spaces and comments from a
Raw
node that represents a declaration value - Changed
Value
parse handler to return a node only with typeValue
(previously it returned aRaw
node in some cases) - Fixed issue with
onParseError()
is not invoked for errors occured on selector or declaration value parsing in some cases - Changed using of
onParseError()
to stop parsing if handler throws an exception
- Lexer
- Changed
grammar.walk()
to invoke passed handler on entering to node rather than on leaving the node - Improved
grammar.walk()
to take a walk handler pair as an object, i.e.walk(node, { enter: fn, leave: fn })
- Changed
Lexer#match*()
methods to take a node of any type, but with achildren
field - Added
Lexer#match(syntax, node)
method - Fixed
Lexer#matchType()
method to stop return a positive result for the CSS wide keywords
- Changed
- Parser
- Added fallback node as argument to
onParseError()
handler - Fixed raw consuming in tolerant mode when selector is invalid (greedy consuming and redundant warnings)
- Fixed exception in tolerant mode caused by unknown at-rule with unclosed block
- Changed handling of semicolons:
- Hanging semicolon inside declaration blocks raise an error or turns into a
Raw
node in tolerant mode instead of being ignored - Semicolon outside of declaration blocks opens a
Rule
node as part of selector instead of being ignored
- Hanging semicolon inside declaration blocks raise an error or turns into a
- Aligned
parseAtrulePrelude
behaviour toparseRulePrelude
- Removed
Raw
node wraping intoAtrulePrelude
whenparseAtrulePrelude
is disabled - Removed error emitting when at-rule has a custom prelude customer but no prelude is found (it should be validated by a lexer later)
- Removed
- Added fallback node as argument to
- Generator
- Fixed performance issue with
translateWithSourceMap()
, flattening the string (because of mixing building string and indexing into it) turned it into a quadratic algorithm (approximate numbers can be found in the quiz created by this case)
- Fixed performance issue with
- Added support for a single solidus hack for
property()
- Minor fixes for custom errors
- Improved CSSTree to be stable for standart build-in objects extension (#58)
- Parser
- Renamed rule's
selector
toprelude
. The reasons: spec names this part so, and this branch can contain not only a selector (SelectorList
) but also a raw payload (Raw
). What's changed:- Renamed
Rule.selector
toRule.prelude
- Renamed
parseSelector
parser option toparseRulePrelude
- Removed option for selector parse in
SelectorList
- Renamed
- Renamed rule's
- Lexer
- Fixed undefined positions in a error when match a syntax to empty or white space only value
- Improved
Lexer#checkStructure()
- Return a warning as an object with node reference and message
- No exception on unknown node type, return a warning instead
- Fixed
Tokenizer#getRawLength()
's false positive balance match to the end of input in some cases (#56) - Rename walker's entry point methods to be the same as CSSTree exposed methods (i.e.
walk()
,walkUp()
etc) - Rename at-rule's
expression
toprelude
(since spec names it so)AtruleExpression
node type →AtrulePrelude
Atrule.expression
field →Atrule.prelude
parseAtruleExpression
parser's option →parseAtrulePrelude
atruleExpression
parse context →atrulePrelude
atruleExpression
walk context reference →atrulePrelude
- Parser
- Fixed exception on parsing of unclosed
{}-block
in tolerant mode - Added tolerant mode support for
DeclarationList
- Added standalone entry point, i.e. default parser can be used via
require('css-tree/lib/parser')
(#47)
- Fixed exception on parsing of unclosed
- Generator
- Changed generator to produce
+n
whenAnPlusB.a
is+1
to be "round-trip" with parser - Added standalone entry point, i.e. default generators can be used via
require('css-tree/lib/generator')
- Changed generator to produce
- Walker
- Added standalone entry point, i.e. default walkers can be used via
require('css-tree/lib/walker')
(#47)
- Added standalone entry point, i.e. default walkers can be used via
- Lexer
- Added
default
keyword to the list of invalid values for<custom-ident>
(since it reversed per spec)
- Added
- Convertors (
toPlainObject()
andfromPlainObject()
) moved tolib/convertor
(entry point isrequire('css-tree/lib/convertor')
)
- Tokenizer
- Added
Raw
token type - Improved tokenization of
url()
with raw as url to be more spec complient - Added
Tokenizer#balance
array computation on token layout - Added
Tokenizer#getRawLength()
to compute a raw length with respect of block balance - Added
Tokenizer#getTokenStart(offset)
method to get token start offset by token index - Added
idx
andbalance
fields to each token ofTokenizer#dump()
method result
- Added
- Parser
- Added
onParseError
option - Reworked node parsers that consume a
Raw
node to use a new approach. Since now aRaw
node builds inparser#Raw()
function only - Changed semantic of
parser#Raw()
, it takes 5 parameters now (it might to be changed in future) - Changed
parser#tolerantParse()
to pass a start token index to fallback function instead of source offset - Fixed
AtruleExpression
consuming in tolerant mode - Atrule handler to convert an empty
AtruleExpression
node intonull
- Changed
AtruleExpression
handler to always return a node (before it could return anull
in some cases)
- Added
- Lexer
- Fixed comma match node for
#
multiplier - Added reference name to
SyntaxReferenceError
- Fixed comma match node for
- Additional fixes on custom errors
- Reduced possible corruption of base config by
syntax.fork()
- Tokenizer
- Added
Atrule
token type (<at-rule-token>
per spec) - Added
Function
token type (<function-token>
per spec) - Added
Url
token type - Replaced
Tokenizer#getTypes()
method withTokenizer#dump()
to get all tokens as an array - Renamed
Tokenizer.TYPE.Whitespace
toTokenizer.TYPE.WhiteSpace
- Renamed
Tokenizer.findWhitespaceEnd()
toTokenizer.findWhiteSpaceEnd()
- Added
- Parser
- Added initial implementation of tollerant mode (turn on by passing
tolerant: true
option). In this mode parse errors are never occour and any invalid part of CSS turns into aRaw
node. Current safe points:Atrule
,AtruleExpression
,Rule
,Selector
andDeclaration
. Feature is experimental and further improvements are planned. - Changed
Atrule.expression
to contain aAtruleExpression
node ornull
only (other node types is wrapping into aAtruleExpression
node) - Renamed
AttributeSelector.operator
toAttributeSelector.matcher
- Added initial implementation of tollerant mode (turn on by passing
- Generator
translate()
method is now can take a function as second argument, that recieves every generated chunk. When no function is passed, default handler is used, it concats all the chunks and method returns a string.
- Lexer
- Used mdn/data package as source of lexer's grammar instead of local dictionaries
- Added
x
unit to<resolution>
generic type - Improved match tree:
- Omited Group (sequences) match nodes
- Omited empty match nodes (for terms with
zero or more
multipliers) - Added
ASTNode
node type to contain a reference to AST node - Fixed node duplication (uncompleted match were added to tree)
- Added AST node reference in match nodes
- Added comma match node by
#
multiplier
- Grammar
- Changed
translate()
function to get a handler as third argument (optional). That handler recieves result of node traslation and can be used for decoration purposes. See example - Added
SyntaxParseError
to grammar export - Reworked group and multipliers representation in syntax tree:
- Replaced
Sequence
forGroup
node type (Sequence
node type removed) - Added
explicit
boolean property forGroup
- Only groups can have a multiplier now (other node types is wrapping into a single term implicit group when multiplier is applied)
- Renamed
nonEmpty
Group's property todisallowEmpty
- Added optimisation for syntax tree by dropping redundant root
Group
when it contains a singleGroup
term (return thisGroup
as a result)
- Replaced
- Changed
- Changed lexer's match functionality
- Changed
Lexer#matchProperty()
andLexer#matchType()
to return an object instead of match tree. A match tree stores inmatched
field when AST is matched to grammar successfully, otherwise an error inerror
field. The result object also has some methods to test AST node against a match tree:getTrace()
,isType()
,isProperty()
andisKeyword()
- Added
Lexer#matchDeclaration()
method - Removed
Lexer#lastMatchError
(error stores in match result object inerror
field)
- Changed
- Added initial implementation of search for AST segments (new lexer methods:
Lexer#findValueSegments()
,Lexer#findDeclarationValueSegments()
andLexer#findAllSegments
) - Implemented
SyntaxReferenceError
for unknown property and type references
- Renamed field in resulting object of
property()
function:variable
→custom
- Fixed issue with readonly properties (e.g.
line
andcolumn
) ofError
and exception on attempt to write in iOS Safari
- Extended
List
class with new methods:List#prepend(item)
List#prependData(data)
List#insertData(data)
List#insertList(list)
List#replace(item, itemOrList)
- Added
atrule
walk context (#39) - Changed a result of generate method for
AnPlusB
,AttributeSelector
,Function
,MediaFeature
andRatio
(1e95877) - Fixed typo in
List
exception messages (@strarsis, #42) - Improved tokenizer to convert an input to a string
- Implemented new concept of
syntax
- Changed main
exports
to expose a default syntax - Defined initial CSS syntax
- Implemented
createSyntax()
method to create a new syntax from scratch - Implemented
fork()
method to create a new syntax based on given via extension
- Changed main
- Parser
- Implemented
mediaQueryList
andmediaQuery
parsing contexts - Implemented
CDO
andCDC
node types - Implemented additional declaration property prefix hacks (
#
and+
) - Added support for UTF-16LE BOM
- Added support for
@font-face
at-rule - Added
chroma()
to legacy IE filter functions - Improved
HexColor
to consume hex only - Improved support for
\0
and\9
hacks (#2) - Relaxed number check for
Ratio
terms- Allowed fractal values as a
Ratio
term - Disallowed zero number as a
Ratio
term
- Allowed fractal values as a
- Changed important clause parsing
- Allowed any identifier for important (to support hacks like
!ie
) - Store
true
forimportant
field in case identifier equals toimportant
and string otherwise
- Allowed any identifier for important (to support hacks like
- Fixed parse error formatted message rendering to take into account tabs
- Removed exposing of
Parser
class - Removed
readSelectorSequence()
,readSequenceFallback()
andreadSelectorSequenceFallback
methods - Used single universal sequence consumer for
AtruleExpression
,Selector
andValue
- Implemented
- Generator
- Reworked generator to use auto-generated functions based on syntax definition (additional work to be done in next releases)
- Implemented
translateMarkup(ast, before, after)
method for complex cases - Reworked
translateWithSourceMap
to be more flexible (based ontranslateMarkup
, additional work to be done in next releases)
- Walker
- Reworked walker to use auto-generated function based on syntax definition (additional work to be done in next releases)
- Lexer
- Prepared for better extensibility (additional work to be done in next releases)
- Implemented
checkStructure(ast)
method to check AST structure based on syntax definition - Update syntax dictionaries to latest
mdn/data
- Add missing
<'offset-position'>
syntax - Extended
<position>
property with-webkit-sticky
(@sergejmueller, #37)
- Add missing
- Improved mismatch error position
- Implemented script (
gen:syntax
) to generate AST format reference page (docs/ast.md
) using syntax definition
- Exposed
Parser
class - Added
startOffset
option toTokenizer
(constructor andsetSource()
method) - Added fallback functions for default (
readSequenceFallback
) and selector (readSelectorSequenceFallback
) sequence readers - Fixed edge cases for
AnPlusB
- Fixed wrong whitespace ignoring in
Selector
consumer
- Fixed broken
atruleExpression
context - Fixed vendor prefix detection in
keyword()
andproperty()
- Fixed
property()
to not lowercase custom property names - Added
variable
boolean flag inproperty()
result - Renamed
scanner
intotokenizer
- Ranamed
syntax
intolexer
- Moved
docs/*.html
files to csstree/docs repo - Added
element()
function forValue
context (-moz-element()
supported as well) - Merged
Universal
node type intoType
- Renamed node types:
Id
->IdSelector
Class
->ClassSelector
Type
->TypeSelector
Attribute
->AttributeSelector
PseudoClass
->PseudoClassSelector
PseudoElement
->PseudoElementSelector
Hash
->HexColor
Space
->WhiteSpace
An+B
->AnPlusB
- Removed
Progid
node type - Relaxed
MediaQuery
consumer to not validate syntax on parse and to include whitespaces in children sequence as is - Added
WhiteSpace.value
property to store whitespace sequence - Implemented parser options to specify what should be parsed in details (when option is
false
some part of CSS represents as balancedRaw
):parseAtruleExpression
– to parse at-rule expressions (true
by default)parseSelector
– to parse rule's selector (true
by default)parseValue
- to parse declaration's value (true
by default)parseCustomProperty
– to parse value and fallback of custom property (false
by default)
- Changed tokenization to stick leading hyphen minus to identifier token
- Changed selector parsing:
- Don't convert spaces into descendant combinator
- Don't validate selector structure on parsing (selectors may be checked by lexer later)
- Initial refactoring of docs
- Various improvements and fixes
- Implemented
DeclarationList
,MediaQueryList
,MediaQuery
,MediaFeature
andRatio
node types - Implemented
declarationList
context (useful to parse HTMLstyle
attribute content) - Implemented custom consumers for
@import
,@media
,@page
and@supports
at-rules - Implemented
atrule
option forparse()
config, is used foratruleExpession
context to specify custom consumer for at-rule if any - Added
Scanner#skipWS()
,Scanner#eatNonWS()
,Scanner#consume()
andScanner#consumeNonWS()
helper methods - Added custom consumers for known functional-pseudos, consume unknown functional-pseudo content as balanced
Raw
- Allowed any
PseudoElement
to be a functional-pseudo (#33) - Improved walker implementations to reduce GC thrashing by reusing cursors
- Changed
Atrule.block
to contain aBlock
node type only if any - Changed
Block.loc
positions to include curly brackets - Changed
Atrule.expression
to store anull
if no expression - Changed parser to use
StyleSheet
node type only for top level node (when context isstylesheet
, that's by default) - Changed
Parentheses
,Brackets
andFunction
consumers to use passed sequence reader instead of its own - Changed
Value
andAtruleExpression
consumers to use common sequence reader (that reader was used byValue
consumer before) - Changed default sequence reader to exclude storage of spaces around
Comma
- Changed processing of custom properties:
- Consume declaration value as balanced
Raw
- Consume
var()
fallback value as balancedRaw
- Validate first argument of
var()
starts with double dash - Custom property's value and fallback includes spaces around
- Consume declaration value as balanced
- Fixed
Nth
to have aloc
property - Fixed
SelectorList.loc
andSelector.loc
positions to exclude spaces - Fixed issue Browserify build fail with
default-syntax.json
is not found error (#32, @philschatz) - Disallowed
Type
selector starting with dash (parser throws an error in this case now) - Disallowed empty selectors for
Rule
(not sure if it's correct but looks reasonable) - Removed
>>
combinator support until any browser support (no signals about that yet) - Removed
PseudoElement.legacy
property - Removed special case for
:before
,:after
,:first-letter
and:first-line
to represent them asPseudoElement
, now those pseudos are represented asPseudoClass
nodes - Removed deprecated
Syntax#match()
method - Parser was splitted into modules and related changes, one step closer to an extensible parser
- Various fixes and improvements, all changes have negligible impact on performance
- Changed location storing in
SyntaxMatchError
- Changed property to store mismatch offset to
mismatchOffset
- Changed
offset
property to store bad node offset in source CSS if any - Added
loc
property that stores bad nodeloc
if any
- Changed property to store mismatch offset to
- Fixed
Syntax#matchProperty()
method to always return a positive result for custom properties since syntax is never defined for them (#31) - Implemented
fromPlainObject()
andtoPlainObject()
to convert plain object to AST or AST to plain object (currently convertsList
<->Array
)
- Added support for
:matches(<selector-list>)
(#28) - Added support for
:has(<relative-selector-list>)
- Added support for
::slotted(<compound-selector>)
- Implemented
Brackets
node type - Implemented basic support for at-rule inside rule block (#24)
- Renamed
Selector
node type toSelectorList
- Renamed
SimpleSelector
node type toSelector
- Renamed
UnicodeRange.name
property toUnicodeRange.value
- Replaced
Negation
node type for regularPseudoClass
- Unified name of node property to store nested nodes, it always
children
now:StyleSheet.rules
->StyleSheet.children
SelectorList.selectors
->SelectorList.children
Block.declarations
->Block.children
*.sequence
->*.children
- Fixed edge cases in parsing
Hex
andUnicodeRange
when number not an integer - Changed
nth-
pseudos parsing- Implemented
An+B
node type to represent expressions like2n + 1
or-3n
- Fixed edge cases when
a
orb
is not an integer - Changed
odd
andeven
keywords processing, keywords are storing asIdentifier
node type now - Changed
Nth
node type format to store anth
-query and an optionalselector
- Implemented
of
clause fornth-
pseudos (a.e.:nth-child(2n + 1 of li, img)
) - Limited
Nth
parsing rules to:nth-child()
,:nth-last-child()
,:nth-of-type()
and:nth-last-of-type()
pseudos
- Implemented
- Changed the way to store locations
- Renamed
info
node property toloc
- Changed format of
loc
to storestart
andend
positions
- Renamed
- Reworked
Scanner
to be a single point to its functionality - Exposed
Scanner
class to be useful for external projects - Changed
walk()
function behaviour to traverse AST nodes in natural order - Implemented
walkUp()
function to traverse AST nodes from deepest to parent (behaves aswalk()
before)
- Fixed
<angle>
generic according to specs that allow a<number>
equals to zero to be used as valid value (#30)
- Fixed
Scanner#skip()
issue method when cursor is moving to the end of source - Simplified
Progid
node - Changed behaviour for bad selector processing, now parsing fails instead of selector ignoring
- Fixed
<id-selector>
generic syntax - Added
q
unit for<length>
generic syntax - Refactored syntax parser (performance)
- Reduced startup time by implementing lazy syntax parsing (default syntax doesn't parse on module load)
- Updated syntax dictionaries and used
mdn/data
instead ofTemplate:CSSData
- Renamed
syntax.stringify()
method tosyntax.translate()
- Simplified generic syntax functions, those functions receive a single AST node for checking and should return
true
orfalse
- Added exception for values that contains
var()
, those values are always valid for now - Added more tests and increase code coverage to
98.5%
- Added support for explicit descendant combinator (
>>
) - Implemented
Type
andUniversal
type nodes - Improved
Number
parsing by including sign and exponent (#26) - Parse
before
,after
,first-letter
andfirst-line
pseudos with single colon asPseudoElement
- Changed
FunctionalPseudo
node type toPseudoClass
- Fixed attribute selector name parsing (namespace edge cases)
- Fixed location calculation for specified offset when
eof
is reached - Added more non-standard colors (#25)
- Removed obsolete
Syntax#getAll()
method - Fixed various edge cases, code clean up and performance improvements
- More accurate positions for syntax mismatch errors
- Added
apple
specific font keywords (#20) - Changed
Property
node stucture from object to string - Renamed
Ruleset
node type toRule
- Removed
Argument
node type - Fixed
Dimension
andPercentage
position computation - Fixed bad selector parsing (temporary solution)
- Fixed location computation for CSS with very long lines that may lead to really long parsing with
positions:true
(even freeze) - Fixed
line
andcolumn
computation forSyntaxMatch
error - Improved performance of parsing and translation. Now CSSTree is under 10ms in PostCSS benchmark.