wip: $data should only expose properties from data()

This commit is contained in:
Evan You
2019-09-05 20:36:35 -04:00
parent 94a05561f8
commit 7eed0df3c2
4 changed files with 43 additions and 27 deletions

View File

@@ -1127,13 +1127,13 @@ export function createRenderer(options: RendererOptions): RootRenderFunction {
value: HostNode | ComponentInstance | null
) {
const refs = parent.refs === EMPTY_OBJ ? (parent.refs = {}) : parent.refs
const rawData = toRaw(parent.data)
const renderContext = toRaw(parent.renderContext)
// unset old ref
if (oldRef !== null && oldRef !== ref) {
if (isString(oldRef)) {
refs[oldRef] = null
const oldSetupRef = rawData[oldRef]
const oldSetupRef = renderContext[oldRef]
if (isRef(oldSetupRef)) {
oldSetupRef.value = null
}
@@ -1143,7 +1143,7 @@ export function createRenderer(options: RendererOptions): RootRenderFunction {
}
if (isString(ref)) {
const setupRef = rawData[ref]
const setupRef = renderContext[ref]
if (isRef(setupRef)) {
setupRef.value = value
}