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
Now let me look at how vModelText interacts, and write a repro test:
- Assistant
Let me write a temporary repro test to confirm the behavior in jsdom:
- Assistant
Repro passes. Now run the existing test suites to check for regressions:
- Assistant
All 62 pass. Now add a regression test to the useModel spec, modeled on the existing #10279 test:
- Assistant
Just a serialization detail for the empty string:
- Assistant
Now verify the new test actually fails without the fix (temporarily reverting):
- Assistant
All pass. Clean up the temp repro and run the broader runtime-core + runtime-dom suites plus type check:
- Assistant
The fix is complete. Summary:
Root cause
In the repro, an
<input>has bothv-model="model"(adefineModelref) and a custom@inputhandler that overrides the model to a constant. On each keystroke two sets happen in the same tick:vModelText's listener runs first:model.value = el.value(e.g."ab") → emits"ab", parent value becomes"ab".- The user's
@inputhandler runs:model.value = "a"→ emits"a", parent value reverts to"a".
The parent prop ends up net-unchanged (
"a"→"a"), so no prop sync flows back down, the child never re-renders, and the DOM keeps the raw typed value (). The existing force-trigger in 's setter only handles the case where a option transformed the value (), which doesn't apply here since the final set is → . (The bug is browser-independent at the core level — it reproduces in jsdom; timing just made it more visible on Firefox.)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.