tailwindcss/tests
Robin Malfait b661614265
Enable optimize universal defaults by default (#5635)
* enabled `optimizeUniversalDefaults` by default

This PR is done in a way so that the default is set to `true`, but you
can still disable it if it causes issues. In this case we do appreciate
an issue in that case 😅.

* update tests to use optimized universal selector

* update integration tests

* add dedicated tests for the optimized universal selector

* improve minimumImpactSelector algorithm

I think I cracked the algorithm, but I will probably need another pair
of eyes on the subject.

The current implementation works like this:

Prerequisites:

- The selector should already have been parsed using the selectorParser
  from 'postcss-selector-parser'.

Algorithm:

1. Remove all of the pseudo classes from the list of nodes.
  1.1. We do want to keep pseudo elements (E.g.: `::before`, `::first-line`, ...)
  1.2. We do want to keep pseudo classes that contain nodes (E.g.:
    `:not(...)`)
2. Reverse the list of nodes.
  This will make it easier to search from the end to the start. For
  example `.group:hover .group-hover` should result in `.group-hover`
  not `.group`.
  2.1. Find the index of the best match (class, id, attribute), and
    convert the node if required. (E.g.: `span#app` -> `#app` => `[id="app"]`)
  2.2. Remove the rest of the selector that is not important anymore
  2.3. Re-join the left-over nodes together

* update tests using new algorithm

* also look for `tag` types

* take `tag` into account

* simplify logic

* add test to prove `rest.reverse()` in first case is required

In case we don't find a match (idx === -1), we use `rest.reverse()`.
However, it looks like you can just use `nodes` instead.
This is not entirely true, because the `rest` variable will contain only
the nodes that are not pseudo elements.

`*:hover` would result in `*:hover` instead of just `*`

* replace all nodes after > with a single universal selector
2021-10-06 17:45:26 +02:00
..
fixtures Remove AOT (#5340) 2021-09-01 17:13:59 +02:00
plugins Enable optimize universal defaults by default (#5635) 2021-10-06 17:45:26 +02:00
postcss-plugins/nesting Remove AOT (#5340) 2021-09-01 17:13:59 +02:00
util Remove variants related code (#5465) 2021-09-10 09:34:27 -04:00
animations.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
apply.test.css Update color parsing and formatting (#5442) 2021-09-09 16:15:53 +02:00
apply.test.html JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
apply.test.js Update color parsing and formatting (#5442) 2021-09-09 16:15:53 +02:00
arbitrary-values.test.css Add flex-basis utilities (#5671) 2021-10-04 15:47:14 -04:00
arbitrary-values.test.html Add flex-basis utilities (#5671) 2021-10-04 15:47:14 -04:00
arbitrary-values.test.js Detect ambiguity in arbitrary values (#5634) 2021-09-30 12:39:41 +02:00
basic-usage.test.css Enable optimize universal defaults by default (#5635) 2021-10-06 17:45:26 +02:00
basic-usage.test.html Add flex-basis utilities (#5671) 2021-10-04 15:47:14 -04:00
basic-usage.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
collapse-adjacent-rules.test.css JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
collapse-adjacent-rules.test.html JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
collapse-adjacent-rules.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
color-opacity-modifiers.test.js Handle old to new config when normalizing the config (#5658) 2021-10-01 12:56:54 +02:00
color.test.js Update color parsing and formatting (#5442) 2021-09-09 16:15:53 +02:00
combined-selectors.test.js Ensure full node stays, if only a partial is used (#5617) 2021-09-28 11:54:39 +02:00
configurePlugins.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
containerPlugin.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
context-reuse.test.html JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
context-reuse.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
context-reuse.worker.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
custom-extractors.test.css Update color parsing and formatting (#5442) 2021-09-09 16:15:53 +02:00
custom-extractors.test.html JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
custom-extractors.test.js Handle old to new config when normalizing the config (#5658) 2021-10-01 12:56:54 +02:00
custom-plugins.test.js Polish match APIs (#5664) 2021-10-01 17:31:09 +02:00
custom-separator.test.css JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
custom-separator.test.html JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
custom-separator.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
custom-transformers.test.js Handle old to new config when normalizing the config (#5658) 2021-10-01 12:56:54 +02:00
customConfig.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
dark-mode.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
defaultConfig.test.js Improve public API (#5526) 2021-09-26 12:44:13 +02:00
defaultTheme.test.js Improve public API (#5526) 2021-09-26 12:44:13 +02:00
detect-nesting.test.js Warn when nesting is detected (#5489) 2021-09-16 14:13:45 +02:00
escapeClassName.test.js [WIP] Unify JIT and AOT code paths (#4188) 2021-05-07 13:56:15 -04:00
evaluateTailwindFunctions.test.js Refactor internals to decouple watch strategies and extract IO 2021-05-26 09:43:05 -04:00
experimental.test.js Enable optimize universal defaults by default (#5635) 2021-10-06 17:45:26 +02:00
extractor-edge-cases.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
flattenColorPalette.test.js [WIP] Unify JIT and AOT code paths (#4188) 2021-05-07 13:56:15 -04:00
getClassList.test.js Rename completions and remove color information (#5662) 2021-10-01 09:41:27 +01:00
import-syntax.test.css Update color parsing and formatting (#5442) 2021-09-09 16:15:53 +02:00
import-syntax.test.html JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
import-syntax.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
important-boolean.test.css JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
important-boolean.test.html JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
important-boolean.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
important-modifier-prefix.test.css JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
important-modifier-prefix.test.html JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
important-modifier-prefix.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
important-modifier.test.css JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
important-modifier.test.html JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
important-modifier.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
important-selector.test.css JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
important-selector.test.html JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
important-selector.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
kitchen-sink.test.css Enable optimize universal defaults by default (#5635) 2021-10-06 17:45:26 +02:00
kitchen-sink.test.html JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
kitchen-sink.test.js Improve public API (#5526) 2021-09-26 12:44:13 +02:00
layer-at-rules.test.js port @layer tests from AOT to JIT mode (#5379) 2021-09-03 17:46:15 +02:00
layer-without-tailwind.test.css JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
layer-without-tailwind.test.html JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
layer-without-tailwind.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
match-components.test.js Enable optimize universal defaults by default (#5635) 2021-10-06 17:45:26 +02:00
minimum-impact-selector.test.js Enable optimize universal defaults by default (#5635) 2021-10-06 17:45:26 +02:00
modify-selectors.test.css JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
modify-selectors.test.html JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
modify-selectors.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
mutable.test.css JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
mutable.test.html JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
mutable.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
negated-content-ignore.test.html Fix using negated content globs (#5625) 2021-09-29 11:15:31 +01:00
negated-content-include.test.html Fix using negated content globs (#5625) 2021-09-29 11:15:31 +01:00
negated-content.test.js Fix using negated content globs (#5625) 2021-09-29 11:15:31 +01:00
negateValue.test.js [WIP] Unify JIT and AOT code paths (#4188) 2021-05-07 13:56:15 -04:00
normalize-config.test.js Handle old to new config when normalizing the config (#5658) 2021-10-01 12:56:54 +02:00
opacity.test.js Support using functions as colors when disabling color opacity utilities (#5470) 2021-09-10 09:35:15 -04:00
parallel-variants.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
parseAnimationValue.test.js ensure we don't override the name (#5602) 2021-09-26 07:44:41 -04:00
parseObjectStyles.test.js [WIP] Unify JIT and AOT code paths (#4188) 2021-05-07 13:56:15 -04:00
prefix.fn.test.css JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
prefix.fn.test.html JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
prefix.fn.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
prefix.test.css Update color parsing and formatting (#5442) 2021-09-09 16:15:53 +02:00
prefix.test.html JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
prefix.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
prefixSelector.test.js [WIP] Unify JIT and AOT code paths (#4188) 2021-05-07 13:56:15 -04:00
raw-content.test.css Add scroll-behavior utilities (#5388) 2021-09-11 09:13:28 -04:00
raw-content.test.html Add scroll-behavior utilities (#5388) 2021-09-11 09:13:28 -04:00
raw-content.test.js Handle old to new config when normalizing the config (#5658) 2021-10-01 12:56:54 +02:00
relative-purge-paths.test.html JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
relative-purge-paths.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
resolve-defaults-at-rules.test.js Enable optimize universal defaults by default (#5635) 2021-10-06 17:45:26 +02:00
resolveConfig.test.js Handle old to new config when normalizing the config (#5658) 2021-10-01 12:56:54 +02:00
responsive-and-variants-atrules.test.css JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
responsive-and-variants-atrules.test.html JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
responsive-and-variants-atrules.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
safelist.test.js Pattern safelisting (#5511) 2021-09-16 14:47:41 +02:00
screenAtRule.test.js Refactor internals to decouple watch strategies and extract IO 2021-05-26 09:43:05 -04:00
syntax-lit-html.test.js Add test for lit-html syntax 2021-09-21 12:41:58 -04:00
syntax-svelte.test.js Fix svelte test 2021-09-21 12:43:44 -04:00
syntax-svelte.test.svelte Rename svelte tests 2021-09-21 12:37:49 -04:00
tailwind-screens.test.js JIT by default - move tests and make them consistent (#5374) 2021-09-03 13:48:16 +02:00
to-path.test.js Remove lodash (#5390) 2021-09-06 14:15:10 -04:00
variants.test.css Enable optimize universal defaults by default (#5635) 2021-10-06 17:45:26 +02:00
variants.test.html Polish match APIs (#5664) 2021-10-01 17:31:09 +02:00
variants.test.js Polish match APIs (#5664) 2021-10-01 17:31:09 +02:00
withAlphaVariable.test.js Update color parsing and formatting (#5442) 2021-09-09 16:15:53 +02:00