AK-21/Graphite-Industrial-Intelligence
0
1# 6.0.102 3- Fixed: `isPseudoElement()` supports `:first-letter` and `:first-line`4 5# 6.0.96 7- Fixed: `Combinator.raws` property type8 9# 6.0.810 11- Fixed: reduced size12 13# 6.0.714 15- Fixed: parse animation percents16 17# 6.0.618 19- Fixed: parse quoted attributes containing a newline correctly20 21# 6.0.522 23- Perf: rework unesc for a 63+% performance boost24 25# 6.0.426 27- Fixed: ts errors28 29# 6.0.330 31- Fixed: replace node built-in "util" module with "util-deprecate"32- Fixed: handle uppercase pseudo elements33- Fixed: do not create invalid combinator before comment34 35# 6.0.236 37- Fixed an issue with parsing and stringifying an empty attribute value38 39# 6.0.140 41- Fixed an issue with unicode surrogate pair parsing42 43# 6.0.044 45- Updated: `cssesc` to 3.0.0 (major)46- Fixed: Issues with escaped `id` and `class` selectors47 48# 5.0.049 50- Allow escaped dot within class name.51- Update PostCSS to 7.0.7 (patch)52 53# 5.0.0-rc.454 55- Fixed an issue where comments immediately after an insensitive (in attribute)56 were not parsed correctly.57- Updated `cssesc` to 2.0.0 (major).58- Removed outdated integration tests.59- Added tests for custom selectors, tags with attributes, the universal60 selector with pseudos, and tokens after combinators.61 62# 5.0.0-rc.163 64To ease adoption of the v5.0 release, we have relaxed the node version65check performed by npm at installation time to allow for node 4, which66remains officially unsupported, but likely to continue working for the67time being.68 69# 5.0.0-rc.070 71This release has **BREAKING CHANGES** that were required to fix regressions72in 4.0.0 and to make the Combinator Node API consistent for all combinator73types. Please read carefully.74 75## Summary of Changes76 77* The way a descendent combinator that isn't a single space character (E.g. `.a .b`) is stored in the AST has changed.78* Named Combinators (E.g. `.a /for/ .b`) are now properly parsed as a combinator.79* 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.80* Several bug fixes that caused the parser to hang and run out of memory when a `/` was encountered have been fixed.81* The minimum supported version of Node is now `v6.0.0`.82 83### Changes to the Descendent Combinator84 85In prior releases, the value of a descendant combinator with multiple spaces included all the spaces.86 87* `.a .b`: Extra spaces are now stored as space before.88 - Old & Busted:89 - `combinator.value === " "`90 - New hotness:91 - `combinator.value === " " && combinator.spaces.before === " "`92* `.a /*comment*/.b`: A comment at the end of the combinator causes extra space to become after space.93 - Old & Busted:94 - `combinator.value === " "`95 - `combinator.raws.value === " /*comment/"`96 - New hotness:97 - `combinator.value === " "`98 - `combinator.spaces.after === " "`99 - `combinator.raws.spaces.after === " /*comment*/"`100* `.a<newline>.b`: whitespace that doesn't start or end with a single space character is stored as a raw value.101 - Old & Busted:102 - `combinator.value === "\n"`103 - `combinator.raws.value === undefined`104 - New hotness:105 - `combinator.value === " "`106 - `combinator.raws.value === "\n"`107 108### Support for "Named Combinators"109 110Although, nonstandard and unlikely to ever become a standard, combinators like `/deep/` and `/for/` are now properly supported.111 112Because 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](https://twitter.com/tabatkins) and we agreed to call them "named combinators" so now they are called that.113 114Before 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 `"/"`.115 116* `.a /for/ .b` is parsed as a combinator.117 - Old & Busted:118 - `root.nodes[0].nodes[1].type === "tag"`119 - `root.nodes[0].nodes[1].value === "/"`120 - New hotness:121 - `root.nodes[0].nodes[1].type === "combinator"`122 - `root.nodes[0].nodes[1].value === "/for/"`123* `.a /F\6fR/ .b` escapes are handled and uppercase is normalized.124 - Old & Busted:125 - `root.nodes[0].nodes[2].type === "tag"`126 - `root.nodes[0].nodes[2].value === "F\\6fR"`127 - New hotness:128 - `root.nodes[0].nodes[1].type === "combinator"`129 - `root.nodes[0].nodes[1].value === "/for/"`130 - `root.nodes[0].nodes[1].raws.value === "/F\\6fR/"`131 132### Source position checks and lookups133 134A new API was added to look up a node based on the source location.135 136```js137const selectorParser = require("postcss-selector-parser");138// You can find the most specific node for any given character139let combinator = selectorParser.astSync(".a > .b").atPosition(1,4);140combinator.toString() === " > ";141// You can check if a node includes a specific character142// Whitespace surrounding the node that is owned by that node143// is included in the check.144[2,3,4,5,6].map(column => combinator.isAtPosition(1, column));145// => [false, true, true, true, false]146```147 148# 4.0.0149 150This release has **BREAKING CHANGES** that were required to fix bugs regarding values with escape sequences. Please read carefully.151 152* **Identifiers with escapes** - CSS escape sequences are now hidden from the public API by default.153 The normal value of a node like a class name or ID, or an aspect of a node such as attribute154 selector's value, is unescaped. Escapes representing Non-ascii characters are unescaped into155 unicode characters. For example: `bu\tton, .\31 00, #i\2764\FE0Fu, [attr="value is \"quoted\""]`156 will parse respectively to the values `button`, `100`, `i❤️u`, `value is "quoted"`.157 The original escape sequences for these values can be found in the corresponding property name158 in `node.raws`. Where possible, deprecation warnings were added, but the nature159 of escape handling makes it impossible to detect what is escaped or not. Our expectation is160 that most users are neither expecting nor handling escape sequences in their use of this library,161 and so for them, this is a bug fix. Users who are taking care to handle escapes correctly can162 now update their code to remove the escape handling and let us do it for them.163 164* **Mutating values with escapes** - When you make an update to a node property that has escape handling165 The value is assumed to be unescaped, and any special characters are escaped automatically and166 the corresponding `raws` value is immediately updated. This can result in changes to the original167 escape format. Where the exact value of the escape sequence is important there are methods that168 allow both values to be set in conjunction. There are a number of new convenience methods for169 manipulating values that involve escapes, especially for attributes values where the quote mark170 is involved. See https://github.com/postcss/postcss-selector-parser/pull/133 for an extensive171 write-up on these changes.172 173 174**Upgrade/API Example**175 176In `3.x` there was no unescape handling and internal consistency of several properties was the caller's job to maintain. It was very easy for the developer177to create a CSS file that did not parse correctly when some types of values178were in use.179 180```js181const selectorParser = require("postcss-selector-parser");182let attr = selectorParser.attribute({attribute: "id", operator: "=", value: "a-value"});183attr.value; // => "a-value"184attr.toString(); // => [id=a-value]185// Add quotes to an attribute's value.186// All these values have to be set by the caller to be consistent:187// no internal consistency is maintained.188attr.raws.unquoted = attr.value189attr.value = "'" + attr.value + "'";190attr.value; // => "'a-value'"191attr.quoted = true;192attr.toString(); // => "[id='a-value']"193```194 195In `4.0` there is a convenient API for setting and mutating values196that may need escaping. Especially for attributes.197 198```js199const selectorParser = require("postcss-selector-parser");200 201// The constructor requires you specify the exact escape sequence202let className = selectorParser.className({value: "illegal class name", raws: {value: "illegal\\ class\\ name"}});203className.toString(); // => '.illegal\\ class\\ name'204 205// So it's better to set the value as a property206className = selectorParser.className();207// Most properties that deal with identifiers work like this208className.value = "escape for me";209className.value; // => 'escape for me'210className.toString(); // => '.escape\\ for\\ me'211 212// emoji and all non-ascii are escaped to ensure it works in every css file.213className.value = "😱🦄😍";214className.value; // => '😱🦄😍'215className.toString(); // => '.\\1F631\\1F984\\1F60D'216 217// you can control the escape sequence if you want, or do bad bad things218className.setPropertyAndEscape('value', 'xxxx', 'yyyy');219className.value; // => "xxxx"220className.toString(); // => ".yyyy"221 222// Pass a value directly through to the css output without escaping it. 223className.setPropertyWithoutEscape('value', '$REPLACE_ME$');224className.value; // => "$REPLACE_ME$"225className.toString(); // => ".$REPLACE_ME$"226 227// The biggest changes are to the Attribute class228// passing quoteMark explicitly is required to avoid a deprecation warning.229let attr = selectorParser.attribute({attribute: "id", operator: "=", value: "a-value", quoteMark: null});230attr.toString(); // => "[id=a-value]"231// Get the value with quotes on it and any necessary escapes.232// This is the same as reading attr.value in 3.x.233attr.getQuotedValue(); // => "a-value";234attr.quoteMark; // => null235 236// Add quotes to an attribute's value.237attr.quoteMark = "'"; // This is all that's required.238attr.toString(); // => "[id='a-value']"239attr.quoted; // => true240// The value is still the same, only the quotes have changed.241attr.value; // => a-value242attr.getQuotedValue(); // => "'a-value'";243 244// deprecated assignment, no warning because there's no escapes245attr.value = "new-value";246// no quote mark is needed so it is removed247attr.getQuotedValue(); // => "new-value";248 249// deprecated assignment, 250attr.value = "\"a 'single quoted' value\"";251// > (node:27859) DeprecationWarning: Assigning an attribute a value containing characters that might need to be escaped is deprecated. Call attribute.setValue() instead.252attr.getQuotedValue(); // => '"a \'single quoted\' value"';253// quote mark inferred from first and last characters.254attr.quoteMark; // => '"'255 256// setValue takes options to make manipulating the value simple.257attr.setValue('foo', {smart: true});258// foo doesn't require any escapes or quotes.259attr.toString(); // => '[id=foo]'260attr.quoteMark; // => null 261 262// An explicit quote mark can be specified263attr.setValue('foo', {quoteMark: '"'});264attr.toString(); // => '[id="foo"]'265 266// preserves quote mark by default267attr.setValue('bar');268attr.toString(); // => '[id="bar"]'269attr.quoteMark = null;270attr.toString(); // => '[id=bar]'271 272// with no arguments, it preserves quote mark even when it's not a great idea273attr.setValue('a value \n that should be quoted');274attr.toString(); // => '[id=a\\ value\\ \\A\\ that\\ should\\ be\\ quoted]'275 276// smart preservation with a specified default277attr.setValue('a value \n that should be quoted', {smart: true, preferCurrentQuoteMark: true, quoteMark: "'"});278// => "[id='a value \\A that should be quoted']"279attr.quoteMark = '"';280// => '[id="a value \\A that should be quoted"]'281 282// this keeps double quotes because it wants to quote the value and the existing value has double quotes.283attr.setValue('this should be quoted', {smart: true, preferCurrentQuoteMark: true, quoteMark: "'"});284// => '[id="this should be quoted"]'285 286// picks single quotes because the value has double quotes287attr.setValue('a "double quoted" value', {smart: true, preferCurrentQuoteMark: true, quoteMark: "'"});288// => "[id='a "double quoted" value']"289 290// setPropertyAndEscape lets you do anything you want. Even things that are a bad idea and illegal.291attr.setPropertyAndEscape('value', 'xxxx', 'the password is 42');292attr.value; // => "xxxx"293attr.toString(); // => "[id=the password is 42]"294 295// Pass a value directly through to the css output without escaping it. 296attr.setPropertyWithoutEscape('value', '$REPLACEMENT$');297attr.value; // => "$REPLACEMENT$"298attr.toString(); // => "[id=$REPLACEMENT$]"299```300 301# 3.1.2302 303* Fix: Removed dot-prop dependency since it's no longer written in es5.304 305# 3.1.1306 307* Fix: typescript definitions weren't in the published package.308 309# 3.1.0310 311* Fixed numerous bugs in attribute nodes relating to the handling of comments312 and whitespace. There's significant changes to `attrNode.spaces` and `attrNode.raws` since the `3.0.0` release.313* Added `Attribute#offsetOf(part)` to get the offset location of314 attribute parts like `"operator"` and `"value"`. This is most315 often added to `Attribute#sourceIndex` for error reporting.316 317# 3.0.0318 319## Breaking changes320 321* Some tweaks to the tokenizer/attribute selector parsing mean that whitespace322 locations might be slightly different to the 2.x code.323* Better attribute selector parsing with more validation; postcss-selector-parser324 no longer uses regular expressions to parse attribute selectors.325* Added an async API (thanks to @jacobp100); the default `process` API is now326 async, and the sync API is now accessed through `processSync` instead.327* `process()` and `processSync()` now return a string instead of the Processor328 instance.329* Tweaks handling of Less interpolation (thanks to @jwilsson).330* Removes support for Node 0.12.331 332## Other changes333 334* `ast()` and `astSync()` methods have been added to the `Processor`. These335 return the `Root` node of the selectors after processing them.336* `transform()` and `transformSync()` methods have been added to the337 `Processor`. These return the value returned by the processor callback338 after processing the selectors.339* Set the parent when inserting a node (thanks to @chriseppstein).340* Correctly adjust indices when using insertBefore/insertAfter (thanks to @tivac).341* Fixes handling of namespaces with qualified tag selectors.342* `process`, `ast` and `transform` (and their sync variants) now accept a343 `postcss` rule node. When provided, better errors are generated and selector344 processing is automatically set back to the rule selector (unless the `updateSelector` option is set to `false`.)345* Now more memory efficient when tokenizing selectors.346 347### Upgrade hints348 349The pattern of:350 351`rule.selector = processor.process(rule.selector).result.toString();`352 353is now:354 355`processor.processSync(rule)`356 357# 2.2.3358 359* Resolves an issue where the parser would not reduce multiple spaces between an360 ampersand and another simple selector in lossy mode (thanks to @adam-26).361 362# 2.2.2363 364* No longer hangs on an unescaped semicolon; instead the parser will throw365 an exception for these cases.366 367# 2.2.1368 369* Allows a consumer to specify whitespace tokens when creating a new Node370 (thanks to @Semigradsky).371 372# 2.2.0373 374* Added a new option to normalize whitespace when parsing the selector string375 (thanks to @adam-26).376 377# 2.1.1378 379* Better unquoted value handling within attribute selectors380 (thanks to @evilebottnawi).381 382# 2.1.0383 384* Added: Use string constants for all node types & expose them on the main385 parser instance (thanks to @Aweary).386 387# 2.0.0388 389This release contains the following breaking changes:390 391* Renamed all `eachInside` iterators to `walk`. For example, `eachTag` is now392 `walkTags`, and `eachInside` is now `walk`.393* Renamed `Node#removeSelf()` to `Node#remove()`.394* Renamed `Container#remove()` to `Container#removeChild()`.395* Renamed `Node#raw` to `Node#raws` (thanks to @davidtheclark).396* Now parses `&` as the *nesting* selector, rather than a *tag* selector.397* Fixes misinterpretation of Sass interpolation (e.g. `#{foo}`) as an398 id selector (thanks to @davidtheclark).399 400and;401 402* Fixes parsing of attribute selectors with equals signs in them403 (e.g. `[data-attr="foo=bar"]`) (thanks to @montmanu).404* Adds `quoted` and `raw.unquoted` properties to attribute nodes405 (thanks to @davidtheclark).406 407# 1.3.3408 409* Fixes an infinite loop on `)` and `]` tokens when they had no opening pairs.410 Now postcss-selector-parser will throw when it encounters these lone tokens.411 412# 1.3.2413 414* Now uses plain integers rather than `str.charCodeAt(0)` for compiled builds.415 416# 1.3.1417 418* Update flatten to v1.x (thanks to @shinnn).419 420# 1.3.0421 422* Adds a new node type, `String`, to fix a crash on selectors such as423 `foo:bar("test")`.424 425# 1.2.1426 427* Fixes a crash when the parser encountered a trailing combinator.428 429# 1.2.0430 431* A more descriptive error is thrown when the parser expects to find a432 pseudo-class/pseudo-element (thanks to @ashelley).433* Adds support for line/column locations for selector nodes, as well as a434 `Node#sourceIndex` method (thanks to @davidtheclark).435 436# 1.1.4437 438* Fixes a crash when a selector started with a `>` combinator. The module will439 now no longer throw if a selector has a leading/trailing combinator node.440 441# 1.1.3442 443* Fixes a crash on `@` tokens.444 445# 1.1.2446 447* Fixes an infinite loop caused by using parentheses in a non-pseudo element448 context.449 450# 1.1.1451 452* Fixes a crash when a backslash ended a selector string.453 454# 1.1.0455 456* Adds support for replacing multiple nodes at once with `replaceWith`457 (thanks to @jonathantneal).458* Parser no longer throws on sequential IDs and trailing commas, to support459 parsing of selector hacks.460 461# 1.0.1462 463* Fixes using `insertAfter` and `insertBefore` during iteration.464 465# 1.0.0466 467* Adds `clone` and `replaceWith` methods to nodes.468* Adds `insertBefore` and `insertAfter` to containers.469* Stabilises API.470 471# 0.0.5472 473* Fixes crash on extra whitespace inside a pseudo selector's parentheses.474* Adds sort function to the container class.475* Enables the parser to pass its input through without transforming.476* Iteration-safe `each` and `eachInside`.477 478# 0.0.4479 480* Tidy up redundant duplication.481* Fixes a bug where the parser would loop infinitely on universal selectors482 inside pseudo selectors.483* Adds `length` getter and `eachInside`, `map`, `reduce` to the container class.484* When a selector has been removed from the tree, the root node will no longer485 cast it to a string.486* Adds node type iterators to the container class (e.g. `eachComment`).487* Adds filter function to the container class.488* Adds split function to the container class.489* Create new node types by doing `parser.id(opts)` etc.490* Adds support for pseudo classes anywhere in the selector.491 492# 0.0.3493 494* Adds `next` and `prev` to the node class.495* Adds `first` and `last` getters to the container class.496* Adds `every` and `some` iterators to the container class.497* Add `empty` alias for `removeAll`.498* Combinators are now types of node.499* Fixes the at method so that it is not an alias for `index`.500* Tidy up creation of new nodes in the parser.501* Refactors how namespaces are handled for consistency & less redundant code.502* Refactors AST to use `nodes` exclusively, and eliminates excessive nesting.503* Fixes nested pseudo parsing.504* Fixes whitespace parsing.505 506# 0.0.2507 508* Adds support for namespace selectors.509* Adds support for selectors joined by escaped spaces - such as `.\31\ 0`.510 511# 0.0.1512 513* Initial release.514 