|
|
@@ -2,12 +2,9 @@ import {
|
|
|
type ElementNode,
|
|
|
type AttributeNode,
|
|
|
NodeTypes,
|
|
|
- ErrorCodes,
|
|
|
- createCompilerError,
|
|
|
ElementTypes,
|
|
|
- createSimpleExpression,
|
|
|
} from '@vue/compiler-dom'
|
|
|
-import { camelize, isBuiltInDirective, isVoidTag } from '@vue/shared'
|
|
|
+import { isBuiltInDirective, isVoidTag } from '@vue/shared'
|
|
|
import { NodeTransform, TransformContext } from '../transform'
|
|
|
import { VaporDirectiveNode, IRNodeTypes } from '../ir'
|
|
|
|
|
|
@@ -69,54 +66,17 @@ function transformProp(
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- let { arg, exp, loc } = prop
|
|
|
const directiveTransform = context.options.directiveTransforms[name]
|
|
|
if (directiveTransform) {
|
|
|
directiveTransform(prop, node, context)
|
|
|
} else if (!isBuiltInDirective(name)) {
|
|
|
+ // custom directive
|
|
|
context.registerOperation({
|
|
|
type: IRNodeTypes.WITH_DIRECTIVE,
|
|
|
element: context.reference(),
|
|
|
name,
|
|
|
- binding: exp,
|
|
|
+ binding: prop.exp,
|
|
|
loc: prop.loc,
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
- switch (name) {
|
|
|
- case 'bind': {
|
|
|
- if (!arg) {
|
|
|
- // TODO support v-bind="{}"
|
|
|
- return
|
|
|
- }
|
|
|
- if (!exp) {
|
|
|
- // shorthand syntax https://github.com/vuejs/core/pull/9451
|
|
|
- const propName = camelize(arg.content)
|
|
|
- exp = createSimpleExpression(propName, false, arg.loc)
|
|
|
- exp.ast = null
|
|
|
- }
|
|
|
-
|
|
|
- if (!exp.content.trim()) {
|
|
|
- context.options.onError(
|
|
|
- createCompilerError(ErrorCodes.X_V_BIND_NO_EXPRESSION, loc),
|
|
|
- )
|
|
|
- context.template += ` ${arg.content}=""`
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- context.registerEffect(
|
|
|
- [exp],
|
|
|
- [
|
|
|
- {
|
|
|
- type: IRNodeTypes.SET_PROP,
|
|
|
- loc: prop.loc,
|
|
|
- element: context.reference(),
|
|
|
- name: arg,
|
|
|
- value: exp,
|
|
|
- },
|
|
|
- ],
|
|
|
- )
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
}
|