feat(v-on): cache handlers

This commit is contained in:
Evan You
2019-10-18 21:51:34 -04:00
parent 39ea67a2d2
commit 58593c4714
19 changed files with 529 additions and 243 deletions

View File

@@ -42,7 +42,8 @@ export const enum NodeTypes {
JS_ARRAY_EXPRESSION,
JS_FUNCTION_EXPRESSION,
JS_SEQUENCE_EXPRESSION,
JS_CONDITIONAL_EXPRESSION
JS_CONDITIONAL_EXPRESSION,
JS_CACHE_EXPRESSION
}
export const enum ElementTypes {
@@ -93,6 +94,7 @@ export interface RootNode extends Node {
components: string[]
directives: string[]
hoists: JSChildNode[]
cached: number
codegenNode: TemplateChildNode | JSChildNode | undefined
}
@@ -236,6 +238,7 @@ export type JSChildNode =
| FunctionExpression
| ConditionalExpression
| SequenceExpression
| CacheExpression
export interface CallExpression extends Node {
type: NodeTypes.JS_CALL_EXPRESSION
@@ -283,6 +286,12 @@ export interface ConditionalExpression extends Node {
alternate: JSChildNode
}
export interface CacheExpression extends Node {
type: NodeTypes.JS_CACHE_EXPRESSION
index: number
value: JSChildNode
}
// Codegen Node Types ----------------------------------------------------------
// createVNode(...)
@@ -605,3 +614,15 @@ export function createConditionalExpression(
loc: locStub
}
}
export function createCacheExpression(
index: number,
value: JSChildNode
): CacheExpression {
return {
type: NodeTypes.JS_CACHE_EXPRESSION,
index,
value,
loc: locStub
}
}