Skip to content

Commit e231ea6

Browse files
authored
Fix merging of arrays during config resolution (#9706)
* Fix merging of arrays during config resolution * Update changelog
1 parent 661f58c commit e231ea6

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Escape special characters in resolved content base paths ([#9650](https://github.com/tailwindlabs/tailwindcss/pull/9650))
1313
- Don't reuse container for array returning variant functions ([#9644](https://github.com/tailwindlabs/tailwindcss/pull/9644))
1414
- Exclude non-relevant selectors when generating rules with the important modifier ([#9677](https://github.com/tailwindlabs/tailwindcss/issues/9677))
15+
- Fix merging of arrays during config resolution ([#9706](https://github.com/tailwindlabs/tailwindcss/issues/9706))
1516

1617
## [3.2.1] - 2022-10-21
1718

src/util/resolveConfig.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ function isFunction(input) {
1616
return typeof input === 'function'
1717
}
1818

19-
function isObject(input) {
20-
return typeof input === 'object' && input !== null
21-
}
22-
2319
function mergeWith(target, ...sources) {
2420
let customizer = sources.pop()
2521

@@ -28,7 +24,7 @@ function mergeWith(target, ...sources) {
2824
let merged = customizer(target[k], source[k])
2925

3026
if (merged === undefined) {
31-
if (isObject(target[k]) && isObject(source[k])) {
27+
if (isPlainObject(target[k]) && isPlainObject(source[k])) {
3228
target[k] = mergeWith({}, target[k], source[k], customizer)
3329
} else {
3430
target[k] = source[k]
@@ -103,12 +99,12 @@ function mergeThemes(themes) {
10399

104100
function mergeExtensionCustomizer(merged, value) {
105101
// When we have an array of objects, we do want to merge it
106-
if (Array.isArray(merged) && isObject(merged[0])) {
102+
if (Array.isArray(merged) && isPlainObject(merged[0])) {
107103
return merged.concat(value)
108104
}
109105

110106
// When the incoming value is an array, and the existing config is an object, prepend the existing object
111-
if (Array.isArray(value) && isObject(value[0]) && isObject(merged)) {
107+
if (Array.isArray(value) && isPlainObject(value[0]) && isPlainObject(merged)) {
112108
return [merged, ...value]
113109
}
114110

tests/resolveConfig.test.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,8 @@ test('theme values in the extend section are not deeply merged when they are sim
591591
extend: {
592592
fonts: {
593593
sans: ['Comic Sans'],
594+
serif: ['Papyrus', { fontFeatureSettings: '"cv11"' }],
595+
mono: [['Lobster', 'Papyrus'], { fontFeatureSettings: '"cv11"' }],
594596
},
595597
},
596598
},
@@ -619,8 +621,8 @@ test('theme values in the extend section are not deeply merged when they are sim
619621
theme: {
620622
fonts: {
621623
sans: ['Comic Sans'],
622-
serif: ['Constantia', 'Georgia', 'serif'],
623-
mono: ['Menlo', 'Courier New', 'monospace'],
624+
serif: ['Papyrus', { fontFeatureSettings: '"cv11"' }],
625+
mono: [['Lobster', 'Papyrus'], { fontFeatureSettings: '"cv11"' }],
624626
},
625627
},
626628
})

0 commit comments

Comments
 (0)