source: trip-planner-front/node_modules/css-has-pseudo/node_modules/postcss-selector-parser/CHANGELOG.md@ 6a3a178

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

initial commit

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