refactor(compiler): use shorter helpers for text and comment nodes

This commit is contained in:
Evan You
2019-10-24 17:55:00 -04:00
parent eb20730a67
commit 1c0a2c6d41
19 changed files with 126 additions and 108 deletions

View File

@@ -21,12 +21,11 @@ import { isString, isArray } from '@vue/shared'
import { CompilerError, defaultOnError } from './errors'
import {
TO_STRING,
COMMENT,
CREATE_VNODE,
FRAGMENT,
helperNameMap,
WITH_DIRECTIVES,
CREATE_BLOCK
CREATE_BLOCK,
CREATE_COMMENT
} from './runtimeHelpers'
import { isVSlot, createBlockExpression } from './utils'
import { hoistStatic, isSingleElementRoot } from './transforms/hoistStatic'
@@ -346,8 +345,7 @@ export function traverseNode(
case NodeTypes.COMMENT:
// inject import for the Comment symbol, which is needed for creating
// comment nodes with `createVNode`
context.helper(CREATE_VNODE)
context.helper(COMMENT)
context.helper(CREATE_COMMENT)
break
case NodeTypes.INTERPOLATION:
// no need to traverse, but we need to inject toString helper