Skip to content

fix(slots): refine condition to avoid copying compile marker #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

Draft
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
    • Updated the criteria for excluding certain keys during slot assignment, now only excluding the '_' and '__' keys. This change may affect how custom slot keys are handled.

Copy link

coderabbitai bot commented Jul 10, 2025

Walkthrough

The assignSlots function in componentSlots.ts has been updated to change the exclusion logic for slot keys. Instead of excluding all keys starting with an underscore or named $stable, it now only excludes the keys '_' and '__', allowing slot names that start with an underscore.

Changes

File(s) Change Summary
packages/runtime-core/src/componentSlots.ts Modified assignSlots function to only exclude '_' and '__' keys, allowing others with _.

Sequence Diagram(s)

sequenceDiagram
    participant ParentComponent
    participant assignSlots
    participant ChildComponent

    ParentComponent->>assignSlots: Provide children slot keys (some starting with '_')
    assignSlots->>assignSlots: Exclude only '_' and '__' keys
    assignSlots->>ChildComponent: Assign allowed slot keys (including those starting with '_')
Loading

Assessment against linked issues

Objective Addressed Explanation
Allow slot <template> names starting with underscore to work as before (Issue #13611)
Restore slot assignment behavior to match v3.5.13 for keys starting with underscore (#13611)

Suggested labels

ready to merge, :exclamation: p4-important

Poem

A bunny hopped and fixed a slot,
Where underscores were once forgot.
Now templates named with sneaky lines,
Will render fine in all designs.
With code so neat and logic clear,
The rabbit cheers: "Your slots appear!"
🐇✨

✨ 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

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 101 kB (+11 B) 38.4 kB (+1 B) 34.6 kB (+13 B)
vue.global.prod.js 159 kB (+11 B) 58.5 kB (+1 B) 52.1 kB (+17 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 46.5 kB (+11 B) 18.2 kB (+5 B) 16.7 kB (-1 B)
createApp 54.5 kB (+11 B) 21.2 kB (+6 B) 19.4 kB (+7 B)
createSSRApp 58.7 kB (+11 B) 22.9 kB (+4 B) 20.9 kB (+10 B)
defineCustomElement 59.5 kB (+11 B) 22.8 kB (+4 B) 20.8 kB (-7 B)
overall 68.6 kB (+11 B) 26.4 kB (+5 B) 24 kB (-4 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: 95e4120

@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

@@ -180,7 +180,7 @@ const assignSlots = (
// when rendering the optimized slots by manually written render function,
// do not copy the `slots._` compiler flag so that `renderSlot` creates
// slot Fragment with BAIL patchFlag to force full updates
if (optimized || !isInternalKey(key)) {
if (optimized || (key !== '_' && key !== '__')) {
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Good refinement of the exclusion logic, but verify the $stable key handling.

The change correctly narrows the exclusion to only the specific internal markers '_' and '__' instead of all keys starting with underscore. This allows legitimate slot names that start with underscore to be copied, which aligns with the PR objective.

However, the previous logic also excluded $stable, but the new logic doesn't. Verify if this is intentional, as $stable is used as a manual render function hint and excluding it might be important for correct slot behavior.


🏁 Script executed:

#!/bin/bash
# Description: Check if $stable key handling is addressed elsewhere or if this is an intentional change
# Expected: Find usage patterns of $stable key in slot-related code

# Search for $stable usage in the codebase
rg -A 5 -B 5 '\$stable' --type ts

# Search for related issue #13611 to understand the context
rg -A 10 -B 10 '13611' --type ts --type js --type md

Length of output: 7655


🏁 Script executed:

#!/bin/bash
# Display the assignSlots implementation to verify how non-function entries are handled
sed -n '140,300p' packages/runtime-core/src/componentSlots.ts

Length of output: 3810


Exclude $stable in assignSlots to prevent copying an internal flag.

The current condition in packages/runtime-core/src/componentSlots.ts only skips the compiler markers _ and __, but will copy the $stable property from children into the public slots object. This internal flag shouldn’t be exposed as a slot.

• File: packages/runtime-core/src/componentSlots.ts
• Function: assignSlots (around line 183)
• Suggestion: update the if condition to also exclude $stable.

Proposed diff:

- if (optimized || (key !== '_' && key !== '__')) {
+ if (optimized || (key !== '_' && key !== '__' && key !== '$stable')) {
    slots[key] = children[key]
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (optimized || (key !== '_' && key !== '__')) {
if (optimized || (key !== '_' && key !== '__' && key !== '$stable')) {
slots[key] = children[key]
}
🤖 Prompt for AI Agents
In packages/runtime-core/src/componentSlots.ts at line 183, the if condition
currently excludes keys '_' and '__' but does not exclude the internal flag
'$stable'. Update the condition to also exclude '$stable' by adding a check that
skips keys equal to '$stable' to prevent copying this internal property into the
public slots object.

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
1 participant