Fix merging of arrays during config resolution (#9706)
* Fix merging of arrays during config resolution * Update changelog
This commit is contained in:
parent
661f58ce8b
commit
e231ea6c61
3 changed files with 8 additions and 9 deletions
|
|
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Escape special characters in resolved content base paths ([#9650](https://github.com/tailwindlabs/tailwindcss/pull/9650))
|
||||
- Don't reuse container for array returning variant functions ([#9644](https://github.com/tailwindlabs/tailwindcss/pull/9644))
|
||||
- Exclude non-relevant selectors when generating rules with the important modifier ([#9677](https://github.com/tailwindlabs/tailwindcss/issues/9677))
|
||||
- Fix merging of arrays during config resolution ([#9706](https://github.com/tailwindlabs/tailwindcss/issues/9706))
|
||||
|
||||
## [3.2.1] - 2022-10-21
|
||||
|
||||
|
|
|
|||
|
|
@ -16,10 +16,6 @@ function isFunction(input) {
|
|||
return typeof input === 'function'
|
||||
}
|
||||
|
||||
function isObject(input) {
|
||||
return typeof input === 'object' && input !== null
|
||||
}
|
||||
|
||||
function mergeWith(target, ...sources) {
|
||||
let customizer = sources.pop()
|
||||
|
||||
|
|
@ -28,7 +24,7 @@ function mergeWith(target, ...sources) {
|
|||
let merged = customizer(target[k], source[k])
|
||||
|
||||
if (merged === undefined) {
|
||||
if (isObject(target[k]) && isObject(source[k])) {
|
||||
if (isPlainObject(target[k]) && isPlainObject(source[k])) {
|
||||
target[k] = mergeWith({}, target[k], source[k], customizer)
|
||||
} else {
|
||||
target[k] = source[k]
|
||||
|
|
@ -103,12 +99,12 @@ function mergeThemes(themes) {
|
|||
|
||||
function mergeExtensionCustomizer(merged, value) {
|
||||
// When we have an array of objects, we do want to merge it
|
||||
if (Array.isArray(merged) && isObject(merged[0])) {
|
||||
if (Array.isArray(merged) && isPlainObject(merged[0])) {
|
||||
return merged.concat(value)
|
||||
}
|
||||
|
||||
// When the incoming value is an array, and the existing config is an object, prepend the existing object
|
||||
if (Array.isArray(value) && isObject(value[0]) && isObject(merged)) {
|
||||
if (Array.isArray(value) && isPlainObject(value[0]) && isPlainObject(merged)) {
|
||||
return [merged, ...value]
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -591,6 +591,8 @@ test('theme values in the extend section are not deeply merged when they are sim
|
|||
extend: {
|
||||
fonts: {
|
||||
sans: ['Comic Sans'],
|
||||
serif: ['Papyrus', { fontFeatureSettings: '"cv11"' }],
|
||||
mono: [['Lobster', 'Papyrus'], { fontFeatureSettings: '"cv11"' }],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -619,8 +621,8 @@ test('theme values in the extend section are not deeply merged when they are sim
|
|||
theme: {
|
||||
fonts: {
|
||||
sans: ['Comic Sans'],
|
||||
serif: ['Constantia', 'Georgia', 'serif'],
|
||||
mono: ['Menlo', 'Courier New', 'monospace'],
|
||||
serif: ['Papyrus', { fontFeatureSettings: '"cv11"' }],
|
||||
mono: [['Lobster', 'Papyrus'], { fontFeatureSettings: '"cv11"' }],
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue