Skip to content

Commit 32b5124

Browse files
authored
fix(runtime-core): in operator returning false for built-in instance properties in exposeProxy (#6138)
fix #6137
1 parent 018b850 commit 32b5124

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/runtime-core/__tests__/apiExpose.spec.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ describe('api: expose', () => {
203203
return h('div')
204204
},
205205
setup(_, { expose }) {
206-
expose()
206+
expose({
207+
foo: 42
208+
})
207209
return () => h(GrandChild, { ref: grandChildRef })
208210
}
209211
})
@@ -216,7 +218,10 @@ describe('api: expose', () => {
216218
}
217219
const root = nodeOps.createElement('div')
218220
render(h(Parent), root)
221+
expect('$el' in childRef.value).toBe(true)
219222
expect(childRef.value.$el.tag).toBe('div')
223+
expect('foo' in childRef.value).toBe(true)
224+
expect('$parent' in grandChildRef.value).toBe(true)
220225
expect(grandChildRef.value.$parent).toBe(childRef.value)
221226
expect(grandChildRef.value.$parent.$parent).toBe(grandChildRef.value.$root)
222227
})

packages/runtime-core/src/component.ts

+3
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,9 @@ export function getExposeProxy(instance: ComponentInternalInstance) {
945945
} else if (key in publicPropertiesMap) {
946946
return publicPropertiesMap[key](instance)
947947
}
948+
},
949+
has(target, key: string) {
950+
return key in target || key in publicPropertiesMap
948951
}
949952
}))
950953
)

0 commit comments

Comments
 (0)