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

Function renderElementVNode

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

Source from the content-addressed store, hash-verified

291}
292
293function renderElementVNode(
294 push: PushFn,
295 vnode: VNode,
296 parentComponent: ComponentInternalInstance,
297 slotScopeId?: string,
298) {
299 const tag = vnode.type as string
300 let { props, children, shapeFlag, scopeId } = vnode
301 let openTag = `<${tag}`
302
303 if (props) {
304 openTag += ssrRenderAttrs(props, tag)
305 }
306
307 const renderedScopeIds: string[] = []
308 const appendScopeId = (id: string) => {
309 if (
310 id &&
311 (!props || !hasOwn(props, id)) &&
312 !renderedScopeIds.includes(id)
313 ) {
314 openTag += ` ${id}`
315 renderedScopeIds.push(id)
316 }
317 }
318
319 if (scopeId) {
320 appendScopeId(scopeId)
321 }
322 // inherit parent chain scope id if this is the root node
323 let curParent: ComponentInternalInstance | null = parentComponent
324 let curVnode = vnode
325 while (curParent && curVnode === curParent.subTree) {
326 curVnode = curParent.vnode
327 if (curVnode.scopeId) {
328 appendScopeId(curVnode.scopeId)
329 }
330 curParent = curParent.parent
331 }
332 if (slotScopeId) {
333 const slotScopeIdList = slotScopeId.trim().split(' ')
334 for (let i = 0; i < slotScopeIdList.length; i++) {
335 appendScopeId(slotScopeIdList[i])
336 }
337 }
338
339 push(openTag + `>`)
340 if (!isVoidTag(tag)) {
341 let hasChildrenOverride = false
342 if (props) {
343 if (props.innerHTML) {
344 hasChildrenOverride = true
345 push(props.innerHTML)
346 } else if (props.textContent) {
347 hasChildrenOverride = true
348 push(escapeHtml(props.textContent))
349 } else if (tag === 'textarea' && props.value) {
350 hasChildrenOverride = true

Callers 1

renderVNodeFunction · 0.85

Calls 5

ssrRenderAttrsFunction · 0.90
escapeHtmlFunction · 0.90
appendScopeIdFunction · 0.85
renderVNodeChildrenFunction · 0.85
pushFunction · 0.70

Tested by

no test coverage detected