-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
fix(compiler-core): prevent comments from blocking static node hoisting #13345
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
Changes from 1 commit
f6ec77a
07bb18c
fdbb624
87afe4b
7a45fd7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,20 +41,19 @@ export function cacheStatic(root: RootNode, context: TransformContext): void { | |
context, | ||
// Root node is unfortunately non-hoistable due to potential parent | ||
// fallthrough attributes. | ||
isSingleElementRoot(root, root.children[0]), | ||
!!getSingleElementRoot(root), | ||
) | ||
} | ||
|
||
export function isSingleElementRoot( | ||
export function getSingleElementRoot( | ||
root: RootNode, | ||
child: TemplateChildNode, | ||
): child is PlainElementNode | ComponentNode | TemplateNode { | ||
const { children } = root | ||
return ( | ||
children.length === 1 && | ||
child.type === NodeTypes.ELEMENT && | ||
!isSlotOutlet(child) | ||
) | ||
): PlainElementNode | ComponentNode | TemplateNode | null { | ||
const children = root.children.filter(x => x.type !== NodeTypes.COMMENT) | ||
return children.length === 1 && | ||
children[0].type === NodeTypes.ELEMENT && | ||
!isSlotOutlet(children[0]) | ||
? children[0] | ||
: null | ||
} | ||
Comment on lines
+48
to
57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Key implementation change to filter out comment nodes. This is the core change that fixes issue #13344. The new
This ensures that static prop hoisting works correctly even when comment nodes are present, which addresses the fallthrough attributes issue in the PR description. While thoroughly filtering out all comment nodes is correct for this specific use case (hoisting static props), ensure that this doesn't break any other functionality that might rely on comments being processed. The test case appropriately verifies that the comment node is still present in the final output. The implementation is clean and well-focused on the specific issue being fixed. 🤖 Prompt for AI Agents
|
||
|
||
function walk( | ||
|
Uh oh!
There was an error while loading. Please reload this page.