@@ -46,6 +46,26 @@ describe('api: createApp', () => {
|
||||
expect(`already been mounted`).toHaveBeenWarned()
|
||||
})
|
||||
|
||||
test('unmount', () => {
|
||||
const Comp = {
|
||||
props: {
|
||||
count: {
|
||||
default: 0
|
||||
}
|
||||
},
|
||||
setup(props: { count: number }) {
|
||||
return () => props.count
|
||||
}
|
||||
}
|
||||
|
||||
const root = nodeOps.createElement('div')
|
||||
const app = createApp()
|
||||
app.mount(Comp, root)
|
||||
|
||||
app.unmount(root)
|
||||
expect(serializeInner(root)).toBe(``)
|
||||
})
|
||||
|
||||
test('provide', () => {
|
||||
const app = createApp()
|
||||
app.provide('foo', 1)
|
||||
|
||||
@@ -24,6 +24,7 @@ export interface App<HostElement = any> {
|
||||
rootContainer: HostElement | string,
|
||||
rootProps?: Data
|
||||
): ComponentPublicInstance
|
||||
unmount(rootContainer: HostElement | string): void
|
||||
provide<T>(key: InjectionKey<T> | string, value: T): this
|
||||
}
|
||||
|
||||
@@ -197,6 +198,10 @@ export function createAppAPI<HostNode, HostElement>(
|
||||
}
|
||||
},
|
||||
|
||||
unmount(rootContainer: HostElement) {
|
||||
render(null, rootContainer)
|
||||
},
|
||||
|
||||
provide(key, value) {
|
||||
if (__DEV__ && key in context.provides) {
|
||||
warn(
|
||||
|
||||
Reference in New Issue
Block a user