Skip to content

refactor(compiler-vapor): Should perform safety check for simple expressions in events.#14815

Closed
jackma9604 wants to merge 1 commit into
vuejs:minorfrom
jackma9604:refactor/vOn
Closed

refactor(compiler-vapor): Should perform safety check for simple expressions in events.#14815
jackma9604 wants to merge 1 commit into
vuejs:minorfrom
jackma9604:refactor/vOn

Conversation

@jackma9604
Copy link
Copy Markdown

This adjustment is made to maintain consistency with the behavior of simple expressions for events in vdom mode.

html
<button @click="onClick">Button</button>

vdom after compilation
onClick: _cache[0] || (_cache[0] = (...args) => (_ctx.onClick && _ctx.onClick(...args)))

vapor after compilation
n0.$evtclick = _createInvoker(e => _ctx.onClick(e))

If onClick is not defined, an error will occur after the click event

_ctx.onClick is not a function

Adjusted vapor compilation result
n0.$evtclick = _createInvoker(e => (_ctx.onClick && _ctx.onClick(e)))

see: Playground

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 549a80aa-7c25-41d6-840a-5123a608bf25

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 14, 2026

Open in StackBlitz

@vue/compiler-core

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

@vue/compiler-dom

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

@vue/compiler-sfc

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

@vue/compiler-ssr

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

@vue/compiler-vapor

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

@vue/reactivity

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

@vue/runtime-core

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

@vue/runtime-dom

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

@vue/runtime-vapor

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

@vue/server-renderer

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

@vue/shared

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

vue

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

@vue/compat

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

commit: 3c5244c

@github-actions
Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
compiler-dom.global.prod.js 86.5 kB 30.3 kB 26.6 kB
runtime-dom.global.prod.js 113 kB 42.6 kB 38.1 kB
vue.global.prod.js 172 kB 62.4 kB 55.6 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 51.5 kB 20.1 kB 18.3 kB
createApp 60.5 kB 23.4 kB 21.3 kB
createApp + vaporInteropPlugin 103 kB 37.2 kB 33.6 kB
createVaporApp 27.6 kB 10.7 kB 9.83 kB
createSSRApp 65 kB 25.2 kB 22.9 kB
createVaporSSRApp 33.8 kB 12.8 kB 11.8 kB
defineCustomElement 67.1 kB 25.4 kB 23.1 kB
defineVaporCustomElement 40.3 kB 14.3 kB 13.2 kB
overall 75.8 kB 28.9 kB 26.2 kB

@edison1105
Copy link
Copy Markdown
Member

Thanks for this PR, but I don't think this is necessary.

VDOM needs fn && fn(...args) because cacheHandlers caches the handler wrapper. If it cached _ctx.onClick directly, later changes to onClick would not be reflected, so the wrapper has to read the latest _ctx.onClick at call time. The && also preserves the nullable-handler behavior.

Vapor does not need this because it does not have the same cacheHandlers / props patching problem here. The generated event invoker can call the handler directly. If @click="onClick" points to an undefined method, that should surface as a user error instead of being silently ignored.

@edison1105 edison1105 closed this May 14, 2026
@jackma9604 jackma9604 deleted the refactor/vOn branch May 14, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants