Skip to content

Using :where(.anything) in a plugin and having !anything inside HTML, creates invalid CSS #10582

@saadeghi

Description

@saadeghi

What version of Tailwind CSS are you using?

3.2.6

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

Tailwind Play (or any tool)

Reproduction URL

https://play.tailwindcss.com/Oy7NHRkftL?file=config

Describe your issue

If there is string with ! prefix with the same class from a plugin that has a :where() selector, Tailwind creates invalid CSS

HTML:

!btn

tailwind.config.js:

const plugin = require('tailwindcss/plugin')
module.exports = {
  plugins: [
    plugin(function({ addComponents }) {
      addComponents({
        '.btn': {
          backgroundColor: 'red',
        },
        ':where(.btn)': {
          backgroundColor: 'blue',
        },
      })
    })
  ]
}

Generated CSS:

.\!btn {
  background-color: red !important
}

 {
  background-color: blue !important
}

As you can see it can't apply important to the :where() selector and it generates an empty selector.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions