From adb95805c599294b72e8d4983c8e1f64c34c813c Mon Sep 17 00:00:00 2001 From: woohm402 Date: Fri, 23 May 2025 01:27:04 +0900 Subject: [PATCH] fix --- .../src/compat/apply-config-to-theme.test.ts | 2 ++ packages/tailwindcss/src/theme.ts | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/tailwindcss/src/compat/apply-config-to-theme.test.ts b/packages/tailwindcss/src/compat/apply-config-to-theme.test.ts index 3a748fd8b306..2b29756459be 100644 --- a/packages/tailwindcss/src/compat/apply-config-to-theme.test.ts +++ b/packages/tailwindcss/src/compat/apply-config-to-theme.test.ts @@ -55,6 +55,7 @@ test('config values can be merged into the theme', () => { lg: ['1.125rem', '2'], xl: ['1.5rem', '3rem', 'invalid'], '2xl': ['2rem'], + LargeTitle: ['28px', { fontWeight: 700, lineHeight: '36px' }], }, letterSpacing: { @@ -117,6 +118,7 @@ test('config values can be merged into the theme', () => { ]) expect(theme.resolve('2xl', ['--text'])).toEqual('2rem') expect(theme.resolveWith('2xl', ['--text'], ['--line-height'])).toEqual(['2rem', {}]) + expect(theme.resolve('LargeTitle', ['--text'])).toEqual('28px') expect(theme.resolve('super-wide', ['--tracking'])).toEqual('0.25em') expect(theme.resolve('super-loose', ['--leading'])).toEqual('3') expect(theme.resolve('1/2', ['--width'])).toEqual('60%') diff --git a/packages/tailwindcss/src/theme.ts b/packages/tailwindcss/src/theme.ts index 2928afd3bd55..fbefab86e07b 100644 --- a/packages/tailwindcss/src/theme.ts +++ b/packages/tailwindcss/src/theme.ts @@ -165,10 +165,12 @@ export class Theme { candidateValue !== null ? (`${namespace}-${candidateValue}` as ThemeKey) : namespace if (!this.values.has(themeKey)) { - // If the exact theme key is not found, we might be trying to resolve a key containing a dot - // that was registered with an underscore instead: - if (candidateValue !== null && candidateValue.includes('.')) { - themeKey = `${namespace}-${candidateValue.replaceAll('.', '_')}` as ThemeKey + if (candidateValue !== null) { + // If the exact theme key is not found, we might be trying to resolve a key: + // - containing a dot that was registered with an underscore instead + // - containing a lowercase alphabet followed by an uppercase one that was replaced to kebab case + themeKey = + `${namespace}-${candidateValue.replaceAll('.', '_').replace(/([a-z])([A-Z])/g, (_, a, b) => `${a}-${b.toLowerCase()}`)}` as ThemeKey if (!this.values.has(themeKey)) continue } else {