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
shellSystem: 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
defineModeland input synchronization, focusing on Firefox-specific behavior. - Assistant
Identifying the issue: when v-model and
@inputboth update the model in one tick, the final value can match the prop while the DOM is stale; we should force a localtrigger()so the input re-syncs. - Assistant
Cause
defineModelis implemented withuseModel. When a parent usesv-model, the child does not updatelocalValueinsideset(); it only emits and waits for props to sync.In the playground repro, both
v-modeland@inputassign the model on each keystroke (v-model writes the raw input,@inputforces'a'). The final emitted value is often unchanged (still'a'), so the parent may not re-render the child andv-model’sbeforeUpdatenever resets the DOM. Firefox was more likely to show the stale input in that situation.Fix
Extended the existing
#10279“force local update” logic inuseModelso that when end with an emitted value equal to the current , we still call and re-render so the input can be synced.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.