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
Let me start by understanding the issue. It's about
defineModelon Firefox not working as expected. There's a reproduction link to the Vue playground, which I can't access directly. Let me explore the repository structure to understand the codebase and then find the relevant code related todefineModel.Let me first explore the repository structure.
Assistant
This is the Vue core repository. Let me explore the packages directory to understand the structure.
Assistant
Now let me look at the
compiler-sfcpackage wheredefineModelis likely implemented, and also search fordefineModelacross the codebaseAssistant
Let me look at the key files related to
defineModel:Assistant
The
opencommand doesn't seem to work. Let me try with a different approach.Assistant
Let me look at the compiler-sfc side of `defineModel
Assistant
The runtime implementation is
useModel. Let me find that.Assistant
Let me look at the
useModelruntime implementationAssistant
Let me look at recent changes to the useModel implementation and any related Firefox fixes
Assistant
Let me search for related commits and issues
Assistant
Let me decode the playground URL to understand the exact reproduction code
Assistant
Let me look at the
hasChangedutility functionAssistant
Let me see the hasChanged function.
Assistant
Let me look at the
useModeltests to understand the expected behavior betterAssistant
Let me check the
watchSyncEffectimplementationAssistant
Let me look at the watchSyncEffect
Assistant
Let me look at the
doWatchfunction, focusing on the sync flushAssistant
Let me look at the doWatch function
Assistant
Let me look at the v-model runtime-dom implementation
Assistant
Let me look at vModel.ts.
Assistant
Let me try to decode the playground URL properly
Assistant
Let me install lz-string and decode the playground
Assistant
Now let me decode it.
Assistant
Let me try the other LZString method
Assistant
Now I have a good understanding of the issue. Let me create a reproduction test first to confirm the bug
Assistant
Let me now implement the fix in useModel.ts
Assistant
Let me go back to the repo root
Assistant
Now I understand the issue. Let me implement the fix. There are two problems in the
useModelsetter:-
Early return on first call: When
prevSetValueisEMPTY_OBJ(first call) and the setter transforms the value to the same aslocalValue, the early return incorrectly fires becauseprevSetValue !== EMPTY_OBJis false. -
Force-update condition: Even if we fix #1, the force-update check
!hasChanged(emittedValue, prevEmittedValue)fails on the first call becauseprevEmittedValueisundefined.
Let me apply the fix:
-
Assistant
Let me use the replace command with proper
Assistant
Now fix the force-update condition to handle the first call (where
prevEmittedValueisundefined):Assistant
Let me verify the full setter function looks correct
Assistant
Now let me run the existing tests for useModel to make sure nothing is broken
Assistant
All 14 tests pass. Let me also run the defineModel tests from compiler-sfc
Assistant
Both test suites pass. Now let me write a quick reproduction script to verify the fix works for the specific Firefox issue
Assistant
Let me also run the broader runtime-core tests related to components and v-model
Assistant
Let me also run any vModel-related tests
Assistant
Let me also run the full compileScript tests
Assistant
All tests pass. Let me now review the final state of the file
Assistant
The fix looks correct. Let me verify the edge cases one more time by analyzing the logic:
Fix 1: Added
!hasChanged(value, emittedValue)to the early return condition.- This prevents early return when the setter transforms the input value to a different emitted value, even on the first call (when
prevSetValueisEMPTY_OBJ).
Fix 2: Changed
!hasChanged(emittedValue, prevEmittedValue)to uselocalValueas fallback whenprevEmittedValueisundefined.- On the first call,
prevEmittedValueisundefined, so we compare againstlocalValueinstead. This ensures the force-update triggers when the emitted value equals the current local value (meaning parent won't detect a change, but the input is out of sync).
Let me run the full test suite one more time to be sure:
- This prevents early return when the setter transforms the input value to a different emitted value, even on the first call (when
Assistant
All 26 tests pass. Let me verify the change one final
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-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 →