Skip to content

fix(slots): refine internal key checking logic #13612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

edison1105
Copy link
Member

@edison1105 edison1105 commented Jul 10, 2025

close #13611

Summary by CodeRabbit

  • Refactor
    • Refined internal key recognition to a specific set of keys for improved slot handling.
  • Tests
    • Enhanced slot tests to verify rendering of slots with underscore-prefixed names and normalized slot values.

Copy link

coderabbitai bot commented Jul 10, 2025

Walkthrough

The isInternalKey function in componentSlots.ts was changed to explicitly check for the keys '_', '__', '_ctx', and '$stable' instead of any key starting with an underscore or equal to '$stable'. The test suite was updated to verify that slots with names starting with an underscore (e.g., _foo) are rendered correctly.

Changes

File(s) Change Summary
packages/runtime-core/src/componentSlots.ts Changed isInternalKey to explicitly check keys '_', '__', '_ctx', and '$stable' only.
packages/runtime-core/tests/componentSlots.spec.ts Added tests to confirm slots with names starting with underscore render correctly and updated warnings/assertions for _inner slot.

Sequence Diagram(s)

sequenceDiagram
    participant ParentComponent
    participant isInternalKey
    participant assignSlots
    participant ChildComponent

    ParentComponent->>assignSlots: Provide slot keys (including keys starting with '_')
    assignSlots->>isInternalKey: Check if key is internal (only '_', '__', '_ctx', '$stable')
    isInternalKey-->>assignSlots: Return true/false
    assignSlots->>ChildComponent: Assign slots excluding only internal keys
Loading

Possibly related PRs

Suggested labels

ready to merge, :exclamation: p4-important

Poem

🐇
A slot once lost in underscore's shade,
Now shines again, no longer delayed.
Keys once hidden, now come to light,
Rendering slots just right, in sight.
With careful checks and tests aligned,
The rabbit hops, code redefined!
✨🐰


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 95e4120 and 4139e22.

📒 Files selected for processing (2)
  • packages/runtime-core/__tests__/componentSlots.spec.ts (4 hunks)
  • packages/runtime-core/src/componentSlots.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/runtime-core/src/componentSlots.ts
🔇 Additional comments (4)
packages/runtime-core/__tests__/componentSlots.spec.ts (4)

9-9: LGTM! Import addition is appropriate.

The serializeInner import is correctly added and used in the new test case to verify rendered output.


78-80: LGTM! Warning expectation correctly added for _inner slot.

The warning expectation aligns with the behavior change where _inner slots are now treated as regular slots instead of internal keys, triggering the non-function value warning.


91-91: LGTM! Assertion correctly updated to reflect new behavior.

The assertion properly validates that _inner slots are now accessible and return the expected normalized vnode, confirming the fix to internal key checking logic.


451-467: LGTM! New test case effectively validates the core fix.

This test case properly verifies that slots with underscore-prefixed names (like _foo) are now correctly rendered instead of being treated as internal keys. The test structure is consistent with existing patterns and provides clear validation of the refined internal key checking logic.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Jul 10, 2025

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 101 kB (+19 B) 38.4 kB (+7 B) 34.6 kB (+70 B)
vue.global.prod.js 159 kB (+19 B) 58.5 kB (+7 B) 52.1 kB (+46 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 46.5 kB (+19 B) 18.2 kB (+6 B) 16.7 kB (+5 B)
createApp 54.5 kB (+19 B) 21.2 kB (+6 B) 19.4 kB (+10 B)
createSSRApp 58.7 kB (+19 B) 22.9 kB (+4 B) 20.9 kB (+3 B)
defineCustomElement 59.5 kB (+19 B) 22.8 kB (+5 B) 20.8 kB (+58 B)
overall 68.6 kB (+19 B) 26.4 kB (+9 B) 24 kB (-6 B)

Copy link

pkg-pr-new bot commented Jul 10, 2025

Open in StackBlitz

@vue/compiler-core

npm i https://pkg.pr.new/@vue/compiler-core@13612

@vue/compiler-dom

npm i https://pkg.pr.new/@vue/compiler-dom@13612

@vue/compiler-sfc

npm i https://pkg.pr.new/@vue/compiler-sfc@13612

@vue/compiler-ssr

npm i https://pkg.pr.new/@vue/compiler-ssr@13612

@vue/reactivity

npm i https://pkg.pr.new/@vue/reactivity@13612

@vue/runtime-core

npm i https://pkg.pr.new/@vue/runtime-core@13612

@vue/runtime-dom

npm i https://pkg.pr.new/@vue/runtime-dom@13612

@vue/server-renderer

npm i https://pkg.pr.new/@vue/server-renderer@13612

@vue/shared

npm i https://pkg.pr.new/@vue/shared@13612

vue

npm i https://pkg.pr.new/vue@13612

@vue/compat

npm i https://pkg.pr.new/@vue/compat@13612

commit: 4139e22

@edison1105 edison1105 marked this pull request as draft July 10, 2025 14:39
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 347ef1d and 95e4120.

📒 Files selected for processing (1)
  • packages/runtime-core/src/componentSlots.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Redirect rules
  • GitHub Check: Header rules
  • GitHub Check: Pages changed

@edison1105 edison1105 changed the title fix(slots): refine condition to avoid copying compile marker fix(slots): refine internal key checking logic Jul 18, 2025
@edison1105 edison1105 marked this pull request as ready for review July 18, 2025 14:27
@edison1105
Copy link
Member Author

/ecosystem-ci run

@vue-bot
Copy link
Contributor

vue-bot commented Jul 18, 2025

📝 Ran ecosystem CI: Open

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

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.

Slot <template> not working when its name starts with an underscore (_) since v3.5.14
2 participants