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
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
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 using command. Additionally, you can use and to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call ) using or commands. However you don't need to use or before submitting your changes. In fact, only submits currently unstaged changes because it uses to get the changes that need to be submitted. Assistant
Let me understand the issue. The problem is with
defineModelon Firefox not working as expected. This is a Vue.js core repository (version 3.5.17 mentioned). I need to:- First, explore the repository structure
- Find the relevant code for
defineModel - Understand the issue from the reproduction link
- Fix the issue
Let me start by exploring the repository structure.
Assistant
Let me explore the packages directory to find the relevant code for
defineModel.Assistant
Let me search for
defineModelin the codebase.Assistant
Let me look at the runtime-core implementation of
useModelsince that's whatdefineModelcompiles to.Assistant
Let me look at the
useModelimplementation to understand how it works.Assistant
Let me use cat or open with the file path differently.
Assistant
Let me check the git log for any recent changes related to
useModelordefineModel.Assistant
Let me look at the v-model implementation in runtime-dom.
Assistant
Let me look at the vModel directive implementation.
Assistant
Let me search for any recent commits related to Firefox or input event handling.
Assistant
Let me look for the fix for #10279 and any related PRs.
Assistant
Let me look at this commit in detail.
Assistant
Let me look at the full diff for this commit.
Assistant
Let me check the current version of the repository.
Assistant
Let me search for more recent changes related to useModel or defineModel.
Assistant
Let me look at the
b5cad0e91commit anda18f1ecf0commit.Assistant
Let me look at the
a18f1ecf0commit:Assistant
Let me try to decode the playground URL to understand the reproduction code
Assistant
Let me try to decode the playground URL hash using a script
Assistant
Let me decode the playground hash using zlib decompression
Assistant
Let me try with pako
Assistant
Let me try different decompression approaches
Assistant
Let me search for the commit that changed the early return condition from
valuetoemittedValue.Assistant
Let me look at the
f1bb0aef0commit and thee0428884bcommit.Assistant
Let me look at the
e0428884bcommit:Assistant
Let me search for any recent issues/commits related to Firefox input handling.
Assistant
Let me look at the recent commits about vModel input handling.
Assistant
Let me look at the useModel tests to understand the testing patterns.
Assistant
Let me check how Vue playground encodes its URLs
Assistant
Let me check the sfc-playground package.json
Assistant
Let me install pako and try to decode the playground URL
Assistant
Let me install pako
Assistant
Let me use pnpm to install pako
Assistant
Let me look at the
hasChangedimplementation to understand its behavior.Assistant
Let me look at the
hasChangedimplementation.Assistant
Let me check if there are any recent changes to vModel or useModel that might have introduced the Firefox bug.
Assistant
Let me look at the b1be9bd64 commit about preventing unnecessary DOM update from v-model.
Assistant
Let me write a reproduction script to test the useModel behavior.
Assistant
Let me run the existing useModel tests first to make sure they pass.
Assistant
Let me look at the defineModel implementation in apiSetupHelpers.ts.
Assistant
Let me look at how defineModel is compiled in the SFC compiler.
Assistant
Let me check if there are any recent changes in the changelog related to this issue.
Assistant
Let me look at the changelogs directory.
Assistant
Let me search for any references to this specific issue in commit messages.
Assistant
Let me look at the
watchSyncEffectimplementation.Assistant
Let me look at the watchSyncEffect implementation.
Assistant
Let me look at how the playground encoding works by examining the vue/repl package
Assistant
Let me look at the core chunk for the encoding logic.
Assistant
Let me look at the encoding logic in the core chunk
Assistant
Let me look at the actual URL encoding function in the Vue REPL
Assistant
Let me search for the serialization logic in the Vue REPL
Assistant
Let me look at the issue from a practical standpoint. Let me run the tests to ensure they pass, then look more carefully at the specific edge case in the
useModelsetter.Assistant
Now I have a good understanding of the issue. Let me look at the
useModel.tscode one more time to confirm my fix.Assistant
Let me use open with the full path.
Assistant
Now I've identified two potential issues in the
useModelsetter:-
Early return bug (lines 61-66): On the first call (
prevSetValue === EMPTY_OBJ), ifemittedValue == localValue, it returns early even when the raw input value has changed. This prevents the setter from emitting and the input from being corrected. -
Local mode uses raw value (line 81): In local mode (no parent v-model),
localValue = valueuses the raw input value instead of the setter-transformedemittedValue.
Let me implement the fixes.
First, let me fix the early return condition and the local mode value:
-
Assistant
Now let me fix the local mode to use
emittedValueinstead of the rawvalueAssistant
Now let me run the tests to verify my changes don't break anything
Assistant
I see the issue with my fix. On the first call, we should still return early if the value equals localValue (no real change). Let me adjust the condition
Assistant
Let me run the tests again
Assistant
All useModel tests pass. Let me also run the vModel tests and any other related tests.
Assistant
Let me run a broader set of tests to make sure nothing is broken.
Assistant
All tests pass. Let me also run the defineModel compile tests.
Assistant
All tests pass. Let me review the final state of the changes.
Assistant
Let me verify the final file looks correct.
Assistant
Let me run a broader set of tests to verify nothing else is broken
Assistant
All 101 tests pass. My changes fix two issues in
useModel.ts:-
Early return condition (line 61-67): The previous condition
!(prevSetValue !== EMPTY_OBJ && hasChanged(value, prevSetValue))would return early on the first call whenemittedValue == localValue, even if the raw input value was different. This meant that if a setter always returned the same value (e.g., always "a"), and the parent's initial prop already matched that value, the first user input would be silently dropped. The fix now compares the raw value againstlocalValueon the first call (whenprevSetValueis still theEMPTY_OBJsentinel), and againstprevSetValueon subsequent calls. -
Local mode value (line 84): When there's no parent v-model (local mode), the code was setting
localValue = value(raw input value), ignoring the setter's transformation. The fix usesemittedValueso the local state correctly reflects the transformed value.
Let me verify one more time that the file looks correct:
-
Assistant
The changes are clean and correct. Let me run the full test suite one more time to be absolutely sure:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.