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 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
I’ll first inspect the repository structure and current branch state, then decode the playground reproduction and trace the relevant
defineModel/v-modelupdate path before making a targeted fix. - Assistant
The checkout is clean and is Vue core at 3.5.35, so the reported 3.5.17 behavior may still be present. I’ll locate the playground serialization code and decode the supplied hash to recover the exact component code rather than infer it from the description.
- Assistant
The hash prefix (
eNq) indicates zlib-compressed Base64. I’ll decode it directly with Python and print the embedded files. - Assistant
Python is unavailable in this image, so I’ll use Node’s built-in
zlibmodule for the same deterministic decode. - Assistant
The reproduction has two input listeners: generated
v-modelfirst assigns the typed DOM value to the model, thenonInputassigns"a". This points to synchronization betweenuseModel’s local custom ref, parent prop updates, and DOM value patching—not macro expansion itself. I’ll inspectuseModel, the DOM value patcher, and existing tests around transformed/rejected model values. - Assistant
useModelleaves its local value at the old prop while emitting to a bound parent, relying on the queued parent render to synchronize it. Both emits should collapse to parent value"a", so I’ll inspectvModelText’sbeforeUpdateguards and event scheduling, then review nearby regression tests to identify the browser-specific assumption. - Assistant
A key possibility is listener order. The directive installs a native
inputlistener, while@inputis installed through normal prop patching. If Firefox observes the opposite order, the user handler writes"a"first and then the generated model listener overwrites it with the DOM’s typed value. I’ll verify mount hook ordering and compile output, and inspect the event invoker implementation for browser-dependent timestamp/order behavior. - Assistant
The previous combined command did not show
mountElementbecause its declaration spans generic syntax. I’ll locate it by line number, and use the local compiler package to print the generated render function, which establishes the directive and user-listener registration order precisely. - Assistant
The runtime registers the generated model listener before the user listener, so standard FIFO dispatch should produce the intended final emit. The
useModelno-change guard already accounts for “change then reset before prop sync,” and an existing test covers that sequence. To avoid guessing, I’ll check available browser tooling and inspect the runtime-dom test harness/dependencies; if possible I’ll run the exact reproduction in Firefox and instrument listener/model/DOM state. - Assistant
Only Chrome is preinstalled. The directive element type includes an unused
_assigningmarker, but that may be unrelated legacy typing. I’ll inspect blame/history for the relevantvModelTextguards anduseModelsynchronization code, and search issue-number-like changes in the full local history for a later or reverted fix. - Assistant
The checkout contains history beyond the reported release but no obvious fix touching these paths. Since Firefox is not installed, I’ll attempt Puppeteer’s supported Firefox download (without changing repository files). If network access is unavailable, I can still build a browser-level regression around the identified event/value behavior in Chrome and validate lower-level state transitions.
- Assistant
Firefox downloaded successfully. I’ll build the local full global Vue bundle, then launch both Firefox and Chrome against an exact macro-equivalent reproduction (
defineModel()compiles touseModel(props, "modelValue")). I’ll use real keyboard input and log native listener order, parent model state, and DOM value after each keystroke. - Assistant
The combined command timed out because Corepack prompted interactively before running pnpm, so no repository change occurred. I’ll bypass pnpm and invoke the repository’s Node build script directly, then run the saved browser harness separately with a longer timeout.
- Assistant
The build script expects
rolluponPATH; the dependency exists locally. I’ll prependnode_modules/.binand rerun. - Assistant
The bundle built successfully; the harness file was never created because the earlier prompt blocked before its heredoc. I’ll create it under
/tmp(not the repository) and run both browsers now. - Assistant
Firefox cannot start due to a missing system library, and Chrome did not load the
file://script fromsetContent, leaving the app unmounted. I’ll inject the bundle with Puppeteer’saddScriptTag({path})instead, and install Firefox’s minimal shared-library dependencies in the environment (outside the repository) so the reported browser can be tested directly. - Assistant
The issue is now reproduced exactly:
- Firefox ends with DOM
"ayz"while the parent model is"a". - Chrome ends with both at
"a". - Firefox batches both native listeners into one scheduler turn. The parent changes
a → ay → abefore rendering, so its render sees no prop change and the child/directive never patches the manually edited DOM. useModelcorrectly emits the reset but does not trigger its own subscribers when the emitted value equals its still-current local prop.
The existing
prevSetValueguard already recognizes this “set away, then back before prop sync” case for emission. The missing counterpart is forcing a local update in that case. I’ll inspect the originating guard commit and related render-count assertions before implementing the smallest general fix. - Firefox ends with DOM
- Assistant
The guard was introduced specifically for multiple changes in one tick (#11430), but it only ensured the second value was emitted. I’ll capture whether the setter is restoring the current local value before mutating anything, then force subscribers after emission in that case. This is limited to a sequence the current guard already treats as meaningful; ordinary same-value assignments remain no-ops, and local-mode refs do not receive duplicate triggers because their local value changed on the first assignment.
- Assistant
Review caught a line-range shift: after the first edit added lines, the second numeric edit accidentally removed
i.emit(...)andprevSetValue = value. I’ll restore both and replace the whole post-local-update block explicitly, then inspect the diff again before testing. - Assistant
The corrected diff now preserves all original behavior and adds one force-trigger path. I’ll run the focused
useModelsuite first, rebuild the browser bundle from the modified source, and rerun the exact real-keyboard Firefox/Chrome reproduction. - Assistant
The focused suite passes, and the browser reproduction is fixed: Firefox now ends at DOM/model
"a"after typingxyz, matching Chrome. I’ll perform additional validation with the runtime-domv-modelsuite (the downstream consumer), lint the changed file, and inspect status/diff to ensure generated build artifacts are ignored and only the intended source change will be submitted. - Assistant
The default
unitproject intentionally excludes runtime-dom tests, so the command stopped before lint/status. I’ll list configured project names, then rerun that file under the DOM project and continue the remaining checks. - Assistant
The correct project is
unit-jsdom. I’ll run the suite there, then lint and inspect the final patch. - Assistant
All focused and downstream tests pass, lint passes, and only the intended source file is modified. Before finalizing, I’ll do one semantic review of the existing transformed-setter regression to ensure the broadened comment accurately describes both trigger branches and preserve its issue reference if appropriate.
- Assistant
The existing transformed-setter branch can compare values with differing raw/coerced types, so the combined comment is appropriately phrased around parent updates rather than strict local equality. I’ll retain the original
#10279provenance in the comment, run one final lint/diff check, then submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.