Skip to content

Commit 0796653

Browse files
Correctly merge tuple values when using the plugin API (tailwindlabs#14260)
We noticed that when the `defaultTheme` (change for this is coming in tailwindlabs#14257) defines a tuple that is also defined in the CSS theme, the values are incorrectly merged as objects instead of overwritten. However, CSS theme values should take precedence, even when they use tuple syntax. Proper coverage of this will come once `tailwindlabs#14257` is merged when calling `theme(fontSize.xs[1].lineHeight)` will also have a default value passed in from the `defaultTheme`.
1 parent ab89727 commit 0796653

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

1212
- Bring back type exports for the cjs build of `@tailwindcss/postcss`. ([#14256](https://github.com/tailwindlabs/tailwindcss/pull/14256))
13+
- Correctly merge tuple values when using the plugin API ([#14260](https://github.com/tailwindlabs/tailwindcss/pull/14260))
1314

1415
## [4.0.0-alpha.20] - 2024-08-23
1516

packages/tailwindcss/src/functions.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ describe('theme function', () => {
265265
expect(
266266
await compileCss(css`
267267
@theme {
268-
--font-size-xs: 0.75rem;
269-
--font-size-xs--line-height: 1rem;
268+
--font-size-xs: 1337.75rem;
269+
--font-size-xs--line-height: 1337rem;
270270
}
271271
.text {
272272
font-size: theme(fontSize.xs);
@@ -275,13 +275,13 @@ describe('theme function', () => {
275275
`),
276276
).toMatchInlineSnapshot(`
277277
":root {
278-
--font-size-xs: .75rem;
279-
--font-size-xs--line-height: 1rem;
278+
--font-size-xs: 1337.75rem;
279+
--font-size-xs--line-height: 1337rem;
280280
}
281281
282282
.text {
283-
font-size: .75rem;
284-
line-height: 1rem;
283+
font-size: 1337.75rem;
284+
line-height: 1337rem;
285285
}"
286286
`)
287287
})

packages/tailwindcss/src/theme-fn.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function createThemeFn(
2020

2121
let configValue = resolveValue(get(configTheme() ?? {}, keypath) ?? null)
2222

23-
if (configValue !== null && typeof configValue === 'object') {
23+
if (configValue !== null && typeof configValue === 'object' && !Array.isArray(configValue)) {
2424
return deepMerge({}, [configValue, cssValue], (_, b) => b)
2525
}
2626

0 commit comments

Comments
 (0)