( instance: ComponentInternalInstance, )
| 50 | type SetRootFn = ((root: VNode) => void) | undefined |
| 51 | |
| 52 | export function renderComponentRoot( |
| 53 | instance: ComponentInternalInstance, |
| 54 | ): VNode { |
| 55 | const { |
| 56 | type: Component, |
| 57 | vnode, |
| 58 | proxy, |
| 59 | withProxy, |
| 60 | propsOptions: [propsOptions], |
| 61 | slots, |
| 62 | attrs, |
| 63 | emit, |
| 64 | render, |
| 65 | renderCache, |
| 66 | props, |
| 67 | data, |
| 68 | setupState, |
| 69 | ctx, |
| 70 | inheritAttrs, |
| 71 | } = instance |
| 72 | const prev = setCurrentRenderingInstance(instance) |
| 73 | |
| 74 | let result |
| 75 | let fallthroughAttrs |
| 76 | if (__DEV__) { |
| 77 | accessedAttrs = false |
| 78 | } |
| 79 | |
| 80 | try { |
| 81 | if (vnode.shapeFlag & ShapeFlags.STATEFUL_COMPONENT) { |
| 82 | // withProxy is a proxy with a different `has` trap only for |
| 83 | // runtime-compiled render functions using `with` block. |
| 84 | const proxyToUse = withProxy || proxy |
| 85 | // 'this' isn't available in production builds with `<script setup>`, |
| 86 | // so warn if it's used in dev. |
| 87 | const thisProxy = |
| 88 | __DEV__ && setupState.__isScriptSetup |
| 89 | ? new Proxy(proxyToUse!, { |
| 90 | get(target, key, receiver) { |
| 91 | warn( |
| 92 | `Property '${String( |
| 93 | key, |
| 94 | )}' was accessed via 'this'. Avoid using 'this' in templates.`, |
| 95 | ) |
| 96 | return Reflect.get(target, key, receiver) |
| 97 | }, |
| 98 | }) |
| 99 | : proxyToUse |
| 100 | result = normalizeVNode( |
| 101 | render!.call( |
| 102 | thisProxy, |
| 103 | proxyToUse!, |
| 104 | renderCache, |
| 105 | __DEV__ ? shallowReadonly(props) : props, |
| 106 | setupState, |
| 107 | data, |
| 108 | ctx, |
| 109 | ), |
no test coverage detected