fix(runtime-vapor): guard VaporSlot when vnode.vs is undefined#14779
fix(runtime-vapor): guard VaporSlot when vnode.vs is undefined#14779edison1105 merged 2 commits intovuejs:minorfrom
Conversation
Vapor/VDOM interop could leave slot vnodes without vapor slot metadata, causing renderVaporSlot to throw when destructuring vnode.vs. - Return empty block when vnode.vs.slot is missing - Remount slot when either side lacks vs or slot fn changes - Add regression test (nuxt/ui #6395) Co-authored-by: Cursor <cursoragent@cursor.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/compiler-vapor
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/runtime-vapor
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
Size ReportBundles
Usages
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/runtime-vapor/__tests__/vdomInterop.spec.ts (1)
3645-3668: ⚡ Quick winReactive update errors aren't surfaced to the test runner — add an
errorHandlercheck.Vue routes component re-render errors through
app.config.errorHandlerrather than throwing them into the test's async context. As written, if the update path (triggered bytick.value++) causes an error, the test still passes becauseawait nextTick()resolves normally androot.childNodes.length > 0is satisfied by the anchor text node.🛡️ Suggested fix to make the update-path regression detectable
const root = document.createElement('div') const app = createApp(App) app.use(vaporInteropPlugin) + const errorHandler = vi.fn() + app.config.errorHandler = errorHandler expect(() => app.mount(root)).not.toThrow() tick.value++ await nextTick() expect(root.childNodes.length).toBeGreaterThan(0) + expect(errorHandler).not.toHaveBeenCalled() + app.unmount()🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/runtime-vapor/__tests__/vdomInterop.spec.ts` around lines 3645 - 3668, The test mounts App and advances reactive state but misses errors routed through Vue's app.config.errorHandler; update the test to set app.config.errorHandler to a handler that fails the test (e.g., capture and rethrow or store and throw after nextTick) before calling app.mount(root) so any errors during the update path (triggered by tick.value++ / nextTick) are surfaced; reference the test block that defines tick, App (which returns createVNode(VaporSlot, {})), app.use(vaporInteropPlugin), app.mount(root) and nextTick to locate where to install the errorHandler.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/runtime-vapor/__tests__/vdomInterop.spec.ts`:
- Around line 3645-3668: The test mounts App and advances reactive state but
misses errors routed through Vue's app.config.errorHandler; update the test to
set app.config.errorHandler to a handler that fails the test (e.g., capture and
rethrow or store and throw after nextTick) before calling app.mount(root) so any
errors during the update path (triggered by tick.value++ / nextTick) are
surfaced; reference the test block that defines tick, App (which returns
createVNode(VaporSlot, {})), app.use(vaporInteropPlugin), app.mount(root) and
nextTick to locate where to install the errorHandler.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5d00f98d-e1bf-4e41-aa82-7627ba086dbd
📒 Files selected for processing (2)
packages/runtime-vapor/__tests__/vdomInterop.spec.tspackages/runtime-vapor/src/vdomInterop.ts
Fixes a runtime error when Vapor/VDOM interop leaves
VaporSlotvnodes without vapor slot metadata (vnode.vs/ missing slot function), e.g. when using VDOM component libraries (Nuxt UI) from Vapor parents (nuxt/ui#6395).renderVaporSlotwhenvnode.vsorvnode.vs.slotis missing, before resolving interop slot statevsor the slot function changesMade with Cursor
Summary by CodeRabbit
Bug Fixes
Tests