Skip to content
TheChatArchiveThe Chat Archive
GLMz-ai/glm-5.2· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION defineModel on Firefox does not work as expected Vue version 3.5.17…

  1. User

    ISSUE DESCRIPTION

    defineModel on Firefox does not work as expected

    Vue version

    3.5.17

    Link to minimal reproduction

    https://play.vuejs.org/#eNqFUslOwzAQ/RXLlxSppAc4lRaxqIcisQgQJ1+idBJcnLHlJVSq8u+MnbYUynKy573xm+eZWfNLY/I2AB/ziSutNJ458MEwVWA9Fdw7wc8FysZo69maWag6VlndsIxeZTvmWjdmg+ejGETR7EygwFKj86xodEDPplFhkGVHAiejviDJU+ChMarwQBFjkyTXHjd6AYpc9I8FHxE7Ge2l8iE5pAKVrPOl00jfWEcBwUtSkArsvfGSDAg+ZomJXKGUfr9JmLcBhlu8fIXy7Qd86VYRE/zBggPbguA7zhe2BrIW6dnTHazoviPJf1CU/Qf5CE6rED32aVcBF2R7Ly+5nac2S6yf3WzlAd32U9FozOxSvuDU9ti8377+afckP03vBHbUxe3I/tmDfpZpLDTKBVQS4TZGAxqowCpgGWsyjXM0wQ+gBfRjNovHUe9CQRKQlYTFS6ECkFBW0CaxXjdvN+CXJHL5bWMOdkbGintLk07B2UUiCNiYIuhwj7oPe2AHrg

    Steps to reproduce

    1. Use firefox
    2. 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.4
    

    Any 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 using git reset --hard command. Additionally, you can use git stash and git stash pop 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 submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. GLM Assistant

    Let me explore the repository structure and understand the issue. The issue is about defineModel not working correctly on Firefox. The problem seems to be related to how input events are handled - specifically, when a user types in a field, the value should be blocked/reset to only "a", but on Firefox it doesn't work.

    Let me first look at the repository structure.

  3. GLM Assistant

    This is the Vue 3 core repository. The issue is about defineModel not working correctly on Firefox. Let me understand the issue better.

    The reproduction link shows a component where:

    1. There's an input field with v-model (using defineModel)
    2. When the user types, the setter only keeps "a" (i.e., it blocks other characters)
    3. On Chrome this works, but on Firefox it doesn't

    The key issue is that when a v-model setter modifies the value (e.g., always returning "a"), the DOM input should be updated to reflect the new value. On Firefox, the DOM doesn't get updated correctly.

    Let me look at how defineModel and v-model work with input elements, particularly the vModelText directive or the model event handling.

    Let me search for relevant files.

  4. GLM Assistant

    Let me look at the vModel directive and the useModel helper:

  5. GLM Assistant

    Let me look at the useModel helper which implements defineModel:

  6. GLM Assistant

    Let me decode the reproduction to understand the exact code:

  7. GLM Assistant

    Let me try to decompress the playground code using Node.js:

  8. GLM Assistant

    Let me try to install lz-string or use a different approach. Let me look for it in the node_modules.

  9. GLM Assistant

    Let me write a Node script to decompress the playground link using lz-string:

  10. GLM Assistant

    Let me try a different approach - install lz-string:

  11. GLM Assistant

    Let me use the actual encoded string from the issue and try zlib decompression (the eNq prefix suggests base64-encoded zlib data):

  12. GLM Assistant

    Now I understand the reproduction. The Comp.vue has:

    <script setup lang="ts">
    const model = defineModel()
    function onInput(event: Event) {
      let modifiedValue = 'a'
      model.value = modifiedValue
    }
    </script>
    <template>
      <input v-model="model" @input="onInput" />
    </template>
    

    So the input has BOTH v-model="model" AND @input="onInput". The onInput handler sets model.value = 'a' every time. The issue is about the ORDER of event listeners. Let me investigate the listener registration order.

  13. GLM Assistant

    Let me check the git log for recent changes to these files:

  14. GLM Assistant

    Let me look at the e2e test setup and try to reproduce the issue:

  15. GLM Assistant

    Let me check the e2e test utilities and see if I can reproduce with a real browser:

  16. GLM Assistant

    Let me check how v-model is compiled and applied — whether it uses dirs or vnode hooks:

  17. GLM Assistant

    So the v-model on a native input uses needRuntime = context.helper(directiveToUse) (V_MODEL_TEXT). This is the directive approach. Let me check how this is applied — is it via withDirectives (so it's in vnode.dirs) or via vnode hooks?

    Let me look at the codegen for directives.

  18. GLM Assistant

    Let me compile a test template to see the actual generated code:

  19. GLM Assistant

    No dist. Let me build the compiler or use the source. Let me try building:

  20. GLM Assistant

    Let me build the compiler-dom package:

  21. GLM Assistant

    Need to build compiler-core too, or build with a bundle that includes everything. Let me build the full vue package which is what the e2e tests use. Actually, let me just build compiler-core too. Or better, let me build vue with global format which bundles everything.

    Actually, let me just build compiler-core first.

  22. GLM Assistant

    Let me build the full vue global bundle instead, which is self-contained:

  23. GLM Assistant

    Let me look at invokeDirectiveHook and verify the order of created vs props patch:

  24. GLM Assistant

    Let me write a puppeteer test to reproduce the scenario and verify behavior on Chromium:

  25. GLM Assistant

    Let me remove the TS syntax from the test:

  26. GLM Assistant

    On Chromium, the final value is "a" (correct). The v-model listener fires first, then onInput fires last so "a" wins. Now I need to understand the Firefox difference. Let me search the codebase for any Firefox-related handling:

  27. GLM Assistant

    Let me check the changelog for any related fixes and look at the git history around v-model and defineModel:

  28. GLM Assistant

    Let me look at the changelog for v3.5.x to find the issue. Let me check the changelogs directory.

  29. GLM Assistant

    Let me look at the latest v-model commit to understand the focus check changes:

  30. GLM Assistant

    Let me look at the git history of the focus check to understand its intent:

  31. GLM Assistant

    Let me find when the document.activeElement === el check was originally added:

  32. GLM Assistant

    Let me look at the events module to understand how listeners are wrapped:

  33. GLM Assistant

    Let me compile the actual SFC template to see the exact generated code. Let me build compiler-sfc:

  34. GLM Assistant

    Let me build all the compiler deps needed. Actually, let me use the global build which includes the compiler:

  35. GLM Assistant

    Let me use puppeteer to compile the template and inspect the generated render code:

  36. GLM Assistant

    The function mode compile returns code that needs Vue global. Let me check what compile returns. Maybe code is undefined because compile in the global build (runtime+compiler) returns a render function directly. Actually, compile returns { render, code, ast } I think. But it returned undefined for code. Let me check - maybe the global build's compile returns a compiled function and code is not exposed. Let me just get ast and inspect, or compile and get the source.

    Let me try returning the keys.

  37. GLM Assistant

    Let me build the compiler-dom as a self-contained esm-browser build:

  38. GLM Assistant

    Let me use function mode and add the Vue global:

  39. GLM Assistant

    Let me look at the e2e vModel tests for any related scenarios with @input + v-model:

  40. GLM Assistant

    Let me look at the useModel spec tests related to force-update and multiple changes:

  41. GLM Assistant

    Let me test with multiple keystrokes to see if the bug manifests on the second keystroke:

  42. GLM Assistant

    This confirms the bug happens on the second keystroke on Chromium too. The first keystroke works, but subsequent ones don't reset the value. Let me look at the related commit #11430 "correct update with multiple changes in same tick":

  43. GLM Assistant

    Let me look at the test added for #11430 to understand the scenario:

  44. GLM Assistant

    This confirms the bug happens on the second keystroke on Chromium too — the DOM doesn't reset because the prop doesn't change (final value equals previous), so the component doesn't re-render and beforeUpdate never runs. Let me check if I can test with Firefox via playwright:

  45. GLM Assistant

    Let me try installing playwright to test with Firefox:

  46. GLM Assistant

    Let me install the missing system library:

  47. GLM Assistant

    Now let me try running the reproduction with Firefox via playwright:

  48. GLM Assistant

    On Firefox, the behavior is identical to Chromium: first keystroke works ("a"), but 2nd+ keystrokes fail ("ac", "acd"). So the bug is browser-independent — the DOM doesn't reset on subsequent keystrokes because the prop doesn't change (final value equals previous) so the component doesn't re-render. Let me make a repro using the exact SFC templates via runtime compilation to confirm:

  49. GLM Assistant

    Let me run just Firefox with playwright (chromium already confirmed via puppeteer):

  50. GLM Assistant

    Confirmed: the bug is browser-independent (same on Firefox and Chromium). The first keystroke works, but subsequent keystrokes don't reset the DOM because the prop doesn't change (final value equals previous) so the component never re-renders and beforeUpdate never syncs the DOM. Let me examine the existing force-trigger tests to design a safe fix:

  51. GLM Assistant

    Let me run the existing useModel tests to understand the current behavior:

  52. GLM Assistant

    Let me write a quick script to understand the #10279 test's actual values:

  53. GLM Assistant

    Let me add more detailed logging to understand the conversion:

  54. GLM Assistant

    Now I understand the number conversion. Let me look at the remaining useModel tests to ensure my fix is safe:

  55. GLM Assistant

    Let me look at the "custom setter" test:

  56. GLM Assistant

    I now fully understand the root cause. The DOM doesn't reset on subsequent keystrokes because the final model value equals the previous prop value, so the parent re-renders but the child's prop is unchanged → the child doesn't re-render → beforeUpdate never syncs the DOM. Let me look at the exact setter code and implement a fix:

  57. GLM Assistant

    Let me look at the local mutation tests to ensure my fix is safe:

  58. GLM Assistant

    Now let me implement the fix. I'll add a force-trigger for the case where the model is set multiple times in the same tick (e.g., v-model's input listener and a user input handler both set the model), and the final emitted value equals the current prop value so the parent won't re-render, but the local input state may be out of sync:

  59. GLM Assistant

    There's a duplicate of the prevSetValue/prevEmittedValue lines. Let me fix:

  60. GLM Assistant

    The fix looks good. Now let me rebuild the vue global bundle and re-run the reproduction on both Chromium and Firefox to verify:

  61. GLM Assistant

    Let me re-run without filtering to see the output:

  62. GLM Assistant

    Let me run without grep to see any errors:

  63. GLM Assistant

    waitForTimeout is removed in newer puppeteer. Let me use a setTimeout helper:

  64. GLM Assistant

    The fix works on both Chromium and Firefox — the value is now always "a" after every keystroke. Now let me run the existing useModel tests to ensure no regressions:

  65. GLM Assistant

    All useModel tests pass. Let me run the broader related test suites — defineModel (compiler-sfc), vModel (runtime-dom), and the e2e vModel tests:

  66. GLM Assistant

    Now let me run the e2e vModel tests (which use the global build I just rebuilt):

  67. GLM Assistant

    The e2e failure is a puppeteer/chromium environment issue (browser launch failed), not related to my change. Let me verify this is pre-existing by checking puppeteer's browser availability:

  68. GLM Assistant

    The e2e tests need --no-sandbox (set when CI env is present). Let me run with CI=true:

  69. GLM Assistant

    The e2e test passes (the earlier failure was just a sandbox env issue). Let me run the broader runtime-core and runtime-dom test suites to confirm no regressions:

  70. GLM Assistant

    All pass. Let me run the full e2e suite (with the rebuilt global bundle) to be safe:

  71. GLM Assistant

    All e2e tests pass. Let me also run the compiler vModel tests to be thorough:

  72. GLM Assistant

    All tests pass. Let me also verify the defineModel set option approach (the documented clamping method) still works correctly with multiple keystrokes in a real browser, plus a scenario where the clamp targets a different value:

  73. GLM Assistant

    The set-option approach also works on both browsers. Let me check the git status to see what changes will be submitted and clean up any build artifacts:

  74. GLM Assistant

    Only useModel.ts is modified (dist files are gitignored). Let me verify the final diff:

  75. GLM Assistant

    The fix is clean and minimal. Let me do a final review of the complete modified setter:

  76. GLM Assistant

    The fix is complete and verified. Let me make sure no temporary files are left in the repo:

  77. GLM Assistant

    The repository is clean — only useModel.ts is modified. Let me submit the fix.

    Summary

    Issue: When using defineModel with v-model on an <input> plus a clamping @input handler (e.g., always setting the model to 'a'), the input should only ever show 'a'. On the second and subsequent keystrokes, the DOM was not reset to 'a' — it kept showing the typed characters (e.g., ac, acd).

    Root cause: I reproduced this on both Chromium and Firefox (installing Firefox via Playwright to confirm it is not browser-specific, contrary to the report). On each keystroke two things set the model synchronously:

    1. The v-model directive's input listener sets the model to the raw DOM value (e.g. "ac"), emitting "ac" to the parent.
    2. The user's @input handler sets the model to the clamped value "a", emitting "a" to the parent.

    The parent's value ends up at "a" — the same value it already held. So when the parent re-renders, the child's prop is unchanged ("a" === "a"), the prop-sync watchSyncEffect does not fire, the child component never re-renders, and the vModelText directive's beforeUpdate (which is responsible for writing el.value back) never runs. The DOM stays out of sync with the model.

    Fix (in packages/runtime-core/src/helpers/useModel.ts): Added a force-trigger in the model setter for the case where the model is set multiple times in the same tick, the intermediate emitted value differs from the final one (hasChanged(emittedValue, prevEmittedValue)), and the final emitted value equals the current prop value (!hasChanged(emittedValue, localValue)) — meaning no parent-driven re-render will occur. Forcing a local re-render lets vModelText.beforeUpdate resync el.value to the correct value. This condition is mutually exclusive with the existing #10279 force-trigger (they differ on the prevEmittedValue axis), so no double-triggers occur.

    Verification:

    • Reproduced the bug on Chromium and Firefox (value stuck at ac/acd).
    • After the fix, both browsers show ["a","a","a","a"] across keystrokes.
    • The defineModel set-option clamping approach still works on both browsers.
    • All existing tests pass: useModel.spec (14), defineModel.spec (12), runtime-dom vModel.spec (28), compiler vModel specs (39), runtime-core unit (1019), unit-jsdom (378), and the full e2e suite (103).

    Checklist

    • Reproduced the error — confirmed on both Chromium (puppeteer) and Firefox (Playwright): the DOM fails to reset on the 2nd+ keystroke.
    • Confirmed the fix resolves the error — both browsers now show 'a' after every keystroke.
    • Considered edge cases — first keystroke (no spurious trigger), set-option clamp (still works), normal v-model (no spurious renders), local-mutation mode (redundant trigger is deduped by the scheduler), clamping to a different value (prop change still drives the update), infinite loops (none — re-render reads localValue and programmatic el.value writes don't fire input), and wrong renders (none — the trigger always uses the correct localValue). The new condition is mutually exclusive with the existing #10279 condition.
    • Ran affected existing tests — all pass (useModel, defineModel, vModel unit/jsdom/e2e, full runtime-core and unit-jsdom suites, full e2e suite).

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.