parent
ef59a30cab
commit
7cd85be2db
@ -7,7 +7,7 @@ import {
|
|||||||
SlotOutletNode,
|
SlotOutletNode,
|
||||||
createFunctionExpression
|
createFunctionExpression
|
||||||
} from '../ast'
|
} from '../ast'
|
||||||
import { isSlotOutlet, findProp } from '../utils'
|
import { isSlotOutlet, isBindKey, isStaticExp } from '../utils'
|
||||||
import { buildProps, PropsExpression } from './transformElement'
|
import { buildProps, PropsExpression } from './transformElement'
|
||||||
import { createCompilerError, ErrorCodes } from '../errors'
|
import { createCompilerError, ErrorCodes } from '../errors'
|
||||||
import { RENDER_SLOT } from '../runtimeHelpers'
|
import { RENDER_SLOT } from '../runtimeHelpers'
|
||||||
@ -54,35 +54,32 @@ export function processSlotOutlet(
|
|||||||
let slotName: string | ExpressionNode = `"default"`
|
let slotName: string | ExpressionNode = `"default"`
|
||||||
let slotProps: PropsExpression | undefined = undefined
|
let slotProps: PropsExpression | undefined = undefined
|
||||||
|
|
||||||
// check for <slot name="xxx" OR :name="xxx" />
|
const nonNameProps = []
|
||||||
const name = findProp(node, 'name')
|
for (let i = 0; i < node.props.length; i++) {
|
||||||
if (name) {
|
const p = node.props[i]
|
||||||
if (name.type === NodeTypes.ATTRIBUTE && name.value) {
|
if (p.type === NodeTypes.ATTRIBUTE) {
|
||||||
// static name
|
if (p.value) {
|
||||||
slotName = JSON.stringify(name.value.content)
|
if (p.name === 'name') {
|
||||||
} else if (name.type === NodeTypes.DIRECTIVE && name.exp) {
|
slotName = JSON.stringify(p.value.content)
|
||||||
// dynamic name
|
} else {
|
||||||
slotName = name.exp
|
p.name = camelize(p.name)
|
||||||
|
nonNameProps.push(p)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (p.name === 'bind' && isBindKey(p.arg, 'name')) {
|
||||||
|
if (p.exp) slotName = p.exp
|
||||||
|
} else {
|
||||||
|
if (p.name === 'bind' && p.arg && isStaticExp(p.arg)) {
|
||||||
|
p.arg.content = camelize(p.arg.content)
|
||||||
|
}
|
||||||
|
nonNameProps.push(p)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const propsWithoutName = name
|
if (nonNameProps.length > 0) {
|
||||||
? node.props.filter(p => p !== name)
|
const { props, directives } = buildProps(node, context, nonNameProps)
|
||||||
: node.props
|
|
||||||
|
|
||||||
if (propsWithoutName.length > 0) {
|
|
||||||
//#2488
|
|
||||||
propsWithoutName.forEach(prop => {
|
|
||||||
if (
|
|
||||||
prop.type === NodeTypes.DIRECTIVE &&
|
|
||||||
prop.arg &&
|
|
||||||
prop.arg.type === NodeTypes.SIMPLE_EXPRESSION
|
|
||||||
) {
|
|
||||||
prop.arg.content = camelize(prop.arg.content)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const { props, directives } = buildProps(node, context, propsWithoutName)
|
|
||||||
slotProps = props
|
slotProps = props
|
||||||
|
|
||||||
if (directives.length) {
|
if (directives.length) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user