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 to understand the structure and locate the relevant code for defineModel. Let's first see what we're dealing with.

  3. Assistant

    Let me explore the repository structure to understand the Vue.js codebase and find the relevant code for defineModel.

  4. Assistant

    Let me understand the issue. The issue is about defineModel not working as expected on Firefox. Let me look at the reproduction link to understand what the user is trying to do. They mention that when using defineModel, they want to only allow "a" as input, but it doesn't work on Firefox.

    Let me look at the defineModel implementation in the Vue codebase.

  5. Assistant

    Let me look at the runtime useModel implementation since defineModel compiles to use that:

  6. Assistant

    Let me examine the useModel implementation.

  7. Assistant

    Now let me look at the defineModel spec test to understand how it's supposed to work:

  8. Assistant

    Now let me understand the issue better. Let me look at how v-model on native inputs works and how the value gets set back:

  9. Assistant

    Let me decode the playground URL to understand the reproduction:

  10. Assistant

    Let me try python instead.

  11. Assistant

    Let me try with node.js

  12. Assistant

    Now I understand the reproduction. The issue is:

    1. A child component uses defineModel() and binds to an <input> with v-model="model"
    2. There's also an @input handler that forces model.value = 'a'
    3. On Firefox, this doesn't work - the input value isn't being reset properly

    Let me look at the vModel directive implementation:

  13. Assistant

    Now let me understand the flow better. Let me look at how events are mounted in the runtime:

  14. Assistant

    Let me look at the runtime-core's mount element logic to understand ordering:

  15. Assistant

    Let me look at the renderer to understand how event listeners are attached and the order they fire.

  16. Assistant

    Let me look at the mountElement function:

  17. Assistant

    Now I understand the issue better. Let me trace through the code flow to understand the Firefox-specific problem. Let me look at how events are handled:

  18. Assistant

    Now let me understand the full picture. Let me look at recent git history related to useModel and vModelText:

  19. Assistant

    Let me look at the issue more carefully. Let me look at recent issues related to Firefox:

  20. Assistant

    Let me understand the reproduction better. Let me look at how the compiler handles v-model combined with @input:

  21. Assistant

    Let me look at the vModel transform to understand how the compiler generates the event handler for v-model on inputs.

  22. Assistant

    Now let me understand the core issue. Let me look at the beforeUpdate hook of vModelText more closely, specifically the part where it decides whether to update el.value:

  23. Assistant

    Let me look at the #10279 fix and understand the force local update logic more carefully:

  24. Assistant

    Now let me understand the issue better. The problem is with defineModel on Firefox. Let me decode the playground link to understand the reproduction case.

  25. Assistant

    Let me look at the issue more carefully. Let me re-read the reproduction code:

    The reproduction from the playground:

    1. App.vue has a ref('') named amount and passes it as v-model to Comp
    2. Comp.vue has defineModel() and binds it to <input v-model="model" @input="onInput" />
    3. onInput sets model.value = 'a' (always forces "a")

    The problem: When you type in the input in Firefox, the input event fires. The v-model directive on the input element reads el.value and calls the model setter. Then the @input handler also fires and sets model.value = 'a'. But the input shows what you typed instead of "a".

    Let me think about the ordering of event handlers:

    1. The vModelText directive adds an input event listener in the created hook
    2. The @input="onInput" also adds an event listener via patchEvent

    In mountElement, directive created hooks are called BEFORE props are patched. So:

    1. vModelText.created runs → adds input event listener (listener A)
    2. Props are patched → @input is added as event listener (listener B)

    When the input event fires, both listeners run. The order should be:

    • Listener A (vModelText): reads el.value and calls el[assignKey](...) which triggers onUpdate:modelValue
    • Listener B (@input): calls onInput() which sets model.value = 'a'

    But wait, there's something subtle here. The v-model on a native input compiles to a directive. But @input is a regular event handler. However, the v-model directive also adds its own event listener for the input event.

    Let me look at how the v-model directive's input handler works more carefully.

    The v-model directive adds:

    addEventListener(el, 'input', e => {
        if ((e.target as any).composing) return
        el[assignKey](castValue(el.value, trim, castToNumber))
    })
    

    And the @input handler is:

    function onInput(event: Event) {
        let modifiedValue = 'a'
        model.value = modifiedValue
    }
    

    Both are on the input event. The v-model listener is added first (in created hook), then the @input listener is added (in prop patching).

    So when the input event fires:

    1. v-model handler fires first: el[assignKey](el.value) → this emits update:modelValue with the current el.value
    2. @input handler fires second: model.value = 'a'

    Now, the key question is: in step 1, el[assignKey] is the getModelAssigner(vnode) which gets onUpdate:modelValue from the vnode props. This is the function that the parent passes to update the model. In the case of v-model="model" on a native input, this calls model.value = el.value.

    Then in step 2, model.value = 'a' overrides it.

    But wait - there's a race condition here. When model.value is set twice in the same synchronous execution:

    1. First model.value = el.value (e.g., "ab") → this triggers useModel.set("ab")
    2. Then model.value = 'a' → this triggers useModel.set("a")

    In useModel.set, the first call:

    • emittedValue = "ab", localValue = "a" (current value)
    • hasChanged("ab", "a") = true → doesn't return early
    • Emits update:modelValue with "ab" to parent
    • Sets prevSetValue = "ab", prevEmittedValue = "ab"

    Then the second call:

    • emittedValue = "a", localValue = "a" (still the same, hasn't been updated by prop sync yet)
    • hasChanged("a", "a") = false
    • Also checks prevSetValue !== EMPTY_OBJ && hasChanged("a", "ab") → true
    • So !hasChanged(emittedValue, localValue) && !(prevSetValue !== EMPTY_OBJ && hasChanged(value, prevSetValue))
    • = true && !(true) = true && false = false → DOESN'T return early
    • Emits update:modelValue with "a" to parent

    So the parent will eventually get value "a" and re-render. But here's the key: the v-model directive's beforeUpdate hook is what updates the DOM input value.

    In beforeUpdate:

    beforeUpdate(el, { value, oldValue, ... }, vnode) {
        el[assignKey] = getModelAssigner(vnode)
        if ((el as any).composing) return
        const elValue = ...  // el.value
        const newValue = value == null ? '' : value
    
        if (elValue === newValue) {
          return  // ← IMPORTANT: skips update if el.value already matches
        }
        ...
        el.value = newValue
    }
    

    The problem is: after the model is set to "a", when beforeUpdate runs, el.value might still be "ab" (the user typed value), and newValue is "a", so elValue !== newValue and it should update. So that should work...

    Wait, let me reconsider. The issue says "Firefox does not work as expected". Maybe the problem is with the event handler ordering. In Firefox, @input might fire BEFORE the v-model directive's input handler?

    Actually, looking at the code again: in mountElement, directive created hooks run BEFORE props are patched. So the v-model directive's event listener is added first via addEventListener. Then the @input handler is added. But wait - how is @input added?

    Looking at patchEvent, it creates an invoker and adds it via addEventListener. So both are native addEventListener calls. The order of event listener execution in the DOM is the order they were added.

    So v-model's listener fires first, then @input fires second. That seems correct.

    Hmm, but let me think about this differently. What if the problem is about how beforeUpdate in vModelText works?

    After both event handlers run:

    • model.value has been set to "a" (via the second handler)
    • The parent receives update:modelValue with "a"
    • The parent re-renders, passing modelValue = "a" back to Comp
    • Comp's defineModel() ref sees the new prop value
    • The v-model directive's beforeUpdate runs with value = "a"

    But what's el.value at this point? It's the user-typed value, e.g., "ab". So elValue !== newValue, and el.value = "a" is set.

    Wait, but there's also the v-model directive's created hook's event listener. That listener fires FIRST and reads el.value. Then @input fires and sets model.value = 'a'.

    But in the first handler, el[assignKey](castValue(el.value, trim, castToNumber)) is called. The assignKey is the getModelAssigner(vnode) which is the onUpdate:modelValue from the parent. For v-model="model" on an input inside Comp, this is model.value = el.value.

    Actually wait, I'm confused about the nesting. Let me re-think:

    1. The parent App has v-model="amount" on Comp. This means Comp receives modelValue prop and onUpdate:modelValue event.
    2. Inside Comp, there's <input v-model="model" @input="onInput" />. This is the native input v-model.

    For the native input v-model="model", the compiler transforms this to a directive that:

    • Creates the input element with modelValue: model.value and onUpdate:modelValue that updates model.value
    • But wait, for native elements, v-model is handled differently. The directive vModelText handles it.

    Actually, let me look at this more carefully. For a native <input v-model="model">, the template compiler:

    1. Removes modelValue from the props
    2. Adds vModelText directive with binding value = model.value
    3. Adds onUpdate:modelValue event handler that sets model.value

    So the vNode for the input has:

    • onUpdate:modelValue: (val) => { model.value = val } (from v-model compilation)
    • onInput: onInput function (from @input)

    Both of these are on the same vnode. The vModelText directive's created hook:

    1. Gets el[assignKey] = getModelAssigner(vnode) → this is onUpdate:modelValue from the vnode props
    2. Adds an input event listener that calls el[assignKey](el.value)

    Then props are patched: 3. onInput is added via patchEvent

    So when the input event fires:

    • v-model's listener fires: el[assignKey]("ab") → this calls model.value = "ab"
    • @input listener fires: onInput() → model.value = "a"

    Both are synchronous. After both handlers run, model.value is "a" (the second assignment wins).

    Now, in the useModel setter:

    1. First call with "ab": emits "ab" to parent
    2. Second call with "a": emits "a" to parent

    Both emissions happen synchronously. The parent's re-render is batched. Eventually the parent re-renders with amount = "a", passes modelValue = "a" to Comp, and the vModelText directive's beforeUpdate runs.

    At this point, el.value is still "ab" (the browser's input value), and newValue is "a". So el.value = "a" is set.

    But here's where the Firefox issue might come in. In Firefox, there might be a race condition where the browser is still processing the input event and the cursor position, and setting el.value during beforeUpdate might not work correctly because the browser is in the middle of updating the input.

    Actually, wait. Let me re-read the issue description more carefully. The issue says:

    Enter anything in the field. It should be blocked and only show "a", but it wont on firefox.

    So the issue is that when you type in the input, it doesn't get blocked to "a". The input shows what you typed.

    Let me think about this differently. Maybe the problem is that in Firefox, the beforeUpdate hook returns early because elValue === newValue.

    Wait, that would only happen if el.value is already "a" when beforeUpdate runs. But after typing "b", el.value should be "ab" or "b", not "a".

    Hmm, unless the model setter sets the value back to "a" synchronously, and then the beforeUpdate runs with el.value already being "a"...

    Actually, I think I need to look at this from a different angle. Let me look at how useModel interacts with the vModelText directive's beforeUpdate.

    Actually wait - I think I understand the issue now! The problem is with the el[assignKey] in the vModelText directive. The assignKey is a Symbol stored on the element. It's set in the created hook:

    el[assignKey] = getModelAssigner(vnode)
    

    And also updated in beforeUpdate:

    el[assignKey] = getModelAssigner(vnode)
    

    But wait, that's the assigner for the native input's v-model, not for the component's defineModel.

    Let me think about this again...

    Actually, I think the issue is more subtle. Let me trace through the exact sequence of events in Firefox:

    1. User types "b" in the input (currently showing "a")

    2. The native input event fires

    3. First handler (vModelText directive): calls el[assignKey]("b") → this triggers onUpdate:modelValue which calls model.value = "b"

    4. In useModel.set("b"):

      • emittedValue = "b", localValue = "a" → hasChanged = true
      • Emits update:modelValue("b") to parent
      • prevSetValue = "b", prevEmittedValue = "b"
    5. Second handler (@input): calls onInput(event) → model.value = "a"

    6. In useModel.set("a"):

      • emittedValue = "a", localValue = "a" → hasChanged = false
      • But prevSetValue = "b", hasChanged("a", "b") = true
      • So the condition: !hasChanged("a", "a") && !("b" !== EMPTY_OBJ && hasChanged("a", "b")) = true && false = false
      • Doesn't return early
      • Emits update:modelValue("a") to parent
      • #10279 check: hasChanged("a", "a") = false → doesn't trigger local update
      • prevSetValue = "a", prevEmittedValue = "a"
    7. Now the parent has received two updates: first "b", then "a". The last one is "a".

    8. Parent re-renders with amount = "a", passes modelValue = "a" to Comp

    9. useModel's watchSyncEffect runs: propValue = "a", localValue = "a" → no change → no trigger

    10. But Comp still re-renders because parent re-rendered

    11. vModelText's beforeUpdate runs: value = "a", el.value = "b" (still shows what user typed?)

      • Wait, el.value at this point... hmm.

    Actually, step 9 is interesting. The watchSyncEffect doesn't trigger because localValue is already "a". But the parent did re-render, so the child re-renders anyway. The vModelText beforeUpdate runs with value = "a".

    Now, what's el.value at this point? In Chrome, it might be "b" (what the user typed before it was set to "a" by the useModel). But wait, in the event handler sequence, the v-model directive's handler reads el.value to get "b", and then later the @input handler forces model.value = "a". But el.value is still "b" because nothing has changed the DOM yet.

    So beforeUpdate should see el.value = "b" and newValue = "a", and set el.value = "a". This should work.

    But wait - maybe in Firefox, the beforeUpdate runs but el.value is already "a" somehow? Or maybe the beforeUpdate doesn't run at all because the parent didn't actually trigger a re-render?

    Hmm, let me reconsider. After step 6, the parent emitted "a". But the parent's current value is already "" (the initial value). The parent updates amount = "a" and re-renders. This triggers a re-render of the child with modelValue = "a".

    But wait, the useModel's watchSyncEffect sees propValue = "a" and localValue = "a" (because localValue was never updated since both emits happened in the same tick). So hasChanged is false, trigger() is not called. But the component still re-renders because the parent re-rendered... right?

    Actually, I need to think about this more carefully. The useModel returns a customRef. The customRef is used in the template. When the parent re-renders, the child's render function is called (because props changed). Inside the render function, model.value is accessed, which calls the get of the customRef, which returns localValue (which is "a"). The v-model directive binding value is model.value which is "a".

    So vModelText.beforeUpdate is called with value = "a". And el.value is still "b" (or whatever the user typed). So it should update.

    OK, I'm going in circles. Let me look at the issue from a completely different perspective.

    Maybe the issue is NOT about the model value at all. Maybe it's about the Firefox browser specifically not updating the el.value properly when it's set during beforeUpdate while the input is focused.

    Actually, let me look at the beforeUpdate code again:

    const rootNode = el.getRootNode()
    if (
        (rootNode instanceof Document || rootNode instanceof ShadowRoot) &&
        rootNode.activeElement === el &&
        el.type !== 'range'
    ) {
        // #8546
        if (lazy && value === oldValue) {
            return
        }
        if (trim && el.value.trim() === newValue) {
            return
        }
    }
    
    el.value = newValue
    

    This code does NOT return early for a focused input (unless it's lazy or trim). So it should always set el.value = newValue.

    Wait, but what about the check at the top:

    if (elValue === newValue) {
        return
    }
    

    What if el.value is already "a" at this point? That could happen if:

    1. The v-model directive's input handler ran and set model.value = "b"
    2. Then @input handler ran and set model.value = "a"
    3. In useModel.set("a"), the local update was triggered (#10279 logic)
    4. This caused an immediate re-render/update of the v-model directive
    5. beforeUpdate ran synchronously with value = "a", and el.value was set to "a"
    6. Then later, when the parent re-renders, beforeUpdate runs again with value = "a", and el.value is already "a"

    Hmm, but step 3-5 wouldn't happen synchronously. The trigger() call in #10279 only triggers a re-render, which is batched.

    OK, let me take a completely different approach. Let me look at the issue from the Firefox perspective. What's different about Firefox's input handling?

    One key difference: Firefox fires the input event AFTER the DOM has been updated, while Chrome fires it BEFORE. Wait, no, that's not right. The spec says the input event fires after the DOM is updated.

    Actually, I think the key difference might be about how Firefox handles the caret/selection position. In Firefox, when you programmatically set el.value, the caret position might be preserved or reset differently than in Chrome. But that shouldn't cause the value to be different.

    Let me try yet another approach. Let me look at recent issues and PRs related to Firefox and v-model.Let me look at the specific behavior: when v-model and @input are both on the same <input>, the order of event listeners matters. Let me look at how Vue compiles and handles this:

  26. Assistant

    Now let me look at what the actual issue is. Let me think about the reproduction more carefully. Let me look at the playground code decoded:

    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 user types in the input, both v-model handler and @input handler fire. Let me trace through the exact flow:

  27. Assistant

    Let me now understand the exact flow in the reproduction by examining how vModelText handles value updates and how useModel interacts with it.

  28. Assistant

    Now I have a clear picture of the bug. Let me trace through the flow step by step.

    The reproduction has:

    • Comp.vue with defineModel() and <input v-model="model" @input="onInput" /> where onInput forces model.value = 'a'
    • App.vue passes v-model to Comp

    When the user types in the input (e.g., typing "b" after "a" is already shown):

    1. The v-model directive's input handler fires first (registered in created hook) → calls onUpdate:modelValue("ab") → model.value = "ab" → useModel.set("ab") → emits "ab" to parent, prevSetValue = "ab", prevEmittedValue = "ab"
    2. The @input handler fires → calls model.value = "a" → useModel.set("a")

    In useModel.set("a"):

    • emittedValue = "a", localValue = "a" (from prop sync)
    • hasChanged("a", "a") = false → early return condition checks:
      • !hasChanged(emittedValue, localValue) = true
      • prevSetValue = "ab", hasChanged("a", "ab") = true
      • So !(true && true) = false
      • Overall: true && false = false → does NOT return early → emits "a" to parent

    After both emits, parent has amount = "a". Parent re-renders with modelValue = "a". But the child's modelValue was already "a", so shouldUpdateComponent returns false, and the child doesn't re-render. el.value stays as "ab"!

    Wait, but the user says it works in Chrome. Let me check the #10279 fix more carefully and look at the specific condition that should trigger a local update...

  29. Assistant

    Now I understand the issue. Let me trace through the exact flow more carefully:

    When user types in the input, TWO event handlers fire:

    1. vModelText's handler (registered in created hook) - calls el[assignKey](el.value) → triggers useModel.set("ab")
    2. @input handler - calls model.value = 'a' → triggers useModel.set("a")

    After both set calls:

    • Parent received "ab" then "a", ending at "a" (same as before)
    • localValue is "a" (unchanged)
    • Child doesn't re-render because props haven't changed from parent's perspective
    • el.value stays "ab" in the DOM

    The fix needs to trigger a local update when the emitted value equals the local value (so parent won't trigger prop sync) but differs from the previous emission. Let me create a test to verify:

  30. Assistant

    Now let me look at shouldUpdateComponent to understand when child components are re-rendered:

  31. Assistant

    Let me look at the shouldUpdateComponent function:

  32. Assistant

    Let me understand the issue better. The problem is:

    1. User types in input with v-model="model" and @input="onInput" where onInput always sets model.value = 'a'
    2. In Firefox, the input shows what was typed instead of being forced to "a"

    Let me trace through the execution carefully:

    1. User types "b" (input was showing "a")
    2. The input event fires
    3. Two handlers fire:
      • vModelText handler (registered in created hook): reads el.value = "ab", calls el[assignKey]("ab") which triggers onUpdate:modelValue("ab") - this goes to parent's handler
      • @input handler: calls model.value = 'a' which triggers useModel.set('a')

    But wait, the onUpdate:modelValue handler on the input element is NOT useModel.set. The v-model on a native input element uses the vModelText directive, which reads the value from el.value and calls the onUpdate:modelValue handler.

    For a child component with defineModel(), the compiled template would be something like:

    h('input', {
      modelValue: model.value,
      'onUpdate:modelValue': $event => (model.value = $event),
      onInput: onInput
    }, null, PatchFlags.NEED_HYDRATION)
    

    Wait, actually for native elements, v-model compiles to a directive. Let me look at how the compiler handles it.

    Actually, for native <input v-model="model">, the compiler produces:

    • A vModelText directive with value model.value
    • An onUpdate:modelValue event handler that sets model.value = $event

    When vModelText fires its input handler, it calls el[assignKey](el.value) where assignKey is onUpdate:modelValue from the vnode props.

    So the flow is:

    1. User types "b" → el.value = "ab"
    2. input event fires
    3. vModelText handler fires: calls onUpdate:modelValue("ab") which is ($event) => (model.value = $event) → model.value = "ab" → triggers useModel.set("ab")
    4. @input handler fires: model.value = 'a' → triggers useModel.set('a')

    In useModel.set("ab"):

    • emittedValue = "ab"
    • localValue = "a" (from previous)
    • hasChanged("ab", "a") = true → continues
    • Emits update:modelValue with "ab" to parent
    • prevSetValue = "ab", prevEmittedValue = "ab"

    In useModel.set("a"):

    • emittedValue = "a"- localValue = "a" (unchanged since prop hasn't updated)
    • hasChanged("a", "a") = false
    • prevSetValue = "ab", hasChanged("a", "ab") = true
    • !hasChanged(emittedValue, localValue) && !(prevSetValue !== EMPTY_OBJ && hasChanged(value, prevSetValue))
    • = true && !(true && true) = true && false = false
    • So it does NOT return early
    • Emits update:modelValue with "a" to parent

    Now parent gets two emits: "ab" then "a". The parent's amount goes from "a" → "ab" → "a". Net result: still "a".

    Then parent re-renders with amount = "a", passes modelValue = "a" to child. The watchSyncEffect checks hasChanged(localValue, propValue) = hasChanged("a", "a") = false, so no trigger.

    But wait, the el.value is still "ab" because the browser set it. The vModelText.beforeUpdate would need to run to set el.value = "a".

    So the question is: does the component re-render? The shouldUpdateComponent would need to return true.

    Let me look at shouldUpdateComponent:

  33. Assistant

    Now I understand the issue. Let me trace through the exact flow in the reproduction:

    1. User types "b" in input showing "a" → el.value = "ab"
    2. input event fires
    3. vModelText handler fires first (registered in created hook): calls el[assignKey]("ab") → triggers useModel.set("ab") → emits "ab" to parent → amount = "ab"
    4. @input handler fires: model.value = 'a' → triggers useModel.set("a") → emits "a" to parent → amount = "a"

    After both, amount = "a" (same as before). Parent re-renders, but shouldUpdateComponent returns false because modelValue is "a" both before and after. The child doesn't re-render. el.value stays "ab" in the DOM.

    The key issue: the useModel set function doesn't trigger a local update when the emitted value is the same as the local value but was different from the previously emitted value (meaning the parent's state changed and changed back within the same tick).

    Let me look at the early return logic and the #10279 fix:

  34. Assistant

    Now I have a clear understanding. Let me first run the existing tests to make sure they pass:

  35. Assistant

    Good, all 14 existing tests pass. Now let me implement the fix. The issue is in the useModel set function. After emitting, when the emitted value equals the local value (so the parent won't trigger a prop sync) but differs from the previously emitted value (meaning the parent's state changed and changed back within the same tick), we need to force a local trigger so the child re-renders and the DOM gets synced.

  36. Assistant

    Now let me implement the fix. I need to add a condition after the #10279 check:

  37. Assistant

    Now let me add the fix:

  38. Assistant

    Let me use the edit command instead:

  39. Assistant

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

  40. Assistant

    Now let me run the existing tests to make sure they still pass:

  41. Assistant

    All 14 existing tests pass. Let me also run the defineModel compile tests:

  42. Assistant

    Good. Now let me write a test script that reproduces the exact issue from the bug report and verify the fix:

  43. Assistant

    Let me write a proper test as a standalone script to validate the fix works:

  44. Assistant

    Let me write a proper test case and run it using vitest:

  45. Assistant

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

  46. Assistant

    Let me fix the import path:

  47. Assistant

    The test passes functionally but the assertion format differs. Let me fix the test:

  48. Assistant

    The test passes with the fix. Let me verify that without the fix, this test would fail:

  49. Assistant

    Without the fix, the test fails: compRender was only called 2 times instead of 3, confirming the bug. Let me restore the fix:

  50. Assistant

    Good, the fix is restored. Let me now run ALL existing tests related to useModel and defineModel:

  51. Assistant

    All 26 tests pass. Let me also run a broader set of tests to make sure nothing else breaks:

  52. Assistant

    All 1020 tests pass across 45 test files. Let me clean up the temporary test file and also run the compiler-sfc tests:

  53. Assistant

    All tests pass. Let me now review the final state of my fix:

  54. Assistant

    The fix is clean and minimal. Let me now verify the fix one final time by checking the exact file:

  55. Assistant

    The fix is correct and clean. Let me now verify no temporary files are left and run the complete test suite one final time:

  56. Assistant

    Good, only the useModel.ts file is modified. Let me run the final comprehensive test:

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