MCPcopy
hub / github.com/vuejs/core / renderVNode

Function renderVNode

packages/server-renderer/src/render.ts:224–280  ·  view source on GitHub ↗
(
  push: PushFn,
  vnode: VNode,
  parentComponent: ComponentInternalInstance,
  slotScopeId?: string,
)

Source from the content-addressed store, hash-verified

222}
223
224export function renderVNode(
225 push: PushFn,
226 vnode: VNode,
227 parentComponent: ComponentInternalInstance,
228 slotScopeId?: string,
229): void {
230 const { type, shapeFlag, children, dirs, props } = vnode
231 if (dirs) {
232 vnode.props = applySSRDirectives(vnode, props, dirs)
233 }
234
235 switch (type) {
236 case Text:
237 push(escapeHtml(children as string))
238 break
239 case Comment:
240 push(
241 children
242 ? `<!--${escapeHtmlComment(children as string)}-->`
243 : `<!---->`,
244 )
245 break
246 case Static:
247 push(children as string)
248 break
249 case Fragment:
250 if (vnode.slotScopeIds) {
251 slotScopeId =
252 (slotScopeId ? slotScopeId + ' ' : '') + vnode.slotScopeIds.join(' ')
253 }
254 push(`<!--[-->`) // open
255 renderVNodeChildren(
256 push,
257 children as VNodeArrayChildren,
258 parentComponent,
259 slotScopeId,
260 )
261 push(`<!--]-->`) // close
262 break
263 default:
264 if (shapeFlag & ShapeFlags.ELEMENT) {
265 renderElementVNode(push, vnode, parentComponent, slotScopeId)
266 } else if (shapeFlag & ShapeFlags.COMPONENT) {
267 push(renderComponentVNode(vnode, parentComponent, slotScopeId))
268 } else if (shapeFlag & ShapeFlags.TELEPORT) {
269 renderTeleportVNode(push, vnode, parentComponent, slotScopeId)
270 } else if (shapeFlag & ShapeFlags.SUSPENSE) {
271 renderVNode(push, vnode.ssContent!, parentComponent, slotScopeId)
272 } else {
273 warn(
274 '[@vue/server-renderer] Invalid VNode type:',
275 type,
276 `(${typeof type})`,
277 )
278 }
279 }
280}
281

Callers 2

renderComponentSubTreeFunction · 0.85
renderVNodeChildrenFunction · 0.85

Calls 9

escapeHtmlFunction · 0.90
escapeHtmlCommentFunction · 0.90
applySSRDirectivesFunction · 0.85
renderVNodeChildrenFunction · 0.85
renderElementVNodeFunction · 0.85
renderComponentVNodeFunction · 0.85
renderTeleportVNodeFunction · 0.85
pushFunction · 0.70
warnFunction · 0.50

Tested by

no test coverage detected