Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with Tailwind modifying global state #9294

Merged
merged 7 commits into from Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Don't output duplicate utilities ([#9208](https://github.com/tailwindlabs/tailwindcss/pull/9208))
- Fix `fontFamily` config TypeScript types ([#9214](https://github.com/tailwindlabs/tailwindcss/pull/9214))
- Handle variants on complex selector utilities ([#9262](https://github.com/tailwindlabs/tailwindcss/pull/9262))
- Don't mutate shared config objects ([#9294](https://github.com/tailwindlabs/tailwindcss/pull/9294))

## [3.1.8] - 2022-08-05

Expand Down
2 changes: 1 addition & 1 deletion src/util/resolveConfig.js
Expand Up @@ -29,7 +29,7 @@ function mergeWith(target, ...sources) {

if (merged === undefined) {
if (isObject(target[k]) && isObject(source[k])) {
target[k] = mergeWith(target[k], source[k], customizer)
target[k] = mergeWith({}, target[k], source[k], customizer)
} else {
target[k] = source[k]
}
Expand Down
27 changes: 27 additions & 0 deletions tests/resolveConfig.test.js
Expand Up @@ -1763,3 +1763,30 @@ test('all helpers can be destructured from the first function argument', () => {
},
})
})

test('does not duplicate extended configs every time resolveConfig is called', () => {
let shared = {
foo: { bar: { baz: [{ color: 'red' }] } },
}

const createConfig = (color) =>
resolveConfig([
{
theme: {
foo: shared.foo,
extend: {
foo: { bar: { baz: { color } } },
},
},
},
])

createConfig('orange')
createConfig('yellow')
createConfig('green')

const result = createConfig('blue')

expect(shared.foo.bar.baz).toMatchObject([{ color: 'red' }])
expect(result.theme.foo.bar.baz).toMatchObject([{ color: 'red' }, { color: 'blue' }])
})