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

Fails to compile "expected opening square bracket" with two attribute selectors #10052

Closed
jacobparis opened this issue Dec 11, 2022 · 2 comments · Fixed by #10059
Closed

Fails to compile "expected opening square bracket" with two attribute selectors #10052

jacobparis opened this issue Dec 11, 2022 · 2 comments · Fixed by #10059
Assignees

Comments

@jacobparis
Copy link

jacobparis commented Dec 11, 2022

What version of Tailwind CSS are you using?

Latest Tailwind v3.2.4, reproducible in live playground below.

Reproduction URL
https://play.tailwindcss.com/w66a9h6SsL

Describe your issue

The Tailwind compiler fails with Expected an opening square bracket. when parsing a second attribute selector after one with a value.

The following code attempts to style the element when one of its parents has two attributes. Checking for the presence of two attributes works flawlessly. Checking for the presence of one and the value of the second works great as well. Swapping the order of the attributes breaks the compiler.

  • [data-beta][data-testid]
  • [data-beta][data-testid='test']
  • [data-testid='test'][data-beta]
<ul data-testid="test" data-beta>

  <li class="[[data-beta][data-testid]_&]:bg-violet-500"> This works </li>
  <li class="[[data-beta][data-testid='test']_&]:bg-violet-500"> This works </li>
  <li class="[[data-testid='test'][data-beta]_&]:bg-violet-500"> This breaks </li>
</ul>
@thecrypticace
Copy link
Contributor

Looks like it's picking up [[data-testid='test'][data-beta]_&]:bg-violet-500 and [data-beta]_&]:bg-violet-500 as candidates — the latter of which would produce an invalid selector. I've merged in a fix for this that will be available in the next release. In the mean time you'll be able to test this fix via our insiders build once it's published (takes a few minutes): npm install tailwindcss@insiders

@jacobparis
Copy link
Author

Amazing, thank you!

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

Successfully merging a pull request may close this issue.

2 participants