})
test('default slot outlet with props', () => {
- const ast = parseWithSlots(`<slot foo="bar" :baz="qux" />`)
+ const ast = parseWithSlots(
+ `<slot foo="bar" :baz="qux" :foo-bar="foo-bar" />`
+ )
expect((ast.children[0] as ElementNode).codegenNode).toMatchObject({
type: NodeTypes.JS_CALL_EXPRESSION,
callee: RENDER_SLOT,
content: `qux`,
isStatic: false
}
+ },
+ {
+ key: {
+ content: `fooBar`,
+ isStatic: true
+ },
+ value: {
+ content: `foo-bar`,
+ isStatic: false
+ }
}
]
}
import { buildProps, PropsExpression } from './transformElement'
import { createCompilerError, ErrorCodes } from '../errors'
import { RENDER_SLOT } from '../runtimeHelpers'
+import { camelize } from '@vue/shared/'
export const transformSlotOutlet: NodeTransform = (node, context) => {
if (isSlotOutlet(node)) {
const propsWithoutName = name
? node.props.filter(p => p !== name)
: 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
+
if (directives.length) {
context.onError(
createCompilerError(