Skip to content

Commit

Permalink
Revert "Warn on use of plugin parameters as function" (#14662)
Browse files Browse the repository at this point in the history
Reverts #14661
  • Loading branch information
philipp-spiess authored Oct 14, 2024
1 parent f2ebb8e commit 4e219dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 27 deletions.
12 changes: 2 additions & 10 deletions packages/tailwindcss/src/compat/config/resolve-config.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test, vi } from 'vitest'
import { expect, test } from 'vitest'
import { buildDesignSystem } from '../../design-system'
import { Theme } from '../../theme'
import { resolveConfig } from './resolve-config'
Expand Down Expand Up @@ -172,12 +172,7 @@ test('theme keys can reference other theme keys using the theme function regardl
})
})

test('theme keys can read from the CSS theme', ({ onTestFinished }) => {
let warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined)
onTestFinished(() => {
warn.mockReset()
})

test('theme keys can read from the CSS theme', () => {
let theme = new Theme()
theme.add('--color-green', 'green')

Expand Down Expand Up @@ -252,7 +247,4 @@ test('theme keys can read from the CSS theme', ({ onTestFinished }) => {
},
},
})
expect(warn).toHaveBeenCalledWith(
'Using the plugin object parameter as the theme function is deprecated. Please use the `theme` property instead.',
)
})
21 changes: 4 additions & 17 deletions packages/tailwindcss/src/compat/config/resolve-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,25 +175,12 @@ function extractConfigs(ctx: ResolutionContext, { config, base, path }: ConfigFi
ctx.configs.push(config)
}

let didWarnAboutUsingObjectArgumentAsThemeFn = false

function mergeTheme(ctx: ResolutionContext) {
let themeFn = createThemeFn(ctx.design, () => ctx.theme, resolveValue)
let theme = Object.assign(
(path: string, defaultValue?: any) => {
if (!didWarnAboutUsingObjectArgumentAsThemeFn) {
didWarnAboutUsingObjectArgumentAsThemeFn = true
console.warn(
'Using the plugin object parameter as the theme function is deprecated. Please use the `theme` property instead.',
)
}
return themeFn(path, defaultValue)
},
{
theme: themeFn,
colors,
},
)
let theme = Object.assign(themeFn, {
theme: themeFn,
colors,
})

function resolveValue(value: ThemeValue | null | undefined): ResolvedThemeValue {
if (typeof value === 'function') {
Expand Down

0 comments on commit 4e219dc

Please sign in to comment.