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

feat(core,preset-mini)!: change pseudo sort and add no-merge #2425

Closed
wants to merge 6 commits into from

Conversation

chu121su12
Copy link
Collaborator

To match tailwind's behavior as mentioned in #2416, unocss need to not merge the css output. The noMerge flag in generate() is non-breaking, but it may not be enough to address the issue. The second changes--which maybe breaking--is in the preset-mini, with altering pseudoModifier behavior, such that:

  • all pseudo now have sort meta set
  • the pseudo is ordered such that:
    • raw rule < fn pseudo (+10 sort) < normal pseudo (+30) < tagged (peer, group, etc; +50)
    • the order of :active is still ahead of each modifier above (+10 each)
      This ordering (by itself) should not change how the css are generated since it will just change the order where they appear inside the comma separated selectors. But with the changes in sort value, it is a just in case breaking scenario just to be safe.

The order of fn pseudo vs normal pseudo may be too much of a change, but if you really need to change the sort order, you may opt in to the uno-layer-x variant for better sort control.

In short, previously:

/* layer: default */
.focus\:top-0:focus,
.top-0{top:0;}

after, with global noMerge:

/* layer: default */
.top-0{top:0;}
.focus\:top-0:focus{top:0;}

@netlify
Copy link

netlify bot commented Apr 2, 2023

Deploy Preview for unocss canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit cf418ee
🔍 Latest deploy log https://app.netlify.com/sites/unocss/deploys/64292d5ec7bb0600084d5907

@sibbng
Copy link
Member

sibbng commented Apr 2, 2023

I addressed some related issues in #1973. But that noMerge option on the generate function seems unnecessary since we already have the mergeSelectors option in the config. And this approach doesn't fix the issue on userland since generate option is supposed to be used by lib authors.

In my opinion disabling merge shouldn't change the order of the rules. This sounds like a side effect.

Merging is useful when users have classes like w4 and w-4 in their code. But when it comes to pseudos, we shouldn't merge them with raw utilities to keep their specificity consistent.

@chu121su12 chu121su12 closed this Apr 2, 2023
@chu121su12 chu121su12 deleted the feat/no-merge branch April 2, 2023 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants