Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

before:first-of-type: ordering behavior changed in 3.0 #6112

Closed
david-crespo opened this issue Nov 16, 2021 · 1 comment
Closed

before:first-of-type: ordering behavior changed in 3.0 #6112

david-crespo opened this issue Nov 16, 2021 · 1 comment

Comments

@david-crespo
Copy link

david-crespo commented Nov 16, 2021

What version of Tailwind CSS are you using?

For example: v3.0-alpha.2

What build tool (or framework if it abstracts the build tool) are you using?

Vite and PostCSS for work, but I have a repro using the playground

What version of Node.js are you using?

v16

What browser are you using?

N/A

What operating system are you using?

macOS

Reproduction URL

Change the version between 2.2 and 3.0 to see the different behavior

https://play.tailwindcss.com/dwCf2InE54

Describe your issue

The order of ::first-of-type and ::before in the output is flipped in 3.0. I don't really have any opinion about which order is correct, but the change should at least be documented in the release notes (or fixed if unintentional).

// input
first-of-type:before:content-none

// output 2.2
.first-of-type\:before\:content-none:first-of-type::before {
    content: none;
}

// output 3.0-alpha.2
.first-of-type\:before\:content-none::before:first-of-type {
  --tw-content: none;
  content: var(--tw-content);
}

You have to switch the order to get the desired output in 3.0:

// input
before:first-of-type:content-none

// output 2.2
.before\:first-of-type\:content-none::before:first-of-type {
  content: none;
}

// output 3.0-alpha.2
.before\:first-of-type\:content-none:first-of-type::before {
    --tw-content: none;
    content: var(--tw-content);
}

Also the linter whines when you do it the second way:

Variants are not in the recommended order, which may cause unexpected CSS output.(recommendedVariantOrder)
@david-crespo
Copy link
Author

Never mind! I see now this is a dupe of #6016, and you fixed it in #6018, which will presumably be in the next alpha.

david-crespo added a commit to oxidecomputer/console that referenced this issue Nov 17, 2021
* upgrade to tailwind 3.0 alpha, make config changes

* rewrite svg: w/ new addVariant API tailwindlabs/tailwindcss#5809

* first first-of-type:before: order issue (tw fix in next alpha)

tailwindlabs/tailwindcss#6112
tailwindlabs/tailwindcss#6016
tailwindlabs/tailwindcss#6018

* replace tailwindcss-children plugin with new custom addVariant

* oh yeah... use stroke-green-500

* each variant doesn't need its own plugin

* update yarn.lock after merging main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant