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
Let me decode the playground reproduction to understand the exact scenario:
- Assistant
Baseline passes. Let me write a temporary repro test that simulates the Firefox flow (both handlers run before any flush):
- Assistant
Just a serialization format issue (string values are quoted). Fixing the assertions:
- Assistant
The fix resolves the repro and all existing
useModeltests pass. Now let me run the broader related test suites to check for regressions: - Assistant
All 1251 tests pass. Let me clean up the issue-number reference in the comment (I don't have a confirmed number) and move the repro into the official spec file as a proper regression test:
- Assistant
The failures are all Puppeteer-based e2e tests. Let me confirm they fail for environmental reasons (missing browser), not because of my change:
- Assistant
Confirmed — the e2e failures are environmental (Chromium can't launch as root in this sandbox), unrelated to my change. All 1398 unit tests pass. Let me verify with the non-e2e vue tests and run a type check:
- Assistant
Typecheck passes. Final verification of the diff:
- Assistant
Done. The fix is complete and verified.
Summary
Root cause: With
<input v-model="model" @input="onInput" />whereonInputresets the model (model.value = 'a'), two listeners fire on eachinputevent: first the v-model assigner (emits the raw typed value), then the user's@inputhandler (emits'a').- In Chrome, Vue's scheduler flushes in the microtask checkpoint between the two listeners, so by the time
onInputruns, the prop has synced to the raw value — the reset to'a'is seen as a change, triggering a prop sync that resets the DOM input.
- In Chrome, Vue's scheduler flushes in the microtask checkpoint between the two listeners, so by the time
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.