ISSUE DESCRIPTION defineModel on Firefox does not work as expected Vue version 3.5.17…
- User
ISSUE DESCRIPTION
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
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /core, current file: none) bash-$
- Assistant
I’ll first inspect the repository structure and current status, then locate the
defineModel/v-modelruntime paths and relevant browser/input tests. I’ll also decode the playground reproduction so the Firefox-specific sequence can be modeled locally. - Assistant
The worktree is clean and dependencies are installed. The reproduction hash begins with a zlib signature, so I’ll decode it directly and simultaneously search model directive/runtime code and existing tests for forced model-value synchronization behavior.
- Assistant
This minimal container lacks Python and ripgrep, so I’ll use Node’s built-in
zliband standardgrepinstead. - Assistant
The reproduction has two input listeners: the directive first writes the raw DOM value to the model, then the explicit handler replaces it with
"a"during the same native event. This points touseModel’s same-tick synchronization rather than macro compilation. I’ll inspectuseModel, its regression tests, andvModelTextupdate guards to identify where Firefox’s DOM timing exposes stale state. - Assistant
By inspection, two writes in one event should emit
"typed value"and then"a"; the existinguseModelguard deliberately allows the second write when it differs from the previous set value. The browser discrepancy is likely in event-listener ordering or scheduler deduplication, so I’ll compile the exact child template, inspect event invokers and scheduler/component update ordering, and check repository history/log messages for related fixes. - Assistant
The repository already contains prior same-tick
defineModelfixes, but not this reported case. I’ll inspect those patches to understand invariants, and determine the current branch/version. I’ll also use the package source compiler through the repo’s test runner rather than relying on absent build artifacts. - Assistant
The checkout is a later Vue tree (3.5.35), so the target fix may already exist in history under a less obvious message or may be a regression still pending. I’ll search all commits after 3.5.17 that touched
useModel,vModel, event dispatch, or component emit, and inspect tags to isolate candidate changes rather than guessing. - Assistant
Tags were omitted from this repository snapshot. I’ll locate the 3.5.17 release commit from package-version changes, then use that commit hash as the comparison base.
- Assistant
No post-3.5.17 commit addresses this reproduction, so I need reproduce it in an actual browser. I’ll check available browser binaries and browser automation dependencies. If Firefox is present, I’ll build a small temporary page against the local Vue build and capture emitted values, DOM values, and event order.
- Assistant
A likely browser-sensitive mechanism is listener registration order: the explicit
@inputlistener and the directive’s nativeinputlistener are installed through separate renderer paths. I’ll verify mount ordering and obtain exact compiler output via a temporary Vitest script (outside the repository test suites), then inspect whether Firefox and Chromium can legitimately differ due to listeners added while dispatching. - Assistant
The renderer guarantees the directive listener is registered first, so browser listener-order variance is not the cause. Next I’ll build the exact reproduction with runtime render functions (avoiding SFC tooling), run it in Chrome as a control, and attempt to install/use a headless Firefox package if available. Logging every setter/emit/render/DOM transition will reveal the state machine that a fix must preserve.
- Assistant
Firefox is not installed, but this Debian environment has
apt-get. I’ll install Firefox ESR so the reported browser behavior can be reproduced directly; this does not alter repository files. - Assistant
Firefox ESR is available. I’ll build the local Vue global bundle, create a temporary HTML reproduction matching the SFC semantics (
useModel, nativev-model, then explicit@input), and automate identical keystrokes in both Firefox and Chrome with Puppeteer. The page will record model update emissions and post-microtask DOM values. - Assistant
The
pnpmshim attempted an interactive Corepack download, which this environment disallows. I’ll invoke the repository build script directly with Node. - Assistant
The direct script expects
rolluponPATH; I’ll prepend the existing local binaries and rerun. - Assistant
The bundle is built. I’ll now run the cross-browser probe from
/tmpand keep all reproduction artifacts outside the worktree. - Assistant
The issue is now reproduced exactly:
- Chrome:
a,a,a - Firefox:
a,ay,ayz
Firefox does not run the queued Vue microtask between the directive’s native listener and the explicit listener. Therefore the first assignment queues a parent update away from
"a", the second assignment restores"a"before render, and the parent render sees no prop change. SinceuseModeldoes not locally trigger when the restored value equals its last prop, the child’s dirty DOM value is never patched.I’ll update
useModelto force a local render when consecutive controlled-model sets move away from and then back to the current prop value. This is the same class of synchronization guarantee as the existing transformed-setter fallback, but covers untransformed same-tick restoration. - Chrome:
- Assistant
I’ll make the fallback controlled-model-only, avoiding duplicate triggers for local/uncontrolled models. The condition will compare emitted values (the values the parent actually sees), so it also remains correct when a
defineModelsetter transforms raw assignments. - Assistant
The two line-range edits overlapped after the first changed line counts, leaving a malformed duplicate and removing the initial guard. I caught this in review. I’ll replace the entire setter atomically with the intended complete implementation before running anything.
- Assistant
One extra closing line from the prior malformed block remains immediately after the setter. I’ll remove it and run TypeScript formatting/checks before rebuilding.
- Assistant
The source now parses, passes formatting, lint, and whitespace checks. I’ll run the focused
useModelunit suite first, then rebuild and rerun the real Chrome/Firefox reproduction to confirm behavior rather than relying only on unit-level reasoning. - Assistant
The focused suite passes all 14 tests. I’ll rebuild the modified bundle and rerun the same browser automation.
- Assistant
The exact Firefox reproduction is fixed (
a,a,a) and Chrome remains unchanged. I’ll now run the broader runtime-core and runtime-dom model suites plus the TypeScript check. This covers controlled/uncontrolled models, transformed setters, directive synchronization, and compilation/runtime type safety. - Assistant
The broader suites pass: 45 files and 1,047 tests. I’ll run the repository TypeScript check, then inspect the final diff/status to ensure no generated build output or temporary artifacts will be submitted.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-lunaCompare side by side →
- gpt-5.6-lunaCompare side by side →
- gpt-5.6-lunaCompare side by side →
deepseek/deepseek-v4-proCompare side by side →
deepseek/deepseek-v4-proCompare side by side →