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 statusor 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 start by understanding the issue. The problem is about
defineModelnot working correctly on Firefox. This is a Vue.js core repository (version 3.5.17). The issue is thatdefineModelon Firefox doesn't work as expected - it seems like there's a race condition or Firefox not updating at the same time as Chrome.Let me first explore the repository structure and understand what
defineModeldoes and where it's implemented.The reproduction link shows a minimal reproduction. Let me look at the source code to understand the issue better.
Let me start by exploring the repository structure.
Assistant
Let me explore the packages directory to find where
defineModelis implemented.Assistant
Let me search for
defineModelin the codebase to find where it's implemented.Assistant
Let me look at the key files related to this issue. The problem is likely in how
v-modelhandles input events in Firefox. Let me look at the runtime-dom v-model implementation and the directive implementationAssistant
Let me try again with a single command.
Assistant
Let me look at the vModel directive implementation:
Assistant
Let me look at the
defineModelcompiler transform to understand how it generates theAssistant
Let me look at
useModelin runtime-core sincedefineModelis compiled touseModel:Assistant
hmm, let me search more broadly for
useModel:Assistant
Let me look at the
useModelruntime implementationAssistant
Let me check the git history for recent changes to these files, particularly about Firefox or compositionend
Assistant
Let me look at the commit that introduced the activeElement check
Assistant
Let me see the diff of this commit to understand what was changed:
Assistant
Let me look at the emit function and also examine the vModel tests for Firefox-related
Assistant
Let me search for references to issue numbers and Firefox-related fixes
Assistant
Let me look at the git blame for the
beforeUpdatesection of vModel.tsAssistant
Let me check the current version of the repository:
Assistant
Let me look at the version in package.json:
Assistant
Let me look at the commit that introduced the activeElement check:
Assistant
Let me look at the useModel tests to understand the expected behavior:
Assistant
Let me try to create a reproduction script to test the behavior. First, let me look at the vModel tests to understand how they simulate input events
Assistant
Let me look at the triggerEvent helper:
Assistant
Let me search for any Firefox-specific comments or issues in the code:
Assistant
Let me try to decode the playground hash to understand the reproduction:
Assistant
Let me try with node to decode the hash
Assistant
Let me look at the commit for issue #10279
Assistant
Let me look at the full diff of
de174e1aa:Assistant
Let me look at the commit that changed to
hasChangedAssistant
Let me look at the
hasChangedfunction:Assistant
Let me see the
hasChangedandEMPTY_OBJimplementationsAssistant
Let me try to decode using lz-string which Vue playground uses
Assistant
The first bytes
78daindicate zlib compression. Let me try to decompress properly:Assistant
Let me look at commits between 3.5.17 and the current version that relate to
useModelorvModelAssistant
Let me look at commit
b39e0329fwhich seems related to model handlingAssistant
Let me look at the @vue/repl package to understand the hash encoding
Assistant
Let me search for the serialization logic:
Assistant
Let me search for the decode function in the REPL utils
Assistant
Let me try using fflate to decode (common in Vue ecosystem):
Assistant
Let me search for the encode/decode logic in the REPL chunks:
Assistant
Let me look at the REPL core.js for the encoding logic
Assistant
Let me look at the changelogs for recent versions around 3.5.17
Assistant
Let me check if there's an lz-string in node_modules
Assistant
Let me look at the encoding utilities in the REPL package:
Assistant
Let me search for the serialization logic in the REPL core:
Assistant
Let me search the utils file for serialize/deserialize functions
Assistant
Let me look at the compression/decompression functions in the utils file:
Assistant
Let me try to decode the hash using the correct base64url conversion and zlib:
Assistant
Let me search for any Firefox-specific issues in the git log
Assistant
Let me look at recent changes that might be related to this issue. Let me check all commits that touch useModel or vModel between the version reported and now
Assistant
Let me look at the commit
e0428884bwhich seems very relevant to this issue:Assistant
Now I have a good understanding of the issue. Let me look at the current
useModel.tscode one more time before making changesAssistant
Let me look at how the compiler sets up the v-model handler for native inputs
Assistant
Let me look at the vModel transform in compiler-core
Assistant
Now I have a clear understanding of the bug. The issue is in
useModel.tsin thesetfunction. Let me implement the fix.The problem has two parts:
-
Early return too aggressive: When the setter returns the same value as
localValue, the function returns early without emitting or triggering a re-render. But if the raw input value differs fromlocalValue, we need to proceed to reset the input. -
Force local update doesn't handle first call: The force local update logic requires
prevEmittedValue === emittedValue, but on the first callprevEmittedValueisundefined, so the trigger is never called.
Let me fix both issues
-
Assistant
Now let me make the changes. First, I'll fix the early return condition
Assistant
Let me try the edit command with the correct syntax:
Assistant
Let me open the file first
Assistant
Now let me make the first edit - fix the early return condition:
Assistant
I see there are duplicate lines. Let me fix that - remove lines 68-69 and fix the closing brace
Assistant
There's still an extra closing brace on line 68. Let me fix that
Assistant
Good, the first fix is in place. Now let me fix the force local update condition. I need to add handling for the case where
emittedValue === localValuebutvalue !== localValue:Assistant
Let me verify the complete file looks correct:
Assistant
Now let me run the existing tests to make sure the changes don't break anything:
Assistant
All useModel tests pass. Let me also run the vModel tests:
Assistant
Let me also run the compiler-sfc defineModel tests:
Assistant
Let me verify my understanding by checking the vModelText.beforeUpdate code once more
Assistant
Let me run a broader set of tests to make sure nothing is broken:
Assistant
Let me also run some broader tests that might be affected
Assistant
Let me verify the diff of my changes:
Assistant
Now let me summarize my changes and verify everything is in order.
Let me review the final state of the file one
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.