refactor(compiler): use shorter helpers for text and comment nodes
This commit is contained in:
@@ -19,10 +19,10 @@ import { AppContext } from './apiApp'
|
||||
import { SuspenseBoundary } from './suspense'
|
||||
|
||||
export const Fragment = __DEV__ ? Symbol('Fragment') : Symbol()
|
||||
export const Text = __DEV__ ? Symbol('Text') : Symbol()
|
||||
export const Comment = __DEV__ ? Symbol('Comment') : Symbol()
|
||||
export const Portal = __DEV__ ? Symbol('Portal') : Symbol()
|
||||
export const Suspense = __DEV__ ? Symbol('Suspense') : Symbol()
|
||||
export const Text = __DEV__ ? Symbol('Text') : Symbol()
|
||||
export const Comment = __DEV__ ? Symbol('Comment') : Symbol()
|
||||
|
||||
export type VNodeTypes =
|
||||
| string
|
||||
@@ -254,6 +254,14 @@ export function cloneVNode(vnode: VNode): VNode {
|
||||
}
|
||||
}
|
||||
|
||||
export function createTextVNode(text: string = ' ', flag: number = 0): VNode {
|
||||
return createVNode(Text, null, text, flag)
|
||||
}
|
||||
|
||||
export function createCommentVNode(text: string = ''): VNode {
|
||||
return createVNode(Comment, null, text)
|
||||
}
|
||||
|
||||
export function normalizeVNode(child: VNodeChild): VNode {
|
||||
if (child == null) {
|
||||
// empty placeholder
|
||||
|
||||
Reference in New Issue
Block a user