( instance: ComponentInternalInstance, slotScopeId?: string, )
| 124 | } |
| 125 | |
| 126 | function renderComponentSubTree( |
| 127 | instance: ComponentInternalInstance, |
| 128 | slotScopeId?: string, |
| 129 | ): SSRBuffer | Promise<SSRBuffer> { |
| 130 | if (__DEV__) pushWarningContext(instance.vnode) |
| 131 | const comp = instance.type as Component |
| 132 | const { getBuffer, push } = createBuffer() |
| 133 | if (isFunction(comp)) { |
| 134 | let root = renderComponentRoot(instance) |
| 135 | // #5817 scope ID attrs not falling through if functional component doesn't |
| 136 | // have props |
| 137 | if (!(comp as FunctionalComponent).props) { |
| 138 | for (const key in instance.attrs) { |
| 139 | if (key.startsWith(`data-v-`)) { |
| 140 | ;(root.props || (root.props = {}))[key] = `` |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | renderVNode(push, (instance.subTree = root), instance, slotScopeId) |
| 145 | } else { |
| 146 | if ( |
| 147 | (!instance.render || instance.render === NOOP) && |
| 148 | !instance.ssrRender && |
| 149 | !comp.ssrRender && |
| 150 | isString(comp.template) |
| 151 | ) { |
| 152 | comp.ssrRender = ssrCompile(comp.template, instance) |
| 153 | } |
| 154 | |
| 155 | const ssrRender = instance.ssrRender || comp.ssrRender |
| 156 | if (ssrRender) { |
| 157 | // optimized |
| 158 | // resolve fallthrough attrs |
| 159 | let attrs = instance.inheritAttrs !== false ? instance.attrs : undefined |
| 160 | let hasCloned = false |
| 161 | |
| 162 | let cur = instance |
| 163 | while (true) { |
| 164 | const scopeId = cur.vnode.scopeId |
| 165 | if (scopeId) { |
| 166 | if (!hasCloned) { |
| 167 | attrs = { ...attrs } |
| 168 | hasCloned = true |
| 169 | } |
| 170 | attrs![scopeId] = '' |
| 171 | } |
| 172 | const parent = cur.parent |
| 173 | if (parent && parent.subTree && parent.subTree === cur.vnode) { |
| 174 | // parent is a non-SSR compiled component and is rendering this |
| 175 | // component as root. inherit its scopeId if present. |
| 176 | cur = parent |
| 177 | } else { |
| 178 | break |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | if (slotScopeId) { |
| 183 | if (!hasCloned) attrs = { ...attrs } |
no test coverage detected