feat(compiler): convert text mixed with elements into createVNode calls

This ensures they are tracked as dynamic children when inside blocks.
Also guaruntees compiled vnodes always have vnode children in arrays
so that they can skip normalizeVNode safely in optimized mode.
This commit is contained in:
Evan You
2019-10-21 15:52:29 -04:00
parent a0d570b16d
commit 052febc127
13 changed files with 236 additions and 112 deletions

View File

@@ -35,6 +35,7 @@ export const enum NodeTypes {
IF,
IF_BRANCH,
FOR,
TEXT_CALL,
// codegen
JS_CALL_EXPRESSION,
JS_OBJECT_EXPRESSION,
@@ -86,6 +87,7 @@ export type TemplateChildNode =
| CommentNode
| IfNode
| ForNode
| TextCallNode
export interface RootNode extends Node {
type: NodeTypes.ROOT
@@ -227,6 +229,12 @@ export interface ForNode extends Node {
codegenNode: ForCodegenNode
}
export interface TextCallNode extends Node {
type: NodeTypes.TEXT_CALL
content: TextNode | InterpolationNode | CompoundExpressionNode
codegenNode: CallExpression
}
// We also include a number of JavaScript AST nodes for code generation.
// The AST is an intentionally minimal subset just to meet the exact needs of
// Vue render function generation.