Skip to content

Commit 0e2b451

Browse files
authored
Ensure multiple theme(spacing[5]) calls with bracket notation in arbitrary properties work (#11039)
* ensure that last `]` doesn't stop the match Given this input: ```html <div class="[width:_calc(theme(spacing[5])_+_theme(spacing[5]))]"></div> ``` Then we would expect the match to be this: ``` [width:_calc(theme(spacing[5])_+_theme(spacing[5]))] ``` However, with the `?`, then it would stop and result in: ``` [width:_calc(theme(spacing[5])_+_theme(spacing[5] ``` Which makes it incomplete because the `))]` are missing at the end. * update changelog
1 parent defdc4b commit 0e2b451

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Inherit gradient stop positions when using variants ([#11002](https://github.com/tailwindlabs/tailwindcss/pull/11002))
1414
- Honor default `to` position of gradient when using implicit transparent colors ([#11002](https://github.com/tailwindlabs/tailwindcss/pull/11002))
1515
- Ensure `@tailwindcss/oxide` doesn't leak in the stable engine ([#10988](https://github.com/tailwindlabs/tailwindcss/pull/10988))
16+
- Ensure multiple `theme(spacing[5])` calls with bracket notation in arbitrary properties work ([#11039](https://github.com/tailwindlabs/tailwindcss/pull/11039))
1617

1718
## [3.3.1] - 2023-03-30
1819

src/lib/defaultExtractor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function* buildRegExps(context) {
3535
// This is a targeted fix to continue to allow theme()
3636
// with square brackets to work in arbitrary properties
3737
// while fixing a problem with the regex matching too much
38-
/\[[^\s:'"`]+:[^\s]+?\[[^\s]+?\][^\s]+?\]/,
38+
/\[[^\s:'"`]+:[^\s]+?\[[^\s]+\][^\s]+?\]/,
3939

4040
// Utilities
4141
regex.pattern([

tests/default-extractor.test.js

+7
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ const htmlExamples = html`
4141
<div class="[--y:theme(colors.blue.500)]">
4242
<div class="w-[calc(100%-theme('spacing.1'))]">
4343
<div class='w-[calc(100%-theme("spacing.2"))]'>
44+
<div class='w-[calc(100%-theme("spacing[2]"))]'>
45+
<div class='w-[calc(100%-theme(spacing[2]))]'>
46+
<div class='[width:calc(theme(spacing[2])_+_theme(spacing[3])_+_theme(spacing[4]))]'>
4447
4548
<script>
4649
let classes01 = ["text-[10px]"]
@@ -146,6 +149,10 @@ const includes = [
146149
`[--y:theme(colors.blue.500)]`,
147150
`w-[calc(100%-theme('spacing.1'))]`,
148151
`w-[calc(100%-theme("spacing.2"))]`,
152+
`w-[calc(100%-theme("spacing.2"))]`,
153+
`w-[calc(100%-theme("spacing[2]"))]`,
154+
`w-[calc(100%-theme(spacing[2]))]`,
155+
`[width:calc(theme(spacing[2])_+_theme(spacing[3])_+_theme(spacing[4]))]`,
149156
`border-[color:var(--color,theme(colors.cyan.500))]`,
150157
`translate-x-[var(--scroll-offset)]`,
151158
`font-[arbitrary,'arbitrary_with_space']`,

0 commit comments

Comments
 (0)