Skip to content

fix(runtime-core): force model update when reverted before sync (fix #13524)#14897

Merged
edison1105 merged 3 commits into
vuejs:mainfrom
liulinboyi:fix-13524
Jun 11, 2026
Merged

fix(runtime-core): force model update when reverted before sync (fix #13524)#14897
edison1105 merged 3 commits into
vuejs:mainfrom
liulinboyi:fix-13524

Conversation

@liulinboyi

@liulinboyi liulinboyi commented May 31, 2026

Copy link
Copy Markdown
Member

fix #13524 defineModel on Firefox does not work as expected

Summary by CodeRabbit

  • Bug Fixes

    • Improved model handling during rapid consecutive input events so local input values stay consistent when an intermediate value is reverted before parent updates apply.
  • Tests

    • Added a test verifying model behavior and render counts when an intermediate model value is reverted prior to parent update propagation.

@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c84e7957-883a-4c15-b95d-33455017f5ba

📥 Commits

Reviewing files that changed from the base of the PR and between 10c80c8 and 5736a04.

📒 Files selected for processing (1)
  • packages/runtime-core/src/helpers/useModel.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/runtime-core/src/helpers/useModel.ts

📝 Walkthrough

Walkthrough

Expands useModel.set to detect a microtask-ordering edge where an intermediate emitted value is reverted before parent prop updates flush; adds a test reproducing the rapid onModelInput→onInput sequence and asserting post-nextTick stability.

Changes

useModel microtask timing

Layer / File(s) Summary
useModel setter microtask edge case
packages/runtime-core/src/helpers/useModel.ts
Refactors parent v-model detection into a computed hasVModel and expands the forced-local-update predicate to also trigger when the value changed since the previous set but the emitted value still equals the current local value, ensuring DOM resync in microtask-timing reversion scenarios.
Microtask reversion test case
packages/runtime-core/__tests__/helpers/useModel.spec.ts
Adds test #13524 that mounts a parent/child useModel setup, quickly emits onModelInput then onInput to revert an intermediate value, and asserts that after nextTick the model, DOM, and render counts are stable and as expected.

Sequence Diagram

sequenceDiagram
  participant Parent
  participant Child
  participant useModel
  participant DOM

  Parent->>Child: pass modelValue (initial)
  Child->>useModel: mount with modelValue
  useModel->>DOM: render initial

  Note over Child,useModel: rapid listener sequence (microtask ordering)
  Child->>useModel: onModelInput(intermediate)
  useModel->>Parent: emit update: intermediate
  useModel->>DOM: schedule local update (intermediate)

  Child->>useModel: onInput(revert to initial)
  useModel->>Parent: emit update: initial
  useModel->>DOM: schedule local update (initial)

  Note over useModel,Parent: parent prop may still be initial (no flushed update)
  useModel->>useModel: detect changed vs prevSetValue && emittedValue == localValue
  useModel->>DOM: force trigger() to ensure DOM sync
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Microtasks leapt and values twirled,
A blink, a revert, the DOM unfurled,
I nudge a trigger, steady the race,
Now useModel keeps its rightful place.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing a model update issue when a value is reverted before synchronization, directly addressing issue #13524.
Linked Issues check ✅ Passed The PR adds a test case and fixes the useModel logic to handle a specific timing scenario where an intermediate model value is reverted before parent updates flush, directly addressing the Firefox defineModel issue in #13524.
Out of Scope Changes check ✅ Passed All changes are focused on fixing the defineModel timing issue: a new test verifying the revert behavior and modifications to useModel logic to force updates in the specific revert scenario.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented May 31, 2026

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 106 kB (+29 B) 40.1 kB (+15 B) 36 kB (-24 B)
vue.global.prod.js 164 kB (+29 B) 60.1 kB (+17 B) 53.4 kB (-45 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 48.8 kB 19 kB 17.4 kB
createApp 56.9 kB 22 kB 20.1 kB
createSSRApp 61.2 kB 23.8 kB 21.7 kB
defineCustomElement 63.1 kB 23.9 kB 21.8 kB
overall 71.7 kB 27.4 kB 25 kB

@pkg-pr-new

pkg-pr-new Bot commented May 31, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@14897
npm i https://pkg.pr.new/@vue/compiler-core@14897
yarn add https://pkg.pr.new/@vue/compiler-core@14897.tgz

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@14897
npm i https://pkg.pr.new/@vue/compiler-dom@14897
yarn add https://pkg.pr.new/@vue/compiler-dom@14897.tgz

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@14897
npm i https://pkg.pr.new/@vue/compiler-sfc@14897
yarn add https://pkg.pr.new/@vue/compiler-sfc@14897.tgz

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@14897
npm i https://pkg.pr.new/@vue/compiler-ssr@14897
yarn add https://pkg.pr.new/@vue/compiler-ssr@14897.tgz

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@14897
npm i https://pkg.pr.new/@vue/reactivity@14897
yarn add https://pkg.pr.new/@vue/reactivity@14897.tgz

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@14897
npm i https://pkg.pr.new/@vue/runtime-core@14897
yarn add https://pkg.pr.new/@vue/runtime-core@14897.tgz

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@14897
npm i https://pkg.pr.new/@vue/runtime-dom@14897
yarn add https://pkg.pr.new/@vue/runtime-dom@14897.tgz

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@14897
npm i https://pkg.pr.new/@vue/server-renderer@14897
yarn add https://pkg.pr.new/@vue/server-renderer@14897.tgz

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@14897
npm i https://pkg.pr.new/@vue/shared@14897
yarn add https://pkg.pr.new/@vue/shared@14897.tgz

vue

pnpm add https://pkg.pr.new/vue@14897
npm i https://pkg.pr.new/vue@14897
yarn add https://pkg.pr.new/vue@14897.tgz

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@14897
npm i https://pkg.pr.new/@vue/compat@14897
yarn add https://pkg.pr.new/@vue/compat@14897.tgz

commit: 5736a04

@edison1105

Copy link
Copy Markdown
Member

/ecosystem-ci run

@vue-bot

vue-bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

📝 Ran ecosystem CI: Open

suite result latest scheduled
pinia success success
language-tools success success
router success success
vitepress success success
test-utils success success
vue-i18n success success
nuxt success success
vueuse success success
primevue success success
vuetify success success
vant success success
radix-vue failure failure
quasar success success
vue-simple-compiler success success
vite-plugin-vue success success
vue-macros success success

@edison1105 edison1105 added ready to merge The PR is ready to be merged. scope: v-model 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. labels Jun 4, 2026
@edison1105 edison1105 merged commit 7f76378 into vuejs:main Jun 11, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. ready to merge The PR is ready to be merged. scope: v-model

Projects

None yet

Development

Successfully merging this pull request may close these issues.

defineModel on Firefox does not work as expected

3 participants