-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe Changes
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 '_')
Assessment against linked issues
Suggested labels
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
There was a problem hiding this 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
📒 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 !== '__')) { |
There was a problem hiding this comment.
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.
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.
close #13611
Summary by CodeRabbit
'_'
and'__'
keys. This change may affect how custom slot keys are handled.