Skip to content

Commit 0c97a5b

Browse files
Bring back some deprecated utilities (#15069)
These utilities are deprecated (and were removed) but we're brining them back so they keep working: - `flex-grow-*` - `flex-shrink-*` - `decoration-slice` - `decoration-clone` - `overflow-ellipsis`
1 parent 6c85327 commit 0c97a5b

File tree

3 files changed

+126
-0
lines changed

3 files changed

+126
-0
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
### Fixed
1515

1616
- Ensure `opacity` theme values configured as decimal numbers via JS config files work with color utilities ([#15067](https://github.com/tailwindlabs/tailwindcss/pull/15067))
17+
- Bring back support for `decoration-clone`, `decoration-slice`, `overflow-ellipsis`, `flex-grow-*`, and `flex-shrink-*` ([#15069](https://github.com/tailwindlabs/tailwindcss/pull/15069))
1718
- _Upgrade (experimental)_: Include `color` in the form reset snippet ([#15064](https://github.com/tailwindlabs/tailwindcss/pull/15064))
1819

1920
## [4.0.0-alpha.36] - 2024-11-21

Diff for: packages/tailwindcss/src/compat/legacy-utilities.test.ts

+80
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,83 @@ test('max-w-screen', async () => {
131131
]),
132132
).toEqual('')
133133
})
134+
135+
test('box-decoration', async () => {
136+
expect(await run(['decoration-slice', 'decoration-clone'])).toMatchInlineSnapshot(`
137+
".decoration-clone {
138+
-webkit-box-decoration-break: clone;
139+
box-decoration-break: clone;
140+
}
141+
142+
.decoration-slice {
143+
-webkit-box-decoration-break: slice;
144+
box-decoration-break: slice;
145+
}"
146+
`)
147+
})
148+
149+
test('overflow-ellipsis', async () => {
150+
expect(await run(['overflow-ellipsis'])).toMatchInlineSnapshot(`
151+
".overflow-ellipsis {
152+
text-overflow: ellipsis;
153+
}"
154+
`)
155+
})
156+
157+
test('flex-grow', async () => {
158+
expect(await run(['flex-grow', 'flex-grow-0', 'flex-grow-[123]'])).toMatchInlineSnapshot(`
159+
".flex-grow {
160+
flex-grow: 1;
161+
}
162+
163+
.flex-grow-0 {
164+
flex-grow: 0;
165+
}
166+
167+
.flex-grow-\\[123\\] {
168+
flex-grow: 123;
169+
}"
170+
`)
171+
expect(
172+
await run([
173+
'-flex-grow',
174+
'flex-grow--1',
175+
'flex-grow-1.5',
176+
'-flex-grow-0',
177+
'-flex-grow-[123]',
178+
'flex-grow-unknown',
179+
'flex-grow/foo',
180+
'flex-grow-0/foo',
181+
'flex-grow-[123]/foo',
182+
]),
183+
).toEqual('')
184+
})
185+
186+
test('flex-shrink', async () => {
187+
expect(await run(['flex-shrink', 'flex-shrink-0', 'flex-shrink-[123]'])).toMatchInlineSnapshot(`
188+
".flex-shrink {
189+
flex-shrink: 1;
190+
}
191+
192+
.flex-shrink-0 {
193+
flex-shrink: 0;
194+
}
195+
196+
.flex-shrink-\\[123\\] {
197+
flex-shrink: 123;
198+
}"
199+
`)
200+
expect(
201+
await run([
202+
'-flex-shrink',
203+
'flex-shrink--1',
204+
'flex-shrink-1.5',
205+
'-flex-shrink-0',
206+
'-flex-shrink-[123]',
207+
'flex-shrink-unknown',
208+
'flex-shrink/foo',
209+
'flex-shrink-0/foo',
210+
'flex-shrink-[123]/foo',
211+
]),
212+
).toEqual('')
213+
})

Diff for: packages/tailwindcss/src/compat/legacy-utilities.ts

+45
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { decl } from '../ast'
22
import type { DesignSystem } from '../design-system'
3+
import { isPositiveInteger } from '../utils/infer-data-type'
34

45
export function registerLegacyUtilities(designSystem: DesignSystem) {
56
for (let [value, direction] of [
@@ -25,4 +26,48 @@ export function registerLegacyUtilities(designSystem: DesignSystem) {
2526
if (!value) return
2627
return [decl('max-width', value)]
2728
})
29+
30+
designSystem.utilities.static(`overflow-ellipsis`, () => [decl('text-overflow', `ellipsis`)])
31+
32+
designSystem.utilities.static(`decoration-slice`, () => [
33+
decl('-webkit-box-decoration-break', `slice`),
34+
decl('box-decoration-break', `slice`),
35+
])
36+
37+
designSystem.utilities.static(`decoration-clone`, () => [
38+
decl('-webkit-box-decoration-break', `clone`),
39+
decl('box-decoration-break', `clone`),
40+
])
41+
42+
designSystem.utilities.functional('flex-shrink', (candidate) => {
43+
if (candidate.modifier) return
44+
45+
if (!candidate.value) {
46+
return [decl('flex-shrink', '1')]
47+
}
48+
49+
if (candidate.value.kind === 'arbitrary') {
50+
return [decl('flex-shrink', candidate.value.value)]
51+
}
52+
53+
if (isPositiveInteger(candidate.value.value)) {
54+
return [decl('flex-shrink', candidate.value.value)]
55+
}
56+
})
57+
58+
designSystem.utilities.functional('flex-grow', (candidate) => {
59+
if (candidate.modifier) return
60+
61+
if (!candidate.value) {
62+
return [decl('flex-grow', '1')]
63+
}
64+
65+
if (candidate.value.kind === 'arbitrary') {
66+
return [decl('flex-grow', candidate.value.value)]
67+
}
68+
69+
if (isPositiveInteger(candidate.value.value)) {
70+
return [decl('flex-grow', candidate.value.value)]
71+
}
72+
})
2873
}

0 commit comments

Comments
 (0)