|
@ -360,7 +360,10 @@ function genScopedSlots ( |
|
|
slots: { [key: string]: ASTElement }, |
|
|
slots: { [key: string]: ASTElement }, |
|
|
state: CodegenState |
|
|
state: CodegenState |
|
|
): string { |
|
|
): string { |
|
|
const hasDynamicKeys = Object.keys(slots).some(key => slots[key].slotTargetDynamic) |
|
|
const hasDynamicKeys = Object.keys(slots).some(key => { |
|
|
|
|
|
const slot = slots[key] |
|
|
|
|
|
return slot.slotTargetDynamic || slot.if || slot.for |
|
|
|
|
|
}) |
|
|
return `scopedSlots:_u([${ |
|
|
return `scopedSlots:_u([${ |
|
|
Object.keys(slots).map(key => { |
|
|
Object.keys(slots).map(key => { |
|
|
return genScopedSlot(key, slots[key], state) |
|
|
return genScopedSlot(key, slots[key], state) |
|
@ -373,19 +376,29 @@ function genScopedSlot ( |
|
|
el: ASTElement, |
|
|
el: ASTElement, |
|
|
state: CodegenState |
|
|
state: CodegenState |
|
|
): string { |
|
|
): string { |
|
|
|
|
|
if (el.if && !el.ifProcessed) { |
|
|
|
|
|
return genIfScopedSlot(key, el, state) |
|
|
|
|
|
} |
|
|
if (el.for && !el.forProcessed) { |
|
|
if (el.for && !el.forProcessed) { |
|
|
return genForScopedSlot(key, el, state) |
|
|
return genForScopedSlot(key, el, state) |
|
|
} |
|
|
} |
|
|
const fn = `function(${String(el.slotScope)}){` + |
|
|
const fn = `function(${String(el.slotScope)}){` + |
|
|
`return ${el.tag === 'template' |
|
|
`return ${el.tag === 'template' |
|
|
? el.if |
|
|
? genChildren(el, state) || 'undefined' |
|
|
? `(${el.if})?${genChildren(el, state) || 'undefined'}:undefined` |
|
|
|
|
|
: genChildren(el, state) || 'undefined' |
|
|
|
|
|
: genElement(el, state) |
|
|
: genElement(el, state) |
|
|
}}` |
|
|
}}` |
|
|
return `{key:${key},fn:${fn}}` |
|
|
return `{key:${key},fn:${fn}}` |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function genIfScopedSlot ( |
|
|
|
|
|
key: string, |
|
|
|
|
|
el: any, |
|
|
|
|
|
state: CodegenState |
|
|
|
|
|
): string { |
|
|
|
|
|
el.ifProcessed = true |
|
|
|
|
|
return `(${el.if})?${genScopedSlot(key, el, state)}:null` |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function genForScopedSlot ( |
|
|
function genForScopedSlot ( |
|
|
key: string, |
|
|
key: string, |
|
|
el: any, |
|
|
el: any, |
|
|