Skip to content

Commit 17c7c7e

Browse files
fix(upgrade): prevent nextjs image blur property from modified (#16405)
Fix #16404 --------- Co-authored-by: Philipp Spiess <[email protected]>
1 parent f678a70 commit 17c7c7e

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818

1919
- Revert change to no longer include theme variables that aren't used in compiled CSS ([#16403](https://github.com/tailwindlabs/tailwindcss/pull/16403))
2020

21+
### Fixed
22+
23+
- Upgrade: Don't migrate `blur` to `blur-sm` when used with Next.js `<Image placeholder="blur" />` ([#16405](https://github.com/tailwindlabs/tailwindcss/pull/16405))
24+
2125
## [4.0.5] - 2025-02-08
2226

2327
### Added

packages/@tailwindcss-upgrade/src/template/codemods/legacy-classes.test.ts

+5
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,9 @@ test('does not replace classes in invalid positions', async () => {
6868
await shouldNotReplace(`<div v-show="shadow"></div>\n`)
6969
await shouldNotReplace(`<div x-if="shadow"></div>\n`)
7070
await shouldNotReplace(`<div style={{filter: 'drop-shadow(30px 10px 4px #4444dd)'}}/>\n`)
71+
72+
// Next.js Image placeholder cases
73+
await shouldNotReplace(`<Image placeholder="blur" src="/image.jpg" />`, 'blur')
74+
await shouldNotReplace(`<Image placeholder={'blur'} src="/image.jpg" />`, 'blur')
75+
await shouldNotReplace(`<Image placeholder={blur} src="/image.jpg" />`, 'blur')
7176
})

packages/@tailwindcss-upgrade/src/template/is-safe-migration.ts

+6
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const CONDITIONAL_TEMPLATE_SYNTAX = [
1010
/x-if=['"]$/,
1111
/x-show=['"]$/,
1212
]
13+
const NEXT_PLACEHOLDER_PROP = /placeholder=\{?['"]$/
1314

1415
export function isSafeMigration(location: { contents: string; start: number; end: number }) {
1516
let currentLineBeforeCandidate = ''
@@ -63,5 +64,10 @@ export function isSafeMigration(location: { contents: string; start: number; end
6364
}
6465
}
6566

67+
// Heuristic: Disallow Next.js Image `placeholder` prop
68+
if (NEXT_PLACEHOLDER_PROP.test(currentLineBeforeCandidate)) {
69+
return false
70+
}
71+
6672
return true
6773
}

0 commit comments

Comments
 (0)