refactor: adjust createApp related API signatures
BREAKING CHANGE: `createApp` API has been adjusted.
- `createApp()` now accepts the root component, and optionally a props
object to pass to the root component.
- `app.mount()` now accepts a single argument (the root container)
- `app.unmount()` no longer requires arguments.
New behavior looks like the following:
``` js
const app = createApp(RootComponent)
app.mount('#app')
app.unmount()
```
This commit is contained in:
@@ -12,7 +12,6 @@ import { mockWarn } from '@vue/shared'
|
||||
|
||||
describe('resolveAssets', () => {
|
||||
test('should work', () => {
|
||||
const app = createApp()
|
||||
const FooBar = () => null
|
||||
const BarBaz = { mounted: () => null }
|
||||
|
||||
@@ -49,8 +48,9 @@ describe('resolveAssets', () => {
|
||||
}
|
||||
}
|
||||
|
||||
const app = createApp(Root)
|
||||
const root = nodeOps.createElement('div')
|
||||
app.mount(Root, root)
|
||||
app.mount(root)
|
||||
expect(component1!).toBe(FooBar)
|
||||
expect(component2!).toBe(FooBar)
|
||||
expect(component3!).toBe(FooBar)
|
||||
@@ -78,7 +78,6 @@ describe('resolveAssets', () => {
|
||||
})
|
||||
|
||||
test('not exist', () => {
|
||||
const app = createApp()
|
||||
const Root = {
|
||||
setup() {
|
||||
resolveComponent('foo')
|
||||
@@ -87,14 +86,14 @@ describe('resolveAssets', () => {
|
||||
}
|
||||
}
|
||||
|
||||
const app = createApp(Root)
|
||||
const root = nodeOps.createElement('div')
|
||||
app.mount(Root, root)
|
||||
app.mount(root)
|
||||
expect('Failed to resolve component: foo').toHaveBeenWarned()
|
||||
expect('Failed to resolve directive: bar').toHaveBeenWarned()
|
||||
})
|
||||
|
||||
test('resolve dynamic component', () => {
|
||||
const app = createApp()
|
||||
const dynamicComponents = {
|
||||
foo: () => 'foo',
|
||||
bar: () => 'bar',
|
||||
@@ -112,8 +111,10 @@ describe('resolveAssets', () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const app = createApp(Root)
|
||||
const root = nodeOps.createElement('div')
|
||||
app.mount(Root, root)
|
||||
app.mount(root)
|
||||
expect(foo).toBe(dynamicComponents.foo)
|
||||
expect(bar).toBe(dynamicComponents.bar)
|
||||
expect(baz).toBe(dynamicComponents.baz)
|
||||
|
||||
Reference in New Issue
Block a user