Skip to content

Commit 958bfc9

Browse files
Pass options when using addComponents and matchComponents (#14590)
We forgot to pass `options` from `addComponents` to `addUtilities` and from `matchComponents` to `matchUtilities`. This didn't affect anything using addComponents but anything that used `matchComponents` wouldn't have worked 😬
1 parent a6231b7 commit 958bfc9

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2222
- Fix issue that could cause the CLI to crash when files are deleted while watching ([#14616](https://github.com/tailwindlabs/tailwindcss/pull/14616))
2323
- Ensure custom variants using the JS API have access to modifiers ([#14637](https://github.com/tailwindlabs/tailwindcss/pull/14637))
2424
- Ensure auto complete suggestions work when using `matchUtilities` ([#14589](https://github.com/tailwindlabs/tailwindcss/pull/14589))
25+
- Pass options when using `addComponents` and `matchComponents` ([#14590](https://github.com/tailwindlabs/tailwindcss/pull/14590))
2526
- _Upgrade (experimental)_: Ensure CSS before a layer stays unlayered when running codemods ([#14596](https://github.com/tailwindlabs/tailwindcss/pull/14596))
2627
- _Upgrade (experimental)_: Resolve issues where some prefixed candidates were not properly migrated ([#14600](https://github.com/tailwindlabs/tailwindcss/pull/14600))
2728

Diff for: packages/tailwindcss/src/compat/plugin-api.test.ts

+45
Original file line numberDiff line numberDiff line change
@@ -3544,6 +3544,51 @@ describe('addComponents()', () => {
35443544
})
35453545
})
35463546

3547+
describe('matchComponents()', () => {
3548+
test('is an alias for matchUtilities', async () => {
3549+
let compiled = await compile(
3550+
css`
3551+
@plugin "my-plugin";
3552+
@tailwind utilities;
3553+
`,
3554+
{
3555+
async loadModule(id, base) {
3556+
return {
3557+
base,
3558+
module: ({ matchComponents }: PluginAPI) => {
3559+
matchComponents(
3560+
{
3561+
prose: (value) => ({ '--container-size': value }),
3562+
},
3563+
{
3564+
values: {
3565+
DEFAULT: 'normal',
3566+
sm: 'sm',
3567+
lg: 'lg',
3568+
},
3569+
},
3570+
)
3571+
},
3572+
}
3573+
},
3574+
},
3575+
)
3576+
3577+
expect(optimizeCss(compiled.build(['prose', 'sm:prose-sm', 'hover:prose-lg'])).trim())
3578+
.toMatchInlineSnapshot(`
3579+
".prose {
3580+
--container-size: normal;
3581+
}
3582+
3583+
@media (hover: hover) {
3584+
.hover\\:prose-lg:hover {
3585+
--container-size: lg;
3586+
}
3587+
}"
3588+
`)
3589+
})
3590+
})
3591+
35473592
describe('prefix()', () => {
35483593
test('is an identity function', async () => {
35493594
let fn = vi.fn()

Diff for: packages/tailwindcss/src/compat/plugin-api.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -371,11 +371,11 @@ export function buildPluginApi(
371371
},
372372

373373
addComponents(components, options) {
374-
this.addUtilities(components)
374+
this.addUtilities(components, options)
375375
},
376376

377377
matchComponents(components, options) {
378-
this.matchUtilities(components)
378+
this.matchUtilities(components, options)
379379
},
380380

381381
theme: createThemeFn(

0 commit comments

Comments
 (0)