feat(compiler): handle conditional v-slot

This commit is contained in:
Evan You
2019-10-02 17:18:11 -04:00
parent e90b83600a
commit 3d14265102
9 changed files with 187 additions and 62 deletions

View File

@@ -16,6 +16,7 @@ import { isString, isArray } from '@vue/shared'
import { CompilerError, defaultOnError } from './errors'
import { TO_STRING, COMMENT, CREATE_VNODE, FRAGMENT } from './runtimeConstants'
import { createBlockExpression } from './utils'
import { isVSlot } from './transforms/vSlot'
// There are two types of transforms:
//
@@ -311,6 +312,11 @@ export function createStructuralDirectiveTransform(
return (node, context) => {
if (node.type === NodeTypes.ELEMENT) {
const { props } = node
// structural directive transforms are not concerned with slots
// as they are handled separately in vSlot.ts
if (node.tagType === ElementTypes.TEMPLATE && props.some(isVSlot)) {
return
}
const exitFns = []
for (let i = 0; i < props.length; i++) {
const prop = props[i]