Skip to content
TheChatArchiveThe Chat Archive
xiaomi/mimo-v2.5-pro· 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. Assistant

    I'll start by exploring the repository structure to understand what we're dealing with. Let's first look at the root directory.

  3. Assistant

    Let me get a better overview of the repository structure.

  4. Assistant

    This is the Vue.js core repository. Let me look at the issue more closely. The problem is about defineModel on Firefox not working as expected - specifically with input filtering where only "a" should be allowed but other characters get through. Let me find the relevant source code.

  5. Assistant

    The issue is about defineModel not working as expected in Firefox. Let me understand the reproduction code first. From the URL, it seems like a Vue Playground link. Let me decode it to understand the component.

    The issue is that defineModel with value transformation/filtering doesn't work correctly in Firefox. This is likely related to how input events are handled differently in Firefox vs Chrome.

    Let me look at the defineModel implementation in the Vue compiler and runtime.

  6. Assistant

    Let me explore the issue more. The issue is about defineModel not working properly on Firefox. The reproduction shows an input field that should only keep "a" but it's not working on Firefox. Let me look at the playground link to understand what the code does.

    Let me first decode the playground URL to understand the reproduction case.

    Actually, let me first look at the useModel function in runtime-core since defineModel compiles down to that.

  7. Assistant

    Let me look at the useModel implementation and the useAttrsVModel implementation.

  8. Assistant

    Let me check the playground code to understand what's happening:

  9. Assistant

    Let me try with node instead.

  10. Assistant

    Let me try to decode the playground URL differently. The hash is URL-safe base64 encoded and compressed.

  11. Assistant

    Now I understand the reproduction! The issue is with <input v-model="model" @input="onInput" /> where model comes from defineModel(). The onInput function always sets model.value = 'a', but in Firefox it's not working as expected. This is likely an event handler ordering or input synchronization issue.

    Let me look at how v-model on native input elements works and how it interacts with defineModel.

  12. Assistant

    Let me look at the vModel directive implementation to understand how it handles input events.

  13. Assistant

    Now let me understand the issue. The reproduction is:

    • <input v-model="model" @input="onInput" /> where model is from defineModel()
    • onInput always sets model.value = 'a'
    • Expected: input should always show "a"
    • Actual on Firefox: other characters get through

    Let me look at how the compiler handles this case and how event handlers are merged:

  14. Assistant

    Let me look at the vModel.ts transform in compiler-dom.

  15. Assistant

    Now let me look at the event handler registration:

  16. Assistant

    Now I understand the reproduction. Let me trace the issue:

    The reproduction has:

    <template>
      <input v-model="model" @input="onInput" />
    </template>
    

    When a user types, the vModelText handler reads el.value and calls the assigner, while the @input handler sets model.value = 'a'. On Firefox, the DOM may not be updated fast enough when the v-model handler fires.

    Let me look at how the beforeUpdate of vModelText handles the case where the element is focused and has a different value from the model.

  17. Assistant

    Let me understand the compiled output better. Let me check how the compiler transforms v-model on native elements:

  18. Assistant

    Let me understand the issue better. The reproduction code has:

    <input v-model="model" @input="onInput" />
    

    where model comes from defineModel(). The onInput function sets model.value = 'a'. The issue is that this should always show "a" but on Firefox it doesn't.

    Let me look at the useModel test to understand the expected behavior:

  19. Assistant

    Let me look at how the event handler ordering works when both v-model and @input are on the same element:

  20. Assistant

    Let me look at how props and directives are patched in the runtime-core to understand the order.

  21. Assistant

    Let me look at the renderer to understand the order of prop patching and directive application.

  22. Assistant

    Let me look at the full patchElement function to see the order of operations.

  23. Assistant

    I can see that in patchElement, the order is:

    1. invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate') (line 853) - this calls directive beforeUpdate hooks BEFORE props are patched
    2. Then props are patched3. Then invokeDirectiveHook(n2, n1, parentComponent, 'updated') is called after

    So the directive beforeUpdate hook runs BEFORE props are patched. This means when vModelText.beforeUpdate runs, the props (including @input handler) haven't been updated yet.

    But wait, the vModelText directive's created hook adds the event listener via addEventListener. And the @input event handler is managed by Vue's event system. Let me think about the order of operations more carefully.

    When the input event fires:

    1. The vModelText handler (registered via addEventListener in created) fires and calls el[assignKey](el.value) - this calls the onUpdate:modelValue handler which triggers model update
    2. The @input="onInput" handler fires and sets model.value = 'a'

    But wait, the order depends on how they're registered. The @input="onInput" is registered via Vue's event system (patchEvent), which creates an invoker and adds it via addEventListener. The vModelText handler is also added via addEventListener.The key question is: which event handler fires first? Since both use addEventListener, it depends on the order they were registered.

    Let me think about the order of registration:

    1. During patch, props are processed first (which registers the @input handler)
    2. Then directives' created hook is called (which registers the vModelText handler)

    So the @input handler is registered FIRST, then the vModelText handler. This means when the input event fires:

    1. @input="onInput" handler fires first - sets model.value = 'a'
    2. vModelText handler fires second - reads el.value (the actual DOM value, e.g. "b") and calls el[assignKey]("b")

    So the vModelText handler always reads the DOM value and pushes it to the model, overwriting the 'a' that was set in step 1.

    BUT WAIT - this happens on Chrome too. The issue says it works on Chrome but not on Firefox. So there must be something else going on.

    Let me look at the beforeUpdate of vModelText more carefully:

    beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
        el[assignKey] = getModelAssigner(vnode)
        if ((el as any).composing) return
        const elValue = (number || el.type === 'number') && !/^0\d/.test(el.value)
     ? looseToNumber(el.value)
          : el.value
        const newValue = value == null ? '' : value
    
        if (elValue === newValue) {
          return
        }
    
        const rootNode = el.getRootNode()
        if (
          (rootNode instanceof Document || rootNode instanceof ShadowRoot) &&
          rootNode.activeElement === el &&
          el.type !== 'range'
        ) {
          if (lazy && value === oldValue) {
            return
          }
          if (trim && el.value.trim() === newValue) {
            return
          }
        }
    
        el.value = newValue
      },
    

    When the model is updated to 'a' (step 1 above), a re-render is triggered. During this re-render, beforeUpdate runs with value = 'a' (the new model value). But at this point:

    • el.value is still the old DOM value (e.g., "b" - what the user typed)
    • So elValue !== newValue (i.e., "b" !== "a")
    • The element is focused (activeElement === el)
    • None of the early return conditions apply (no lazy, no trim)
    • So it sets el.value = 'a' ✓

    But then the vModelText handler from step 2 fires and reads el.value which is now 'a' (because we just set it). So it calls el[assignKey]('a') which... doesn't change anything because the model is already 'a'.

    Wait, that can't be right. The issue is about the order of operations within a single event handler callback vs. the re-render.

    Let me reconsider. When the input event fires:

    1. Both event handlers fire synchronously in the same event loop
    2. @input="onInput" fires: model.value = 'a' → this triggers the customRef setter → i.emit('update:modelValue', 'a') → the parent updates3. vModelText handler fires: reads el.value (still 'b' because no re-render has happened yet) → calls el[assignKey]('b') → emits update:modelValue('b')

    So after the event handler callback, the parent has modelValue = 'b' (the last emit wins).

    Then a re-render happens:

    • vModelText.beforeUpdate runs with value = 'b'
    • el.value is 'b' → elValue === newValue → returns early, no DOM update

    So the input shows 'b', not 'a'. But the user says it works on Chrome...

    Actually wait, I need to think about this more carefully. The model.value = 'a' in onInput doesn't directly emit. Let me trace through the customRef setter again:

    set(value) {
        const emittedValue = options.set ? options.set(value) : value
        if (
          !hasChanged(emittedValue, localValue) &&
          !(prevSetValue !== EMPTY_OBJ && hasChanged(value, prevSetValue))
        ) {
          return
        }
        const rawProps = i.vnode!.props
        if (
          !(
            rawProps &&
            (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) &&
            (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps)
          )
        ) {
          // no v-model, local update
          localValue = value
          trigger()
        }
    
        i.emit(`update:${name}`, emittedValue)
        // ...
      },
    

    So when model.value = 'a' is called:

    • emittedValue = 'a'
    • At this point, localValue was already updated to 'b' (by the watchSyncEffect that ran when the vModelText handler set the model via the onUpdate:modelValue event)

    Wait, no. The order matters. Let me re-trace:

    User types "b":

    1. input event fires
    2. @input="onInput" fires FIRST (registered first): model.value = 'a'
      • customRef setter called with 'a'
      • localValue is currently whatever it was before (let's say '' - empty)
      • hasChanged('a', '') is true
      • v-model is present (from parent), so it does NOT update localValue directly
      • emits update:modelValue('a') to parent
    3. vModelText handler fires SECOND (registered second): reads el.value = 'b', calls el[assignKey]('b')
      • This calls onUpdate:modelValue('b') which goes through to... wait, actually the onUpdate:modelValue handler for the native <input> is compiled from v-model="model" and is the assigner from getModelAssigner. It calls model.value = 'b' through the parent's update mechanism.

    Hmm wait, I need to think about this differently. The <input v-model="model" @input="onInput" /> is inside the component that uses defineModel(). So:

    The template <input v-model="model" @input="onInput" /> is compiled to something like:

    createVNode("input", {
      value: model.value,
      onInput: [onInput, ...maybe other],
      "onUpdate:modelValue": $event => (model.value = $event)
    }, ...)
    

    Wait, for native elements with v-model, the compiler uses the vModelText directive which internally registers an input event listener that calls el[assignKey]('el.value') where el[assignKey] is getModelAssigner(vnode) which returns the onUpdate:modelValue handler.

    But the @input="onInput" is also present, so the compiled result has:

    {
      value: model.value,
      onInput: onInput,
      "onUpdate:modelValue": $event => (model.value = $event)
    }
    

    Wait actually let me look at how the compiler handles this. When both v-model and @input are on the same element, they merge the event handlers.

    Actually wait, v-model on a native element is handled by the vModelText directive. The directive creates its own input event listener via addEventListener in the created hook. The @input="onInput" is handled by Vue's event system via patchEvent. These are two separate event listeners.

    So when the user types:

    1. First event handler fires (whichever was registered first)
    2. Second event handler fires (whichever was registered second)

    Since props are patched before directives' created hook runs (see patchElement - it invokes directive hooks during beforeUpdate and updated, but for initial mount, it's in the mount path), let me check the mount order:

  24. Assistant

    Let me look at the mount sequence for native elements.

  25. Assistant

    Let me now focus on understanding the problem with how beforeUpdate works in the vModelText directive. Looking at the beforeUpdate hook, I can see the key comparison:

    const elValue = (number || el.type === 'number') && !/^0\d/.test(el.value)
        ? looseToNumber(el.value)
        : el.value
    const newValue = value == null ? '' : value
    
    if (elValue === newValue) {
        return
    }
    

    The issue is about what happens during the event handler flow. Let me look at the actual order of operations by examining how events are registered on the input element:

  26. Assistant

    Now I understand the reproduction code. Let me trace through the flow:

    1. App.vue passes v-model="amount" to Comp
    2. Comp.vue uses defineModel() and has <input v-model="model" @input="onInput" />
    3. onInput sets model.value = 'a'

    The problem is likely related to event handler ordering between the v-model directive's internal input handler and the @input user handler. Let me compile the component to see the actual output:

  27. Assistant

    Let me try to use the compiler-dom directly.

  28. Assistant

    Let me look more closely at how the vModelText directive handles input events and think about the Firefox issue:

  29. Assistant

    Let me look at recent changes related to vModel or event handling:

  30. Assistant

    Let me now focus on the core issue. Looking at the vModelText directive's beforeUpdate hook, the issue is likely about what happens when the input element is focused and the model value is updated. Let me check the beforeUpdate logic more carefully:

  31. Assistant

    Let me look at the vModel tests to understand the expected behavior better:

  32. Assistant

    Let me look at how component updates are determined:

  33. Assistant

    Let me look more carefully at the key issue. When both v-model and @input are on the same native input element, the order of event handlers matters. Let me trace through what happens:

  34. Assistant

    Let me look at the #11656 fix and the #8546 fix since they seem relevant:

  35. Assistant

    Let me look at the specific change in #11656:

  36. Assistant

    Let me look at the component update flow to understand how patchComponent works:

  37. Assistant

    Let me now try to understand the issue by looking at how the beforeUpdate of vModelText interacts with the event handler flow. Let me also look at recent PRs related to this:

  38. Assistant

    Let me now look at the shouldUpdateComponent logic to understand when child component updates are skipped:

  39. Assistant

    Let me now focus on the actual issue. Let me re-read the issue and the reproduction code:

    The reproduction shows:

    <!-- Comp.vue -->
    <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>
    

    When you type in the input:

    1. The input event fires
    2. Two handlers fire:
      • The vModelText directive's internal handler (registered via addEventListener in created)
      • The @input="onInput" user handler

    The key question is: what order do they fire?

    Looking at how the element is mounted:

    // In mountElement (renderer.ts):
    if (dirs) {
      invokeDirectiveHook(vnode, null, parentComponent, 'created')  // vModelText handler registered here
    }
    // ...
    if (props) {
      for (const key in props) {
        if (key !== 'value' && !isReservedProp(key)) {
          hostPatchProp(el, key, null, props[key], namespace, parentComponent)  // @input handler registered here
        }
      }
    }
    

    So vModelText's handler is registered FIRST, then @input="onInput" is registered SECOND.

    When the user types:

    1. vModelText handler fires: reads el.value (typed text), calls el[assignKey](el.value) which calls onUpdate:modelValue → this triggers model.value = typedValue
    2. @input="onInput" handler fires: calls model.value = 'a'

    But wait - el[assignKey] is the onUpdate:modelValue function. For v-model="model" where model is from defineModel(), this handler is $event => ((model).value = $event).

    So step 1 sets model.value to the typed value. Step 2 sets model.value to 'a'.

    But here's the critical thing: model is a customRef from useModel. When model.value = typedValue is called in step 1, the useModel setter fires, which emits update:modelValue(typedValue) to the parent. Then when model.value = 'a' is called in step 2, the useModel setter fires again, emitting update:modelValue('a') to the parent.

    So the parent gets both events. The parent's ref ends up as 'a'. Then the parent re-renders, and watchSyncEffect in useModel detects the change, updates localValue to 'a', and triggers. Then vModelText.beforeUpdate fires with value = 'a', el.value is still the typed value, so it sets el.value = 'a'.

    This should work... but the issue says it doesn't work on Firefox.

    Wait, let me think about this more carefully. Maybe the issue is about the beforeUpdate comparison. Let me look at the code path again:

    In vModelText.beforeUpdate:

    const elValue = (number || el.type === 'number') && !/^0\d/.test(el.value)
        ? looseToNumber(el.value)
        : el.value
    const newValue = value == null ? '' : value
    
    if (elValue === newValue) {
      return  // Skip update
    }
    

    If el.value is already 'a' (because something else set it), and newValue is 'a', then elValue === newValue and the update is skipped. But who would have set el.value to 'a'?

    Unless... the beforeUpdate itself is setting el.value = 'a' in a previous cycle, and then on the next keystroke, el.value starts with 'a' and then the typed character is appended.

    Wait, let me think about the timeline more carefully:

    First keystroke:

    1. User types 'b'. el.value becomes 'b'.
    2. vModelText handler: reads el.value = 'b', emits 'b' to parent
    3. @input handler: sets model.value = 'a', emits 'a' to parent
    4. Parent re-renders with 'a'. watchSyncEffect runs. Child re-renders.
    5. vModelText.beforeUpdate: value = 'a', el.value = 'b' (still), elValue !== newValue, sets el.value = 'a'

    OK so after first keystroke, el.value = 'a'.

    Second keystroke:

    1. User types 'c'. el.value becomes 'ac'.
    2. vModelText handler: reads el.value = 'ac', emits 'ac' to parent
    3. @input handler: sets model.value = 'a', emits 'a' to parent
    4. Parent re-renders... but amount was already 'a'! Does the parent actually re-render?

    Hmm, in step 2, parent's amount goes from 'a' to 'ac'. In step 3, it goes back to 'a'. Vue batches the updates. The final value is 'a'. Since the value didn't actually change from the last render ('a' → 'a'), the parent might not re-render the child.

    But wait, Vue's reactivity tracks that the ref was set. Even if the final value is the same, the effect might still be triggered. Let me think...

    When amount.value = 'ac' is called, the ref's value changes, triggering the parent's render effect. Then amount.value = 'a' is called, value changes again, but the effect is already queued. The effect runs once with the final value 'a'.

    In the parent's render, it creates a vnode for Comp with modelValue = 'a'. If the previous vnode also had modelValue = 'a', then shouldUpdateComponent might skip the update.

    Let me check shouldUpdateComponent:

  40. Assistant

    Now I need to understand the exact issue better. The problem is:

    1. vModelText directive adds an input event handler in created hook
    2. @input="onInput" adds another input event handler via props
    3. When user types, both fire - vModelText's handler reads el.value and passes it to model first, then onInput sets model to 'a'
    4. On subsequent keystrokes, the parent's value doesn't actually change (was already 'a'), so the child doesn't re-render, and el.value is never corrected

    Let me verify this theory by examining how shouldUpdateComponent works:

  41. Assistant

    Now I have a clear picture of the issue. Let me trace through the exact problem:

    1. User types in <input v-model="model" @input="onInput" />
    2. vModelText's handler fires FIRST (registered in created before props): reads el.value = typed text, calls model.value = typedText → emits to parent
    3. @input="onInput" fires SECOND: sets model.value = 'a' → emits to parent
    4. Parent value ends up as 'a' (same as before typing on subsequent keystrokes)
    5. Since parent value didn't change → shouldUpdateComponent returns false → child doesn't re-render → el.value is never corrected

    The fix needs to be in useModel - when the model is set to the same value it already has (but was set to a different value earlier in the same tick), we need to force a local trigger so the child re-renders and vModelText.beforeUpdate can correct el.value.

    Let me implement this fix:

  42. Assistant

    Now I can see the exact code. Let me implement the fix. The issue is that when model.value is set to the same value it already has (e.g., 'a'), but was previously set to a different value in the same synchronous event handler chain (e.g., the typed text from vModelText), the useModel setter emits to the parent but doesn't trigger a local update. Since the parent's value didn't change, the child doesn't re-render, and el.value is never corrected by vModelText.beforeUpdate.

  43. Assistant

    Let me use the edit command directly:

  44. Assistant

    Now I need to edit the file to add the fix. Let me add the condition after the #10279 check.

  45. Assistant

    Good, the edit looks correct. Now let me run the existing tests to make sure the fix doesn't break anything:

  46. Assistant

    All 14 tests pass. Let me also run the vModel tests:

  47. Assistant

    All tests pass. Let me also run the defineModel tests:

  48. Assistant

    All tests pass. Now let me create a test script to verify the fix works for the specific issue described:

  49. Assistant

    Let me write a proper test that simulates the exact issue scenario using the existing test infrastructure:

  50. Assistant

    The test file needs to be inside the packages directory. Let me place it correctly:

  51. Assistant

    The path is wrong. Let me fix it.

  52. Assistant

    Let me look at how the existing test imports useModel:

  53. Assistant

    Let me check how the existing test imports useModel.

  54. Assistant

    The path should be ../../src/helpers/useModel. Let me fix the test file:

  55. Assistant

    The test passes. Now let me clean up the test file and run all the relevant tests to make sure nothing is broken:

  56. Assistant

    Now let me run all the relevant tests to make sure nothing is broken:

  57. Assistant

    All 54 tests pass. Let me run a broader set of tests to make sure nothing else is broken:

  58. Assistant

    All 1019 tests pass. Let me also run the runtime-dom tests:

  59. Assistant

    All tests pass. Let me verify the final state of the changed file:

  60. Assistant

    Let me check the diff to confirm the change:

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