Add heuristic to skip candidate migrations inside emit(…) (#18330)

Fixes #18318
This commit is contained in:
Jordan Pittman 2025-06-17 12:49:33 -04:00 committed by GitHub
parent 44534963c3
commit 5fc6698b7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 1 deletions

View File

@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
- Nothing yet!
- Add heuristic to skip candidate migrations inside `emit(…)` ([#18330](https://github.com/tailwindlabs/tailwindcss/pull/18330))
## [4.1.10] - 2025-06-11

View File

@ -61,4 +61,8 @@ test('does not replace classes in invalid positions', async () => {
// Alpine/Livewire wire:…
await shouldNotReplace('<x-input.number required="foo" wire:model.blur="coins" />', 'blur')
// Vue 3 events
await shouldNotReplace(`emit('blur', props.modelValue)\n`, 'blur')
await shouldNotReplace(`$emit('blur', props.modelValue)\n`, 'blur')
})

View File

@ -18,6 +18,7 @@ const CONDITIONAL_TEMPLATE_SYNTAX = [
/wire:[^\s]*?$/,
]
const NEXT_PLACEHOLDER_PROP = /placeholder=\{?['"]$/
const VUE_3_EMIT = /\b\$?emit\(['"]$/
export function isSafeMigration(
rawCandidate: string,
@ -175,6 +176,11 @@ export function isSafeMigration(
return false
}
// Heuristic: Disallow replacements inside `emit('…', …)`
if (VUE_3_EMIT.test(currentLineBeforeCandidate)) {
return false
}
return true
}