Releases: postcss/postcss-selector-parser
6.0.1
- Fixed an issue with unicode surrogate pair parsing
6.0.0
- Updated:
cssesc
to 3.0.0 (major) - Fixed: Issues with escaped
id
andclass
selectors
5.0.0
Summary of Changes
- The way a descendent combinator that isn't a single space character (E.g.
.a .b
) is stored in the AST has changed. - Named Combinators (E.g.
.a /for/ .b
) are now properly parsed as a combinator. - It is now possible to look up a node based on the source location of a character in that node and to query nodes if they contain some character.
- Several bug fixes that caused the parser to hang and run out of memory when a
/
was encountered have been fixed. - The minimum supported version of Node is now
v6.0.0
.
Changes to the Descendent Combinator
In prior releases, the value of a descendant combinator with multiple spaces included all the spaces.
.a .b
: Extra spaces are now stored as space before.- Old & Busted:
combinator.value === " "
- New hotness:
combinator.value === " " && combinator.spaces.before === " "
- Old & Busted:
.a /*comment*/.b
: A comment at the end of the combinator causes extra space to become after space.- Old & Busted:
combinator.value === " "
combinator.raws.value === " /*comment/"
- New hotness:
combinator.value === " "
combinator.spaces.after === " "
combinator.raws.spaces.after === " /*comment*/"
- Old & Busted:
.a<newline>.b
: whitespace that doesn't start or end with a single space character is stored as a raw value.- Old & Busted:
combinator.value === "\n"
combinator.raws.value === undefined
- New hotness:
combinator.value === " "
combinator.raws.value === "\n"
- Old & Busted:
Support for "Named Combinators"
Although, nonstandard and unlikely to ever become a standard, combinators like /deep/
and /for/
are now properly supported.
Because they've been taken off the standardization track, there is no spec-official name for combinators of the form /<ident>/
. However, I talked to Tab Atkins and we agreed to call them "named combinators" so now they are called that.
Before this release such named combinators were parsed without intention and generated three nodes of type "tag"
where the first and last nodes had a value of "/"
.
.a /for/ .b
is parsed as a combinator.- Old & Busted:
root.nodes[0].nodes[1].type === "tag"
root.nodes[0].nodes[1].value === "/"
- New hotness:
root.nodes[0].nodes[1].type === "combinator"
root.nodes[0].nodes[1].value === "/for/"
- Old & Busted:
.a /F\6fR/ .b
escapes are handled and uppercase is normalized.- Old & Busted:
root.nodes[0].nodes[2].type === "tag"
root.nodes[0].nodes[2].value === "F\\6fR"
- New hotness:
root.nodes[0].nodes[1].type === "combinator"
root.nodes[0].nodes[1].value === "/for/"
root.nodes[0].nodes[1].raws.value === "/F\\6fR/"
- Old & Busted:
Source position checks and lookups
A new API was added to look up a node based on the source location.
const selectorParser = require("postcss-selector-parser");
// You can find the most specific node for any given character
let combinator = selectorParser.astSync(".a > .b").atPosition(1,4);
combinator.toString() === " > ";
// You can check if a node includes a specific character
// Whitespace surrounding the node that is owned by that node
// is included in the check.
[2,3,4,5,6].map(column => combinator.isAtPosition(1, column));
// => [false, true, true, true, false]
5.0.0-rc.0
This release has BREAKING CHANGES that were required to fix regressions
in 4.0.0 and to make the Combinator Node API consistent for all combinator
types. Please read carefully.
5.0.0-rc.1
To ease adoption of the v5.0 release, we have relaxed the node version
check performed by npm at installation time to allow for node 4, which
remains officially unsupported, but likely to continue working for the
time being.
5.0.0-rc.4
- Fixed and issue where comments immediately after an insensitive
(in attribute) were not parsed correctly. - Updated
cssesc
to 2.0.0 (major). - Removed outdated integration tests.
- Added tests for custom selectors, tags with attributes, the universal
selector with pseudos, and tokens after combinators.
5.0.0
- Allow escaped dot within class name.
- Update PostCSS to 7.0.7 (patch)
5.0.0 Release Candidate 4
Release Summary
- Fixed and issue where comments immediately after an insensitive (in attribute) were not parsed correctly.
- Updated
cssesc
to 2.0.0 (major). - Removed outdated integration tests.
- Added tests for custom selectors, tags with attributes, the universal selector with pseudos, and tokens after combinators.
Release Candidate: 5.0.0
Release Summary
- The way a descendent combinator that isn't a single space character (E.g.
.a .b
) is stored in the AST has changed. - Named Combinators (E.g.
.a /for/ .b
) are now properly parsed as a combinator. - It is now possible to look up a node based on the source location of a character in that node and to query nodes if they contain some character.
- Several bug fixes that caused the parser to hang and run out of memory when a
/
was encountered have been fixed. - The minimum supported version of Node is now
v6.0.0
.
Release Candidate: 4.0.0
There were a number of bugs in the 3.x releases relating to how escape sequences were handled.
We took a step back and thought through these issues and decided that the best course was to change our public API in some subtle but important ways. The new API means that users don't have to worry about escape sequences anymore. By default, the selector parser always returns unescaped strings and then re-escapes them when converting back to CSS strings, using the originally authored escape sequences if possible. If you didn't handle escape sequences or deal with quoted values in attribute selectors, then this release is probably just fixing bugs that you didn't know you had.
If you are manipulating selectors with nonstandard CSS syntax, escape sequences, or special characters, this new API means your code is going to need to change.
There is a full writeup of the changes here: #133
v3.0.0-rc.0
Breaking changes
- Some tweaks to the tokenizer/attribute selector parsing mean that whitespace
locations might be slightly different to the 2.x code. - Better attribute selector parsing with more validation; postcss-selector-parser
no longer uses regular expressions to parse attribute selectors. - Added an async API (thanks to @jacobp100); the default
process
API is now
async, and the sync API is now accessed throughprocessSync
instead. - Tweaks handling of Less interpolation (thanks to @jwilsson).
- Removes support for Node 0.12.
Other changes
- Set the parent when inserting a node (thanks to @chriseppstein).
- Correctly adjust indices when using insertBefore/insertAfter (thanks to @tivac).
- Fixes handling of namespaces with qualified tag selectors.
- Now accepts a PostCSS rule node for better syntax errors.
- Now more memory efficient when tokenizing selectors.