13 Commits

Author SHA1 Message Date
Adam Wathan
22eaad17c3
Fix "Maximum call stack size exceeded" bug (#8636)
* Fix potential call stack size issue

* Update defaultExtractor.js

* add test to verify "Maximum call stack size exceeded" is fixed

* update changelog

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2022-06-14 14:17:40 +02:00
Jordan Pittman
a9c7e52a59
Fix extraction of multi-word utilities with arbitrary values and quotes (#8604)
* Fix extraction of multi-word utilityies with arbitrary values and quotes

* Update  changelog

* Fix changelog entry

This wasn’t in 3.1.2 oops
2022-06-12 10:10:10 -04:00
Jordan Pittman
0664aae901
Fix class detection in markdown code fences and slim templates (#8569)
* Fix detection of classes in markdown code fences

* Fix candidate detection in `.slim` templates

* Update changelog
2022-06-09 16:53:02 -04:00
Robin Malfait
9a5db88e54
Fix candidate extractor regression (#8558)
* fix regression

This is a regression where `%>utility<%` didn't properly abstract
`utility`

* update changelog
2022-06-09 18:22:20 +02:00
Robin Malfait
be51739337
Arbitrary variants (#8299)
* register arbitrary variants

With the new `addVariant` API, we have a beautiful way of creating new
variants.

You can use it as:
```js
addVariant('children', '& > *')
```

Now you can use the `children:` variant. The API uses a `&` as a
reference for the candidate, which means that:
```html
children:pl-4
```

Will result in:
```css
.children\:pl-4 > * { .. }
```

Notice that the `&` was replaced by `.children\:pl-4`.

We can leverage this API to implement arbitrary variants, this means
that you can write those `&>*` (Notice that we don't have spaces) inside
a variant directly. An example of this can be:
```html
<ul class="[&>*]:underline">
  <li>A</li>
  <li>B</li>
  <li>C</li>
</ul>
```
Which generates the following css:
```css
.\[\&\>\*\]\:underline > * {
  text-decoration-line: underline;
}
```

Now all the children of the `ul` will have an `underline`. The selector
itself is a bit crazy since it contains the candidate which is the
selector itself, it is just escaped.

* add tests for arbitrary variants

This still requires some work to the `defaultExtractor` to make sure it
all works with existing code.

* update changelog

* Fix candidate detection for arbitrary variants

* Refactor

* Add support for at rules

* Add test for attribute selectors

* Fix test

* Add attribute selector support

* Split top-level comma parsing into a generalized splitting routine

We can now split on any character at the top level with any nesting. We don’t balance brackets directly here but this is probably “enough”

* Split variants by separator at the top-level only

This means that the separator has to be ouside of balanced brackets

* Fix extraction when using custom variant separators

* Support custom separators when top-level splitting variants

* Add a second multi-character separator test

* Split tests for at-rule and at-rule with selector changes

* Add nested at-rule tests

* Fix space-less at-rule parsing in addVariant

* Add test for using with `@apply`

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
2022-05-08 12:24:59 -04:00
Jordan Pittman
d676086a75
Rewrite default class extractor (#8204)
* Rewrite default extractor

* Eliminate lookbehind assertions in expand apply at rules

* Update changelog
2022-05-04 16:08:25 -04:00
Samuel Alev
bc46d0e0bc
Fix extraction from template literal/function with array (#7481)
* fix: allow extraction from template literal with array

* fix: support extraction from array in function

* test: add more tests for function and template

* test: add test for dynamic classes

* test: add dynamic class test in js

* test: add dynamic class test in js single quote

* Cleanup a bit

* Update changelog

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2022-03-01 14:23:06 -05:00
Jordan Pittman
db475be6dd
Support arbitrary values + calc + theme with quotes (#7462)
* Support arbitrary values + calc + theme with quotes

* Update changelog
2022-02-14 15:44:27 -05:00
Robin Malfait
3149738035
Properly detect theme() value usage in arbitrary properties (#6854)
* properly detect theme value in arbitrary properties

* update changelog
2022-01-03 13:12:43 +01:00
Robin Malfait
b341813d3f
Ensure we can use < and > characters in modifiers (#6851)
* ensure we can use "special" characters in modifiers

Fixes: #6778

* update changelog
2022-01-03 11:17:58 +01:00
Adam Wathan
da7396cf77 Sketching out more specific tests for our default extractor 2021-12-24 12:56:53 -05:00
Robin Malfait
9e03a6800b
Improve jsx interpolation candidate matching (#6593)
* ensure that strangely used jsx with interpolation gets detected

Co-authored-by: Luke Warlow <projects@warlow.dev>
Co-authored-by: Jordan Pittman <jordan@cryptica.me>

* update changelog

Co-authored-by: Luke Warlow <projects@warlow.dev>
Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2021-12-17 17:32:50 +01:00
Jordan Pittman
27c67fef43
Properly extract classes with arbitrary values in arrays and classes followed by escaped quotes (#6590)
Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2021-12-17 10:15:36 -05:00