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

Custom content property doesn't work with nested structure #3546

Closed
4 tasks done
ErriourMe opened this issue Feb 2, 2024 · 6 comments
Closed
4 tasks done

Custom content property doesn't work with nested structure #3546

ErriourMe opened this issue Feb 2, 2024 · 6 comments

Comments

@ErriourMe
Copy link

UnoCSS version

0.58.4

Describe the bug

I'm trying to set point delimiters between elements (First * second * third).
Class to resolve this my thing: [&>div+div]:before:content-['•']. But it doesnt work. It works for any other classes, for empty content ([&>div+div]:before:content-empty), but custom content can't be accepted.
Looks like a bug.

Reproduction

UnoCSS Playground link

System Info

No response

Validations

@henrikvilhelmberglund
Copy link
Contributor

@RebeccaStevens
Copy link
Contributor

I don't really know why but you need to place before: in front of the arbitrary selector for it to work

before: is a variant so it needs to go first.
A variant modifies what comes after it, in this case modifying the [&>div+div] selector to select the :before of it.

@unocss unocss deleted a comment from study-heitaitou Mar 6, 2024
@henrikvilhelmberglund
Copy link
Contributor

I don't really know why but you need to place before: in front of the arbitrary selector for it to work

before: is a variant so it needs to go first. A variant modifies what comes after it, in this case modifying the [&>div+div] selector to select the :before of it.

Isn't the selector also a variant? I don't really see why the order should matter here, it also works fine in the Tailwind playground https://play.tailwindcss.com/wPJpEcPN78

@RebeccaStevens
Copy link
Contributor

I don't really know why but you need to place before: in front of the arbitrary selector for it to work

before: is a variant so it needs to go first. A variant modifies what comes after it, in this case modifying the [&>div+div] selector to select the :before of it.

Isn't the selector also a variant? I don't really see why the order should matter here, it also works fine in the Tailwind playground play.tailwindcss.com/wPJpEcPN78

Ahh, yes sorry, my bad. [&>div+div] and before are both variants. content-['•'] is the selector.
This does in fact look like a bug to me.

@RebeccaStevens
Copy link
Contributor

Did a small amount of digging.

With before:[&>div+div]:content-['•'], the pseudo:before variant get allied first just fine.
But then the variables variant matches twice, instead of once.
The first match returns content-['•'] as the next part to match against (this is what we want).
But the second match returns content-['.

This issue isn't obviously noticeable though as one of the matches is right.

The issue with [&>div+div]:before:content-['•'] is that it only matches once and that returns before:content-[ as the next part to match against.

The issue seems to be caused by the double use of square brackets.

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

4 participants