Skip to content

Conversation

@edison1105
Copy link
Member

@edison1105 edison1105 commented Jan 27, 2026

close #14361

Summary by CodeRabbit

  • Bug Fixes
    • Improved stability of event handler modifiers by gracefully handling null or undefined values, preventing errors and ensuring consistent behavior in edge cases.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

This PR fixes a bug where undefined event handlers with modifiers in loops cause rendering errors. The solution adds an early guard in withModifiers to return falsy handlers unchanged, plus test cases verifying the graceful handling.

Changes

Cohort / File(s) Summary
Event Handler Modifier Guard
packages/runtime-dom/src/directives/vOn.ts
Added early return guard if (!fn) return fn to short-circuit withModifiers when handler is null/undefined, preventing cache initialization and function wrapping
Event Handler Modifier Tests
packages/runtime-dom/__tests__/directives/vOn.spec.ts
Added test cases verifying withModifiers gracefully handles null (returns null) and undefined (returns undefined) handler inputs without throwing

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Suggested labels

ready to merge, :hammer: p3-minor-bug

Suggested reviewers

  • KazariEX

Poem

A guard in the flow, so simple and neat,
Falsy handlers now face defeat! 🐰
No more crashes in loops divine,
With undefined tamed, all tests align! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 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: adding a guard to handle null/undefined handlers in withModifiers, which directly addresses the PR's primary objective.
Linked Issues check ✅ Passed The PR implements the required fix by adding an early guard in withModifiers to handle null/undefined handlers, directly addressing issue #14361 and matching the expected behavior from similar issue #9865.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the null/undefined handler issue in withModifiers; the test case and runtime guard are both in scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings

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

@github-actions
Copy link

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 103 kB (+15 B) 39.1 kB (+6 B) 35.2 kB (+14 B)
vue.global.prod.js 161 kB (+15 B) 59.1 kB (+6 B) 52.6 kB (+65 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 47 kB 18.4 kB 16.8 kB
createApp 55.1 kB 21.4 kB 19.6 kB
createSSRApp 59.4 kB 23.2 kB 21.1 kB
defineCustomElement 60.8 kB 23.1 kB 21.1 kB
overall 69.5 kB 26.7 kB 24.3 kB

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 27, 2026

Open in StackBlitz

@vue/compiler-core

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

@vue/compiler-dom

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

@vue/compiler-sfc

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

@vue/compiler-ssr

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

@vue/reactivity

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

@vue/runtime-core

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

@vue/runtime-dom

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

@vue/server-renderer

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

@vue/shared

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

vue

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

@vue/compat

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

commit: c88267b

@edison1105 edison1105 added ready to merge The PR is ready to be merged. 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. labels Jan 27, 2026
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add undefined handler to event with modifier in loop will cause error

2 participants