tailwindcss/packages
Jordan Pittman ee987e3f6a
Discard matchVariant matches with unknown named values (#18799)
This PR fixes two issues:
- When a variant is defined by `matchVariant` it could match unknown
values but not apply the variant (because it's unknown). This would
result in a utility being output that is the _same_ as a bare utility
without variants but a longer name. These were intended to be discarded
but weren't done so correctly.
- Similarly, when we encounter a known value but its not a string the
same thing would happen where we'd output a utility without applying the
variant. This was also intended to be discarded.

Basically given this code:
```js
matchVariant(
  "foo",
  (value) => `&:is([data-foo='${value}'])`,
  {
    values: {
      DEFAULT: "",
      bar: "bar",
      obj: { some: "object" },
    },
  }
)
```

And this HTML:
```html
<div class="foo-bar:bg-none foo-[baz]:bg-none foo-baz:bg-none foo-obj:bg-none"></div>
```

This CSS would be produced:
```css
@layer utilities {
  .foo-bar\:bg-none {
    &:is([data-foo='bar']) {
      background-image: none;
    }
  }
  /* this one shouldn't be here */
  .foo-baz\:bg-none {
    background-image: none;
  }
  /* this one shouldn't be here */
  .foo-obj\:bg-none {
    background-image: none;
  }
  .foo-\[baz\]\:bg-none {
    &:is([data-foo='baz']) {
      background-image: none;
    }
  }
}
```
2025-08-26 10:21:15 -04:00
..
@tailwindcss-browser Drop warning from browser build (#18732) 2025-08-14 12:20:19 -04:00
@tailwindcss-cli Prepare v4.1.12 release (#18728) 2025-08-14 14:35:49 +02:00
@tailwindcss-node Prepare v4.1.12 release (#18728) 2025-08-14 14:35:49 +02:00
@tailwindcss-postcss Prepare v4.1.12 release (#18728) 2025-08-14 14:35:49 +02:00
@tailwindcss-standalone Prepare v4.1.12 release (#18728) 2025-08-14 14:35:49 +02:00
@tailwindcss-upgrade Prepare v4.1.12 release (#18728) 2025-08-14 14:35:49 +02:00
@tailwindcss-vite Prepare v4.1.12 release (#18728) 2025-08-14 14:35:49 +02:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss Discard matchVariant matches with unknown named values (#18799) 2025-08-26 10:21:15 -04:00
tsconfig.base.json Improve debug logs (#15303) 2024-12-11 15:27:20 +01:00