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
Interface
No new interfaces are introduced.
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 locate
defineModel/model directive implementations and their tests. Then I’ll decode the reproduction if needed, identify the Firefox-specific DOM synchronization path, implement the smallest general fix, and run the focused and broader relevant tests. - Assistant
The issue likely involves the runtime
useModelsetter rather than macro compilation. I’ll decode the provided playground state to recover the exact component code, then inspectuseModeland nativev-modelevent handling against that interaction. - Assistant
Python is unavailable, so I’ll use Node’s built-in
zlibto decode the playground payload. I’ll also inspect the focuseduseModeltests and recent repository history around its forced-trigger logic, which already appears directly relevant to transformed setter values. - Assistant
The reproduction has two handlers for the same native
inputevent: the directive first writes the raw DOM value throughdefineModel, then the explicit handler immediately overwrites it with"a". Both parent updates are batched into one child render. I’ll inspect existing same-tick model tests and the commits that shaped this deduplication behavior, plus runtime DOM tests for multiple input listeners, to determine whether the missing update is in model triggering or directive DOM patching. - Assistant
The failure is a same-tick “round trip”: once the model is already
"a", typing makes the DOM and model temporarily"ab", then the explicit handler restores the model to"a". The parent render is queued, but by flush time its value equals the previous vnode prop, so Vue correctly skips the child prop patch—while the browser DOM remains"ab".useModelalready avoids suppressing the second emit, but it does not force the child render in this non-transformer case. I’ll extend its existing forced-update condition specifically for a same-tick set that returns to the current prop value. - Assistant
The edit accidentally replaced the existing
prevSetValue = valueassignment at the end of the setter. That state is essential both to the original behavior and the new branch, so I’ll restore it before testing. - Assistant
The setter state is restored and the change is syntactically clean. I’ll now run the complete focused
useModelsuite. After that, I’ll create a temporary runtime-test script (not a repository test) that exactly simulates the reproduction’s sequence—model starts at"a", native input writes"ab", and the second handler resets it to"a"in the same tick—and assert that the child rerenders to resynchronize the input. - Assistant
The
pnpmlauncher is an unavailable Corepack shim that attempted an interactive network download, so I’ll bypass it and invoke the already-installed local Vitest binary directly. Also, Vitest 4 does not use Jest’s--runInBand, so I’ll omit that flag. - Assistant
The existing focused suite passes. For an exact regression check, the temporary script will include a vnode before-update hook, mirroring how
vModelText.beforeUpdaterepairs the actual element even when the virtualvalueprop itself compares equal. This distinction is important: the fix must force the child update so the directive hook runs. I’ll run it through the repository’s configured Vite/Vitest transform and then delete it immediately. - Assistant
vite-nodeis not installed as a standalone binary, and the temporary file was still removed cleanly. I’ll instead bundle the same temporary executable with the installed esbuild, using the repository’s package aliases fromtsconfig.json, run the generated file from/tmp, and remove the source afterward. This remains a one-off reproduction script, not a test addition. - Assistant
The alias mapping is straightforward, but bundling Vue runtime sources directly would also require defining all compile-time feature flags. Vitest already supplies those correctly. I’ll therefore run the temporary executable as a root-level temporary spec solely to obtain its transform environment, without modifying any existing test or retaining the temporary file.
- Assistant
The exact same-tick reproduction now passes: the parent remains
"a", the simulated input is repaired to"a", and the child renders exactly once more. The temporary file is removed. I’ll now run both the fulluseModeland runtime DOMv-modeldirective suites together, lint the changed source, and run the repository type check if the available local tooling supports it. - Assistant
The chained command exited successfully, including lint and TypeScript, but only the runtime-core test file was selected because runtime DOM tests belong to a separate Vitest project. I’ll inspect the project names and run the directive suite under its correct project. I’ll also review the final diff and repository status for accidental artifacts (including TypeScript build-info files).
- Assistant
The generated TypeScript build info is under the repository’s existing ignored
temp/directory and is not part of the diff. Runtime DOM uses theunit-jsdomproject, so I’ll run its complete directive test file there. Since this behavior crosses runtime-core scheduling and DOM directives, I’ll also run all unit-jsdom tests if the focused suite passes quickly. - Assistant
Final verification is complete:
- Reported error reproduced: I decoded the supplied playground and reproduced its exact same-event sequence in a temporary runtime test: the DOM/model changed from
"a"to"ab"and was reset to"a"before the scheduler flushed. This exposed the missing child update path; the temporary file was removed afterward. A real Firefox binary was not available, but the framework-level race that causes the Firefox-visible stale DOM was reproduced directly. - Fix confirmed: The same temporary reproduction now confirms the parent remains
"a", the input is resynchronized to"a", and one forced child render occurs so the nativev-modeldirective update hook can run. - Edge cases considered: The new trigger is restricted to successive same-tick assignments where the emitted value returns to the current prop and the raw set value differs from the prior set. Existing transformed-setter handling remains intact, unchanged assignments still return early, and scheduler deduplication prevents redundant rendering.
- Relevant existing tests pass:
useModel(14/14), focused runtime DOMv-model(28/28), and the fullunit-jsdomproject (378 passed, 1 skipped) all pass. ESLint, TypeScript no-emit checking, andgit diff --checkalso pass.
Only
packages/runtime-core/src/helpers/useModel.tsis changed, with no test or temporary artifacts included. I’ll submit the fix now. - Reported error reproduced: I decoded the supplied playground and reproduced its exact same-event sequence in a temporary runtime test: the DOM/model changed from
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
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →
Qwen/Qwen3.5-35B-A3BCompare side by side →