import { VNode, VNodeChild, isVNode } from './vnode'
import {
+ reactive,
ReactiveEffect,
shallowReadonly,
pauseTracking,
}
// setup returned bindings.
// assuming a render function compiled from template is present.
- instance.renderContext = setupResult
+ instance.renderContext = reactive(setupResult)
} else if (__DEV__ && setupResult !== undefined) {
warn(
`setup() should return an object. Received: ${
currentInstance = null
currentSuspense = null
}
-
- if (instance.renderContext === EMPTY_OBJ) {
- instance.renderContext = {}
- }
}
// used to identify a setup context proxy
ComputedOptions,
MethodOptions
} from './apiOptions'
-import {
- ReactiveEffect,
- isRef,
- isReactive,
- Ref,
- ComputedRef,
- unref
-} from '@vue/reactivity'
+import { ReactiveEffect, UnwrapRef } from '@vue/reactivity'
import { warn } from './warning'
import { Slots } from './componentSlots'
import {
$nextTick: typeof nextTick
$watch: typeof instanceWatch
} & P &
- UnwrapSetupBindings<B> &
+ UnwrapRef<B> &
D &
ExtractComputedReturns<C> &
M
-type UnwrapSetupBindings<B> = { [K in keyof B]: UnwrapBinding<B[K]> }
-
-type UnwrapBinding<B> = B extends ComputedRef<any>
- ? B extends ComputedRef<infer V> ? V : B
- : B extends Ref<infer V> ? V : B
-
const publicPropertiesMap: Record<
string,
(i: ComponentInternalInstance) => any
case AccessTypes.DATA:
return data[key]
case AccessTypes.CONTEXT:
- return unref(renderContext[key])
+ return renderContext[key]
case AccessTypes.PROPS:
return propsProxy![key]
// default: just fallthrough
} else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
accessCache![key] = AccessTypes.DATA
return data[key]
- } else if (hasOwn(renderContext, key)) {
+ } else if (renderContext !== EMPTY_OBJ && hasOwn(renderContext, key)) {
accessCache![key] = AccessTypes.CONTEXT
- return unref(renderContext[key])
+ return renderContext[key]
} else if (type.props != null) {
// only cache other properties when instance has declared (this stable)
// props
if (data !== EMPTY_OBJ && hasOwn(data, key)) {
data[key] = value
} else if (hasOwn(renderContext, key)) {
- // context is already reactive (user returned reactive object from setup())
- // just set directly
- if (isReactive(renderContext)) {
- renderContext[key] = value
- } else {
- // handle potential ref set
- const oldValue = renderContext[key]
- if (isRef(oldValue) && !isRef(value)) {
- oldValue.value = value
- } else {
- renderContext[key] = value
- }
- }
+ renderContext[key] = value
} else if (key[0] === '$' && key.slice(1) in target) {
__DEV__ &&
warn(