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
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/runtime-core/src/componentSlots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.

slots[key] = children[key]
}
}
Expand Down