File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 1- import { nodeOps , render } from '@vue/runtime-test'
1+ import { createApp , nodeOps , render } from '@vue/runtime-test'
22import { defineComponent , h , ref } from '../src'
33
44describe ( 'api: expose' , ( ) => {
@@ -170,6 +170,26 @@ describe('api: expose', () => {
170170 render ( h ( Parent ) , root )
171171 } )
172172
173+ test ( 'with mount' , ( ) => {
174+ const Component = defineComponent ( {
175+ setup ( _ , { expose } ) {
176+ expose ( {
177+ foo : 1
178+ } )
179+ return {
180+ bar : 2
181+ }
182+ } ,
183+ render ( ) {
184+ return h ( 'div' )
185+ }
186+ } )
187+ const root = nodeOps . createElement ( 'div' )
188+ const vm = createApp ( Component ) . mount ( root ) as any
189+ expect ( vm . foo ) . toBe ( 1 )
190+ expect ( vm . bar ) . toBe ( undefined )
191+ } )
192+
173193 test ( 'expose should allow access to built-in instance properties' , ( ) => {
174194 const GrandChild = defineComponent ( {
175195 render ( ) {
Original file line number Diff line number Diff line change 33 Data ,
44 validateComponentName ,
55 Component ,
6- ComponentInternalInstance
6+ ComponentInternalInstance ,
7+ getExposeProxy
78} from './component'
89import {
910 ComponentOptions ,
@@ -309,7 +310,7 @@ export function createAppAPI<HostElement>(
309310 devtoolsInitApp ( app , version )
310311 }
311312
312- return vnode . component ! . proxy
313+ return getExposeProxy ( vnode . component ! ) || vnode . component ! . proxy
313314 } else if ( __DEV__ ) {
314315 warn (
315316 `App has already been mounted.\n` +
You can’t perform that action at this time.
0 commit comments