perf(runtime-vapor): `setup()` returning object is only needed in __DEV__ (HMR) (#296)
This commit is contained in:
parent
e61cedf3fd
commit
f0361bafbb
|
@ -55,32 +55,38 @@ export function setupComponent(instance: ComponentInternalInstance): void {
|
||||||
|
|
||||||
let block: Block | undefined
|
let block: Block | undefined
|
||||||
|
|
||||||
if (
|
// Skip the type check for production since this is only for Dev HMR
|
||||||
stateOrNode &&
|
if (__DEV__) {
|
||||||
(stateOrNode instanceof Node ||
|
if (
|
||||||
isArray(stateOrNode) ||
|
stateOrNode &&
|
||||||
fragmentKey in stateOrNode ||
|
(stateOrNode instanceof Node ||
|
||||||
componentKey in stateOrNode)
|
isArray(stateOrNode) ||
|
||||||
) {
|
fragmentKey in stateOrNode ||
|
||||||
|
componentKey in stateOrNode)
|
||||||
|
) {
|
||||||
|
block = stateOrNode
|
||||||
|
} else if (isObject(stateOrNode)) {
|
||||||
|
instance.setupState = proxyRefs(stateOrNode)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!block && component.render) {
|
||||||
|
pauseTracking()
|
||||||
|
block = callWithErrorHandling(
|
||||||
|
component.render,
|
||||||
|
instance,
|
||||||
|
VaporErrorCodes.RENDER_FUNCTION,
|
||||||
|
[
|
||||||
|
instance.setupState, // _ctx
|
||||||
|
shallowReadonly(props), // $props
|
||||||
|
instance.emit, // $emit
|
||||||
|
getAttrsProxy(instance), // $attrs
|
||||||
|
getSlotsProxy(instance), // $slots
|
||||||
|
],
|
||||||
|
)
|
||||||
|
resetTracking()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
block = stateOrNode
|
block = stateOrNode
|
||||||
} else if (isObject(stateOrNode)) {
|
|
||||||
instance.setupState = proxyRefs(stateOrNode)
|
|
||||||
}
|
|
||||||
if (!block && component.render) {
|
|
||||||
pauseTracking()
|
|
||||||
block = callWithErrorHandling(
|
|
||||||
component.render,
|
|
||||||
instance,
|
|
||||||
VaporErrorCodes.RENDER_FUNCTION,
|
|
||||||
[
|
|
||||||
instance.setupState, // _ctx
|
|
||||||
__DEV__ ? shallowReadonly(props) : props, // $props
|
|
||||||
instance.emit, // $emit
|
|
||||||
__DEV__ ? getAttrsProxy(instance) : instance.attrs, // $attrs
|
|
||||||
__DEV__ ? getSlotsProxy(instance) : instance.slots, // $slots
|
|
||||||
],
|
|
||||||
)
|
|
||||||
resetTracking()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!block) {
|
if (!block) {
|
||||||
|
|
Loading…
Reference in New Issue