Skip to content

Conversation

Copy link

Copilot AI commented Nov 14, 2025

Slot content in Vapor components was referencing the wrong component instance, breaking features like inject/provide, template refs, and scoped IDs.

Changes

  • Added withVaporCtx helper in runtime-vapor/src/componentSlots.ts to capture and restore the correct currentInstance when slot functions execute
  • Updated compiler to wrap all slot functions with withVaporCtx() in compiler-vapor/src/generators/component.ts
  • Handles currentSlotConsumer to maintain proper parent-child relationships in forwarded slots scenarios

This mirrors the withCtx pattern used in the standard Vue runtime for the same purpose.

Example

// Slot function is now wrapped to preserve instance context
const slot = withVaporCtx(() => {
  // currentInstance is correctly set to slot owner
  const value = inject('key') // Works correctly
  return createElements()
})

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@coderabbitai
Copy link

coderabbitai bot commented Nov 14, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

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


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

Copilot AI changed the title [WIP] Fix parent instance handling for slotted content fix(runtime-vapor): preserve correct parent instance for slotted content Nov 14, 2025
Copilot AI requested a review from edison1105 November 14, 2025 03:45
Copilot finished work on behalf of edison1105 November 14, 2025 03:45
@edison1105 edison1105 closed this Nov 14, 2025
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