wip: exclude legacy slots from $scopedSlots
This commit is contained in:
@@ -352,6 +352,11 @@ export interface FunctionExpression extends Node {
|
||||
* withScopeId() wrapper
|
||||
*/
|
||||
isSlot: boolean
|
||||
/**
|
||||
* __COMPAT__ only, indicates a slot function that should be excluded from
|
||||
* the legacy $scopedSlots instance property.
|
||||
*/
|
||||
isNonScopedSlot?: boolean
|
||||
}
|
||||
|
||||
export interface ConditionalExpression extends Node {
|
||||
|
||||
@@ -878,6 +878,9 @@ function genFunctionExpression(
|
||||
push(`}`)
|
||||
}
|
||||
if (isSlot) {
|
||||
if (__COMPAT__ && node.isNonScopedSlot) {
|
||||
push(`, undefined, true`)
|
||||
}
|
||||
push(`)`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,11 +129,6 @@ export function buildSlots(
|
||||
const slotsProperties: Property[] = []
|
||||
const dynamicSlots: (ConditionalExpression | CallExpression)[] = []
|
||||
|
||||
const buildDefaultSlotProperty = (
|
||||
props: ExpressionNode | undefined,
|
||||
children: TemplateChildNode[]
|
||||
) => createObjectProperty(`default`, buildSlotFn(props, children, loc))
|
||||
|
||||
// If the slot is inside a v-for or another v-slot, force it to be dynamic
|
||||
// since it likely uses a scope variable.
|
||||
let hasDynamicSlots = context.scopes.vSlot > 0 || context.scopes.vFor > 0
|
||||
@@ -302,6 +297,17 @@ export function buildSlots(
|
||||
}
|
||||
|
||||
if (!onComponentSlot) {
|
||||
const buildDefaultSlotProperty = (
|
||||
props: ExpressionNode | undefined,
|
||||
children: TemplateChildNode[]
|
||||
) => {
|
||||
const fn = buildSlotFn(props, children, loc)
|
||||
if (__COMPAT__) {
|
||||
fn.isNonScopedSlot = true
|
||||
}
|
||||
return createObjectProperty(`default`, fn)
|
||||
}
|
||||
|
||||
if (!hasTemplateSlots) {
|
||||
// implicit default slot (on component)
|
||||
slotsProperties.push(buildDefaultSlotProperty(undefined, children))
|
||||
|
||||
Reference in New Issue
Block a user