-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
fix(compiler): ensure consistent treatment of comment nodes in default slots #9663
base: main
Are you sure you want to change the base?
Conversation
Size ReportBundles
Usages
|
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
❌ Deploy Preview for vue-next-template-explorer failed.
|
If I've understood correctly... Currently, both of these examples would pass a comment VNode via the default slot: <MyChild>
<!-- foo -->
</MyChild> <MyChild>
<template v-slot>
<!-- foo -->
</template>
</MyChild> Whereas this example would discard the comment and wouldn't pass a default slot function at all: <MyChild>
<!-- foo -->
<template #bar></template>
</MyChild> Adding other content, say a <MyChild>
<!-- foo -->
<div />
<template #bar></template>
</MyChild> The proposal in this PR is to retain the comment in all cases, though the usual rules around stripping comments and I don't know which is better. On the one hand, the current behaviour seems inconsistent. As far as I'm aware, this magical stripping of comments is undocumented. There's an easy workaround, by using an explicit On the other hand, it's easy to imagine someone putting in a comment before a I think I prefer the proposal in this PR, but it isn't clear cut for me. |
commit: @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
|
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
This pr resolves an inconsistency in the logic for handling default slots in
packages/compiler-core/src/transforms/vSlot.ts
. Previously, when<template v-slot>
was used in any component slot, comment nodes were inadvertently filtered out. Conversely, in the absence of<template v-slot>
, comment nodes were retained in the default slot. Playground.The behavior is now unified to consistently retain comment nodes in the default slot, regardless of the presence of
<template v-slot>
.Additionally, new unit tests have been added to cover scenarios involving comment nodes in default slots.
Relates to #9655