source: trip-planner-front/node_modules/postcss-selector-parser/CHANGELOG.md@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 18.4 KB
Line 
1# 6.0.6
2
3- Fixed: parse quoted attributes containing a newline correctly
4
5# 6.0.5
6
7- Perf: rework unesc for a 63+% performance boost
8
9# 6.0.4
10
11- Fixed: ts errors
12
13# 6.0.3
14
15- Fixed: replace node built-in "util" module with "util-deprecate"
16- Fixed: handle uppercase pseudo elements
17- Fixed: do not create invalid combinator before comment
18
19# 6.0.2
20
21- Fixed an issue with parsing and stringifying an empty attribute value
22
23# 6.0.1
24
25- Fixed an issue with unicode surrogate pair parsing
26
27# 6.0.0
28
29- Updated: `cssesc` to 3.0.0 (major)
30- Fixed: Issues with escaped `id` and `class` selectors
31
32# 5.0.0
33
34- Allow escaped dot within class name.
35- Update PostCSS to 7.0.7 (patch)
36
37# 5.0.0-rc.4
38
39- Fixed an issue where comments immediately after an insensitive (in attribute)
40 were not parsed correctly.
41- Updated `cssesc` to 2.0.0 (major).
42- Removed outdated integration tests.
43- Added tests for custom selectors, tags with attributes, the universal
44 selector with pseudos, and tokens after combinators.
45
46# 5.0.0-rc.1
47
48To ease adoption of the v5.0 release, we have relaxed the node version
49check performed by npm at installation time to allow for node 4, which
50remains officially unsupported, but likely to continue working for the
51time being.
52
53# 5.0.0-rc.0
54
55This release has **BREAKING CHANGES** that were required to fix regressions
56in 4.0.0 and to make the Combinator Node API consistent for all combinator
57types. Please read carefully.
58
59## Summary of Changes
60
61* The way a descendent combinator that isn't a single space character (E.g. `.a .b`) is stored in the AST has changed.
62* Named Combinators (E.g. `.a /for/ .b`) are now properly parsed as a combinator.
63* 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.
64* Several bug fixes that caused the parser to hang and run out of memory when a `/` was encountered have been fixed.
65* The minimum supported version of Node is now `v6.0.0`.
66
67### Changes to the Descendent Combinator
68
69In prior releases, the value of a descendant combinator with multiple spaces included all the spaces.
70
71* `.a .b`: Extra spaces are now stored as space before.
72 - Old & Busted:
73 - `combinator.value === " "`
74 - New hotness:
75 - `combinator.value === " " && combinator.spaces.before === " "`
76* `.a /*comment*/.b`: A comment at the end of the combinator causes extra space to become after space.
77 - Old & Busted:
78 - `combinator.value === " "`
79 - `combinator.raws.value === " /*comment/"`
80 - New hotness:
81 - `combinator.value === " "`
82 - `combinator.spaces.after === " "`
83 - `combinator.raws.spaces.after === " /*comment*/"`
84* `.a<newline>.b`: whitespace that doesn't start or end with a single space character is stored as a raw value.
85 - Old & Busted:
86 - `combinator.value === "\n"`
87 - `combinator.raws.value === undefined`
88 - New hotness:
89 - `combinator.value === " "`
90 - `combinator.raws.value === "\n"`
91
92### Support for "Named Combinators"
93
94Although, nonstandard and unlikely to ever become a standard, combinators like `/deep/` and `/for/` are now properly supported.
95
96Because 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.
97
98Before 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 `"/"`.
99
100* `.a /for/ .b` is parsed as a combinator.
101 - Old & Busted:
102 - `root.nodes[0].nodes[1].type === "tag"`
103 - `root.nodes[0].nodes[1].value === "/"`
104 - New hotness:
105 - `root.nodes[0].nodes[1].type === "combinator"`
106 - `root.nodes[0].nodes[1].value === "/for/"`
107* `.a /F\6fR/ .b` escapes are handled and uppercase is normalized.
108 - Old & Busted:
109 - `root.nodes[0].nodes[2].type === "tag"`
110 - `root.nodes[0].nodes[2].value === "F\\6fR"`
111 - New hotness:
112 - `root.nodes[0].nodes[1].type === "combinator"`
113 - `root.nodes[0].nodes[1].value === "/for/"`
114 - `root.nodes[0].nodes[1].raws.value === "/F\\6fR/"`
115
116### Source position checks and lookups
117
118A new API was added to look up a node based on the source location.
119
120```js
121const selectorParser = require("postcss-selector-parser");
122// You can find the most specific node for any given character
123let combinator = selectorParser.astSync(".a > .b").atPosition(1,4);
124combinator.toString() === " > ";
125// You can check if a node includes a specific character
126// Whitespace surrounding the node that is owned by that node
127// is included in the check.
128[2,3,4,5,6].map(column => combinator.isAtPosition(1, column));
129// => [false, true, true, true, false]
130```
131
132# 4.0.0
133
134This release has **BREAKING CHANGES** that were required to fix bugs regarding values with escape sequences. Please read carefully.
135
136* **Identifiers with escapes** - CSS escape sequences are now hidden from the public API by default.
137 The normal value of a node like a class name or ID, or an aspect of a node such as attribute
138 selector's value, is unescaped. Escapes representing Non-ascii characters are unescaped into
139 unicode characters. For example: `bu\tton, .\31 00, #i\2764\FE0Fu, [attr="value is \"quoted\""]`
140 will parse respectively to the values `button`, `100`, `i❤️u`, `value is "quoted"`.
141 The original escape sequences for these values can be found in the corresponding property name
142 in `node.raws`. Where possible, deprecation warnings were added, but the nature
143 of escape handling makes it impossible to detect what is escaped or not. Our expectation is
144 that most users are neither expecting nor handling escape sequences in their use of this library,
145 and so for them, this is a bug fix. Users who are taking care to handle escapes correctly can
146 now update their code to remove the escape handling and let us do it for them.
147
148* **Mutating values with escapes** - When you make an update to a node property that has escape handling
149 The value is assumed to be unescaped, and any special characters are escaped automatically and
150 the corresponding `raws` value is immediately updated. This can result in changes to the original
151 escape format. Where the exact value of the escape sequence is important there are methods that
152 allow both values to be set in conjunction. There are a number of new convenience methods for
153 manipulating values that involve escapes, especially for attributes values where the quote mark
154 is involved. See https://github.com/postcss/postcss-selector-parser/pull/133 for an extensive
155 write-up on these changes.
156
157
158**Upgrade/API Example**
159
160In `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 developer
161to create a CSS file that did not parse correctly when some types of values
162were in use.
163
164```js
165const selectorParser = require("postcss-selector-parser");
166let attr = selectorParser.attribute({attribute: "id", operator: "=", value: "a-value"});
167attr.value; // => "a-value"
168attr.toString(); // => [id=a-value]
169// Add quotes to an attribute's value.
170// All these values have to be set by the caller to be consistent:
171// no internal consistency is maintained.
172attr.raws.unquoted = attr.value
173attr.value = "'" + attr.value + "'";
174attr.value; // => "'a-value'"
175attr.quoted = true;
176attr.toString(); // => "[id='a-value']"
177```
178
179In `4.0` there is a convenient API for setting and mutating values
180that may need escaping. Especially for attributes.
181
182```js
183const selectorParser = require("postcss-selector-parser");
184
185// The constructor requires you specify the exact escape sequence
186let className = selectorParser.className({value: "illegal class name", raws: {value: "illegal\\ class\\ name"}});
187className.toString(); // => '.illegal\\ class\\ name'
188
189// So it's better to set the value as a property
190className = selectorParser.className();
191// Most properties that deal with identifiers work like this
192className.value = "escape for me";
193className.value; // => 'escape for me'
194className.toString(); // => '.escape\\ for\\ me'
195
196// emoji and all non-ascii are escaped to ensure it works in every css file.
197className.value = "😱🦄😍";
198className.value; // => '😱🦄😍'
199className.toString(); // => '.\\1F631\\1F984\\1F60D'
200
201// you can control the escape sequence if you want, or do bad bad things
202className.setPropertyAndEscape('value', 'xxxx', 'yyyy');
203className.value; // => "xxxx"
204className.toString(); // => ".yyyy"
205
206// Pass a value directly through to the css output without escaping it.
207className.setPropertyWithoutEscape('value', '$REPLACE_ME$');
208className.value; // => "$REPLACE_ME$"
209className.toString(); // => ".$REPLACE_ME$"
210
211// The biggest changes are to the Attribute class
212// passing quoteMark explicitly is required to avoid a deprecation warning.
213let attr = selectorParser.attribute({attribute: "id", operator: "=", value: "a-value", quoteMark: null});
214attr.toString(); // => "[id=a-value]"
215// Get the value with quotes on it and any necessary escapes.
216// This is the same as reading attr.value in 3.x.
217attr.getQuotedValue(); // => "a-value";
218attr.quoteMark; // => null
219
220// Add quotes to an attribute's value.
221attr.quoteMark = "'"; // This is all that's required.
222attr.toString(); // => "[id='a-value']"
223attr.quoted; // => true
224// The value is still the same, only the quotes have changed.
225attr.value; // => a-value
226attr.getQuotedValue(); // => "'a-value'";
227
228// deprecated assignment, no warning because there's no escapes
229attr.value = "new-value";
230// no quote mark is needed so it is removed
231attr.getQuotedValue(); // => "new-value";
232
233// deprecated assignment,
234attr.value = "\"a 'single quoted' value\"";
235// > (node:27859) DeprecationWarning: Assigning an attribute a value containing characters that might need to be escaped is deprecated. Call attribute.setValue() instead.
236attr.getQuotedValue(); // => '"a \'single quoted\' value"';
237// quote mark inferred from first and last characters.
238attr.quoteMark; // => '"'
239
240// setValue takes options to make manipulating the value simple.
241attr.setValue('foo', {smart: true});
242// foo doesn't require any escapes or quotes.
243attr.toString(); // => '[id=foo]'
244attr.quoteMark; // => null
245
246// An explicit quote mark can be specified
247attr.setValue('foo', {quoteMark: '"'});
248attr.toString(); // => '[id="foo"]'
249
250// preserves quote mark by default
251attr.setValue('bar');
252attr.toString(); // => '[id="bar"]'
253attr.quoteMark = null;
254attr.toString(); // => '[id=bar]'
255
256// with no arguments, it preserves quote mark even when it's not a great idea
257attr.setValue('a value \n that should be quoted');
258attr.toString(); // => '[id=a\\ value\\ \\A\\ that\\ should\\ be\\ quoted]'
259
260// smart preservation with a specified default
261attr.setValue('a value \n that should be quoted', {smart: true, preferCurrentQuoteMark: true, quoteMark: "'"});
262// => "[id='a value \\A that should be quoted']"
263attr.quoteMark = '"';
264// => '[id="a value \\A that should be quoted"]'
265
266// this keeps double quotes because it wants to quote the value and the existing value has double quotes.
267attr.setValue('this should be quoted', {smart: true, preferCurrentQuoteMark: true, quoteMark: "'"});
268// => '[id="this should be quoted"]'
269
270// picks single quotes because the value has double quotes
271attr.setValue('a "double quoted" value', {smart: true, preferCurrentQuoteMark: true, quoteMark: "'"});
272// => "[id='a "double quoted" value']"
273
274// setPropertyAndEscape lets you do anything you want. Even things that are a bad idea and illegal.
275attr.setPropertyAndEscape('value', 'xxxx', 'the password is 42');
276attr.value; // => "xxxx"
277attr.toString(); // => "[id=the password is 42]"
278
279// Pass a value directly through to the css output without escaping it.
280attr.setPropertyWithoutEscape('value', '$REPLACEMENT$');
281attr.value; // => "$REPLACEMENT$"
282attr.toString(); // => "[id=$REPLACEMENT$]"
283```
284
285# 3.1.2
286
287* Fix: Removed dot-prop dependency since it's no longer written in es5.
288
289# 3.1.1
290
291* Fix: typescript definitions weren't in the published package.
292
293# 3.1.0
294
295* Fixed numerous bugs in attribute nodes relating to the handling of comments
296 and whitespace. There's significant changes to `attrNode.spaces` and `attrNode.raws` since the `3.0.0` release.
297* Added `Attribute#offsetOf(part)` to get the offset location of
298 attribute parts like `"operator"` and `"value"`. This is most
299 often added to `Attribute#sourceIndex` for error reporting.
300
301# 3.0.0
302
303## Breaking changes
304
305* Some tweaks to the tokenizer/attribute selector parsing mean that whitespace
306 locations might be slightly different to the 2.x code.
307* Better attribute selector parsing with more validation; postcss-selector-parser
308 no longer uses regular expressions to parse attribute selectors.
309* Added an async API (thanks to @jacobp100); the default `process` API is now
310 async, and the sync API is now accessed through `processSync` instead.
311* `process()` and `processSync()` now return a string instead of the Processor
312 instance.
313* Tweaks handling of Less interpolation (thanks to @jwilsson).
314* Removes support for Node 0.12.
315
316## Other changes
317
318* `ast()` and `astSync()` methods have been added to the `Processor`. These
319 return the `Root` node of the selectors after processing them.
320* `transform()` and `transformSync()` methods have been added to the
321 `Processor`. These return the value returned by the processor callback
322 after processing the selectors.
323* Set the parent when inserting a node (thanks to @chriseppstein).
324* Correctly adjust indices when using insertBefore/insertAfter (thanks to @tivac).
325* Fixes handling of namespaces with qualified tag selectors.
326* `process`, `ast` and `transform` (and their sync variants) now accept a
327 `postcss` rule node. When provided, better errors are generated and selector
328 processing is automatically set back to the rule selector (unless the `updateSelector` option is set to `false`.)
329* Now more memory efficient when tokenizing selectors.
330
331### Upgrade hints
332
333The pattern of:
334
335`rule.selector = processor.process(rule.selector).result.toString();`
336
337is now:
338
339`processor.processSync(rule)`
340
341# 2.2.3
342
343* Resolves an issue where the parser would not reduce multiple spaces between an
344 ampersand and another simple selector in lossy mode (thanks to @adam-26).
345
346# 2.2.2
347
348* No longer hangs on an unescaped semicolon; instead the parser will throw
349 an exception for these cases.
350
351# 2.2.1
352
353* Allows a consumer to specify whitespace tokens when creating a new Node
354 (thanks to @Semigradsky).
355
356# 2.2.0
357
358* Added a new option to normalize whitespace when parsing the selector string
359 (thanks to @adam-26).
360
361# 2.1.1
362
363* Better unquoted value handling within attribute selectors
364 (thanks to @evilebottnawi).
365
366# 2.1.0
367
368* Added: Use string constants for all node types & expose them on the main
369 parser instance (thanks to @Aweary).
370
371# 2.0.0
372
373This release contains the following breaking changes:
374
375* Renamed all `eachInside` iterators to `walk`. For example, `eachTag` is now
376 `walkTags`, and `eachInside` is now `walk`.
377* Renamed `Node#removeSelf()` to `Node#remove()`.
378* Renamed `Container#remove()` to `Container#removeChild()`.
379* Renamed `Node#raw` to `Node#raws` (thanks to @davidtheclark).
380* Now parses `&` as the *nesting* selector, rather than a *tag* selector.
381* Fixes misinterpretation of Sass interpolation (e.g. `#{foo}`) as an
382 id selector (thanks to @davidtheclark).
383
384and;
385
386* Fixes parsing of attribute selectors with equals signs in them
387 (e.g. `[data-attr="foo=bar"]`) (thanks to @montmanu).
388* Adds `quoted` and `raw.unquoted` properties to attribute nodes
389 (thanks to @davidtheclark).
390
391# 1.3.3
392
393* Fixes an infinite loop on `)` and `]` tokens when they had no opening pairs.
394 Now postcss-selector-parser will throw when it encounters these lone tokens.
395
396# 1.3.2
397
398* Now uses plain integers rather than `str.charCodeAt(0)` for compiled builds.
399
400# 1.3.1
401
402* Update flatten to v1.x (thanks to @shinnn).
403
404# 1.3.0
405
406* Adds a new node type, `String`, to fix a crash on selectors such as
407 `foo:bar("test")`.
408
409# 1.2.1
410
411* Fixes a crash when the parser encountered a trailing combinator.
412
413# 1.2.0
414
415* A more descriptive error is thrown when the parser expects to find a
416 pseudo-class/pseudo-element (thanks to @ashelley).
417* Adds support for line/column locations for selector nodes, as well as a
418 `Node#sourceIndex` method (thanks to @davidtheclark).
419
420# 1.1.4
421
422* Fixes a crash when a selector started with a `>` combinator. The module will
423 now no longer throw if a selector has a leading/trailing combinator node.
424
425# 1.1.3
426
427* Fixes a crash on `@` tokens.
428
429# 1.1.2
430
431* Fixes an infinite loop caused by using parentheses in a non-pseudo element
432 context.
433
434# 1.1.1
435
436* Fixes a crash when a backslash ended a selector string.
437
438# 1.1.0
439
440* Adds support for replacing multiple nodes at once with `replaceWith`
441 (thanks to @jonathantneal).
442* Parser no longer throws on sequential IDs and trailing commas, to support
443 parsing of selector hacks.
444
445# 1.0.1
446
447* Fixes using `insertAfter` and `insertBefore` during iteration.
448
449# 1.0.0
450
451* Adds `clone` and `replaceWith` methods to nodes.
452* Adds `insertBefore` and `insertAfter` to containers.
453* Stabilises API.
454
455# 0.0.5
456
457* Fixes crash on extra whitespace inside a pseudo selector's parentheses.
458* Adds sort function to the container class.
459* Enables the parser to pass its input through without transforming.
460* Iteration-safe `each` and `eachInside`.
461
462# 0.0.4
463
464* Tidy up redundant duplication.
465* Fixes a bug where the parser would loop infinitely on universal selectors
466 inside pseudo selectors.
467* Adds `length` getter and `eachInside`, `map`, `reduce` to the container class.
468* When a selector has been removed from the tree, the root node will no longer
469 cast it to a string.
470* Adds node type iterators to the container class (e.g. `eachComment`).
471* Adds filter function to the container class.
472* Adds split function to the container class.
473* Create new node types by doing `parser.id(opts)` etc.
474* Adds support for pseudo classes anywhere in the selector.
475
476# 0.0.3
477
478* Adds `next` and `prev` to the node class.
479* Adds `first` and `last` getters to the container class.
480* Adds `every` and `some` iterators to the container class.
481* Add `empty` alias for `removeAll`.
482* Combinators are now types of node.
483* Fixes the at method so that it is not an alias for `index`.
484* Tidy up creation of new nodes in the parser.
485* Refactors how namespaces are handled for consistency & less redundant code.
486* Refactors AST to use `nodes` exclusively, and eliminates excessive nesting.
487* Fixes nested pseudo parsing.
488* Fixes whitespace parsing.
489
490# 0.0.2
491
492* Adds support for namespace selectors.
493* Adds support for selectors joined by escaped spaces - such as `.\31\ 0`.
494
495# 0.0.1
496
497* Initial release.
Note: See TracBrowser for help on using the repository browser.