defineModel on Firefox does not work as expected Vue version 3.5.17 Link to minimal…
- User
defineModel on Firefox does not work as expected
Vue version
3.5.17
Link to minimal reproduction
Steps to reproduce
- Use firefox
- Enter anything in the field. It should be blocked and only show "a", but it wont on firefox.
What is expected?
It should only keep "a" and nothing else should "make it through"
What is actually happening?
Seems like either a race condition or firefox not updating at the same time as Chrome? no clue.
System Info
System: OS: Windows 11 10.0.26100 CPU: (20) x64 Intel(R) Core(TM) i5-14600K Memory: 12.60 GB / 31.77 GB Binaries: Node: 22.16.0 - C:\nvm4w\nodejs\node.EXE npm: 10.9.2 - C:\nvm4w\nodejs\npm.CMD Browsers: Edge: Chromium (134.0.3124.85) Internet Explorer: 11.0.26100.1882 -- Its not showing my actual browser: Firefox 139.0.4Any additional comments?
No response
Interface
No new interfaces are introduced.
- Assistant
Investigating how
defineModelhandles input updates and why Firefox behaves differently from Chrome. - Assistant
Identifying the issue: when a parent prop doesn't change, the child may not re-render to sync the DOM. Ensuring v-model runs before user
@inputhandlers (capture phase) and fixinguseModelearly-return when a setter transforms the value. - Assistant
The Firefox bug came from event order on
<input v-model="model" @input="onInput" />withdefineModel.What went wrong
On
input, Vue’s v-model listener and your@inputhandler both run. They must run in this order:- v-model reads
el.valueand updates the model @inputcan correct the model (your repro forces'a')
Listeners were both on the bubble phase, registered in mount order (v-model in the directive
createdhook, then@inputfrom props). That order is not reliable everywhere; when@inputran after v-model on Chrome but before on Firefox, the final model could stay as the raw typed string (e.g.'ab') instead of'a', so the field showed extra characters.defineModel’s had a related edge case: if a normalized the value to the same prop the parent already had (e.g. always ), an early return could skip work when the raw input still differed, so the DOM might not resync. - v-model reads
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.