No description
Find a file
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
.github Update release.yml 2021-10-01 11:54:43 -04:00
integrations Enable optimize universal defaults by default (#5635) 2021-10-06 17:45:26 +02:00
jest JIT: Optimize universal selector usage by inlining only the relevant selectors (#4850) 2021-07-01 06:33:37 -04:00
nesting Remove AOT (#5340) 2021-09-01 17:13:59 +02:00
perf Performance improvements + memory leak fix (#3032) 2020-12-11 15:03:49 +01:00
scripts Polish match APIs (#5664) 2021-10-01 17:31:09 +02:00
src Enable optimize universal defaults by default (#5635) 2021-10-06 17:45:26 +02:00
stubs Add flex-basis utilities (#5671) 2021-10-04 15:47:14 -04:00
tests Enable optimize universal defaults by default (#5635) 2021-10-06 17:45:26 +02:00
.editorconfig Convert new stuff to use ES6 modules 2017-08-27 18:02:41 -04:00
.eslintignore Generate plugin list file (#4725) 2021-06-23 14:13:03 -04:00
.eslintrc.json Remove duplicate prettier.config.js settings from .eslintrc.json (#5087) 2021-09-01 17:41:43 +02:00
.gitignore Remove AOT (#5340) 2021-09-01 17:13:59 +02:00
.swcrc Switch to swc from babel (#5593) 2021-09-24 19:17:19 +02:00
base.css Remove preflight CSS export in favor of base 2019-02-11 12:38:46 -05:00
CHANGELOG.md Update changelog 2021-10-04 15:53:52 -04:00
colors.js Improve public API (#5526) 2021-09-26 12:44:13 +02:00
components.css Move CSS files to root for easier imports 2018-03-13 10:05:24 -04:00
defaultConfig.js Improve public API (#5526) 2021-09-26 12:44:13 +02:00
defaultTheme.js Improve public API (#5526) 2021-09-26 12:44:13 +02:00
LICENSE Avoid updating license every year 2017-12-29 22:32:43 +01:00
package-lock.json Update jest to version 27.2.4 2021-10-05 10:27:50 +00:00
package.json Update jest to version 27.2.4 2021-10-05 10:27:50 +00:00
plugin.js Improve public API (#5526) 2021-09-26 12:44:13 +02:00
prettier.config.js Add Prettier configuration file (prettier.config.js) (#3713) 2021-05-13 09:07:24 -04:00
README.md Update README.md 2021-09-14 14:49:09 -04:00
resolveConfig.js Improve public API (#5526) 2021-09-26 12:44:13 +02:00
screens.css Add screen.css file for postcss-import convenience 2019-05-12 10:36:59 -04:00
tailwind.css Undo accidental changes to CDN build process 2019-12-25 13:54:09 -05:00
utilities.css Move CSS files to root for easier imports 2018-03-13 10:05:24 -04:00
variants.css JIT: Replace @tailwind screens with @tailwind variants (#4356) 2021-05-14 13:58:52 -04:00

Tailwind CSS
A utility-first CSS framework for rapidly building custom user interfaces.

Build Status Total Downloads Latest Release License


Documentation

For full documentation, visit tailwindcss.com.

Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discuss Tailwind CSS on GitHub

For casual chit-chat with others using the framework:

Join the Tailwind CSS Discord Server

Contributing

If you're interested in contributing to Tailwind CSS, please read our contributing docs before submitting a pull request.