mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Don't mutate the user's config when resolving
This commit is contained in:
parent
b8e7c12cfd
commit
7e1113561a
@ -826,3 +826,43 @@ test('theme values in the extend section are lazily evaluated', () => {
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test('the original theme is not mutated', () => {
|
||||
const userConfig = {
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
orange: 'orange',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
const defaultConfig = {
|
||||
prefix: '-',
|
||||
important: false,
|
||||
separator: ':',
|
||||
theme: {
|
||||
colors: {
|
||||
cyan: 'cyan',
|
||||
magenta: 'magenta',
|
||||
yellow: 'yellow',
|
||||
},
|
||||
},
|
||||
variants: {
|
||||
borderColor: ['responsive', 'hover', 'focus'],
|
||||
},
|
||||
}
|
||||
|
||||
resolveConfig([userConfig, defaultConfig])
|
||||
|
||||
expect(userConfig).toEqual({
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
orange: 'orange',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
@ -38,7 +38,7 @@ function resolveFunctionKeys(object) {
|
||||
export default function resolveConfig(configs) {
|
||||
return defaults(
|
||||
{
|
||||
theme: resolveFunctionKeys(mergeExtensions(defaults(...map(configs, 'theme')))),
|
||||
theme: resolveFunctionKeys(mergeExtensions(defaults({}, ...map(configs, 'theme')))),
|
||||
variants: defaults(...map(configs, 'variants')),
|
||||
},
|
||||
...configs
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user