Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix resolving theme keys when starting with the name of another theme key in JS configs and plugins ([#19097](https://github.com/tailwindlabs/tailwindcss/pull/19097))
- Allow named groups in combination with `not-*`, `has-*`, and `in-*` ([#19100](https://github.com/tailwindlabs/tailwindcss/pull/19100))
- Prevent important utilities from affecting other utilities ([#19110](https://github.com/tailwindlabs/tailwindcss/pull/19110))
- Don’t index into strings with the `theme(…)` function ([#19111](https://github.com/tailwindlabs/tailwindcss/pull/19111))
- Upgrade: Canonicalize utilities containing `0` values ([#19095](https://github.com/tailwindlabs/tailwindcss/pull/19095))

## [4.1.14] - 2025-10-01
Expand Down
32 changes: 32 additions & 0 deletions packages/tailwindcss/src/compat/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1687,3 +1687,35 @@ test('handles setting theme keys to null', async () => {
"
`)
})

test('The theme() function does not try indexing into strings', async () => {
let compiler = await compile(css`
@theme default {
--color-what-50: #f00;
--color-what-950: #f00;
}

@theme {
/*
* The value of this theme variable is > 50 chars because colors.what.50 was previously
* indexing the string: "light-dark(theme(colors.what.950), theme(colors.what.50))"
* because the resolved config contained an object with a "what" key that was that string
*/
--color-what: light-dark(theme(colors.what.950), theme(colors.what.50));
}

@source inline("text-what");

@tailwind utilities;
`)

expect(compiler.build([])).toMatchInlineSnapshot(`
":root, :host {
--color-what: light-dark(#f00, #f00);
}
.text-what {
color: var(--color-what);
}
"
`)
})
5 changes: 5 additions & 0 deletions packages/tailwindcss/src/compat/plugin-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ function get(obj: any, path: string[]) {
continue
}

// We never want to index into strings
if (typeof obj === 'string') {
return undefined
}

obj = obj[key]
}

Expand Down