Skip to content

Commit 04906c8

Browse files
authored
Use length data type for background-size instead of background-position (#13771)
* move `length` data type from `background-position` to `background-size` This way it's backwards compatible with v3. * sort data types * update changelog * make sure `length` is inferred later Otherwise `bg-[120px]` would be inferred as `length` instead of `position`. In v3 this maps to `position` instead of `length`. ```css .bg-\[120px\] { background-position: 120px; } ``` * add explicit test cases for `length` and `size` data types
1 parent 2fedbe0 commit 04906c8

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
### Fixed
11+
12+
- Use `length` data type for `background-size` instead of `background-position` ([#13771](https://github.com/tailwindlabs/tailwindcss/pull/13771))
1113

1214
## [4.0.0-alpha.15] - 2024-05-08
1315

packages/tailwindcss/src/utilities.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7710,7 +7710,9 @@ test('bg', () => {
77107710
'bg-[50%]',
77117711
'bg-[120px]',
77127712
'bg-[120px_120px]',
7713+
'bg-[length:120px_120px]',
77137714
'bg-[position:120px_120px]',
7715+
'bg-[size:120px_120px]',
77147716

77157717
// background-repeat
77167718
'bg-repeat',
@@ -7834,7 +7836,7 @@ test('bg', () => {
78347836
background-size: cover;
78357837
}
78367838
7837-
.bg-\\[size\\:120px_120px\\] {
7839+
.bg-\\[length\\:120px_120px\\], .bg-\\[size\\:120px_120px\\] {
78387840
background-size: 120px 120px;
78397841
}
78407842

packages/tailwindcss/src/utilities.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,21 +2502,21 @@ export function createUtilities(theme: Theme) {
25022502
inferDataType(value, [
25032503
'image',
25042504
'color',
2505-
'length',
25062505
'percentage',
25072506
'position',
25082507
'bg-size',
2508+
'length',
25092509
'url',
25102510
])
25112511

25122512
switch (type) {
2513-
case 'length':
25142513
case 'percentage':
25152514
case 'position': {
25162515
return [decl('background-position', value)]
25172516
}
2518-
case 'size':
2519-
case 'bg-size': {
2517+
case 'bg-size':
2518+
case 'length':
2519+
case 'size': {
25202520
return [decl('background-size', value)]
25212521
}
25222522
case 'image':

0 commit comments

Comments
 (0)