@@ -19,8 +19,11 @@ export interface App<HostElement = any> {
19
19
mount ( rootContainer : HostElement | string ) : ComponentPublicInstance
20
20
unmount ( rootContainer : HostElement | string ) : void
21
21
provide < T > ( key : InjectionKey < T > | string , value : T ) : this
22
- rootComponent : Component
23
- rootContainer : HostElement | null
22
+
23
+ // internal. We need to expose these for the server-renderer
24
+ _component : Component
25
+ _props : Data | null
26
+ _container : HostElement | null
24
27
}
25
28
26
29
export interface AppConfig {
@@ -85,18 +88,21 @@ export type CreateAppFunction<HostElement> = (
85
88
export function createAppAPI < HostNode , HostElement > (
86
89
render : RootRenderFunction < HostNode , HostElement >
87
90
) : CreateAppFunction < HostElement > {
88
- return function createApp (
89
- rootComponent : Component ,
90
- rootProps ?: Data | null
91
- ) : App {
91
+ return function createApp ( rootComponent : Component , rootProps = null ) {
92
+ if ( rootProps != null && ! isObject ( rootProps ) ) {
93
+ __DEV__ && warn ( `root props passed to app.mount() must be an object.` )
94
+ rootProps = null
95
+ }
96
+
92
97
const context = createAppContext ( )
93
98
const installedPlugins = new Set ( )
94
99
95
100
let isMounted = false
96
101
97
102
const app : App = {
98
- rootComponent,
99
- rootContainer : null ,
103
+ _component : rootComponent ,
104
+ _props : rootProps ,
105
+ _container : null ,
100
106
101
107
get config ( ) {
102
108
return context . config
@@ -176,11 +182,6 @@ export function createAppAPI<HostNode, HostElement>(
176
182
177
183
mount ( rootContainer : HostElement ) : any {
178
184
if ( ! isMounted ) {
179
- if ( rootProps != null && ! isObject ( rootProps ) ) {
180
- __DEV__ &&
181
- warn ( `root props passed to app.mount() must be an object.` )
182
- rootProps = null
183
- }
184
185
const vnode = createVNode ( rootComponent , rootProps )
185
186
// store app context on the root VNode.
186
187
// this will be set on the root instance on initial mount.
@@ -195,7 +196,7 @@ export function createAppAPI<HostNode, HostElement>(
195
196
196
197
render ( vnode , rootContainer )
197
198
isMounted = true
198
- app . rootContainer = rootContainer
199
+ app . _container = rootContainer
199
200
return vnode . component ! . proxy
200
201
} else if ( __DEV__ ) {
201
202
warn (
@@ -206,7 +207,7 @@ export function createAppAPI<HostNode, HostElement>(
206
207
207
208
unmount ( ) {
208
209
if ( isMounted ) {
209
- render ( null , app . rootContainer ! )
210
+ render ( null , app . _container ! )
210
211
} else if ( __DEV__ ) {
211
212
warn ( `Cannot unmount an app that is not mounted.` )
212
213
}
0 commit comments