vue3-yuanma/packages/runtime-test/src/index.ts
Evan You c07751fd36 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()
  ```
2020-01-27 16:00:17 -05:00

30 lines
817 B
TypeScript

import {
createRenderer,
VNode,
RootRenderFunction,
CreateAppFunction
} from '@vue/runtime-core'
import { nodeOps, TestNode, TestElement } from './nodeOps'
import { patchProp } from './patchProp'
import { serializeInner } from './serialize'
const { render: baseRender, createApp: baseCreateApp } = createRenderer({
patchProp,
...nodeOps
})
export const render = baseRender as RootRenderFunction<TestNode, TestElement>
export const createApp = baseCreateApp as CreateAppFunction<TestElement>
// convenience for one-off render validations
export function renderToString(vnode: VNode) {
const root = nodeOps.createElement('div')
render(vnode, root)
return serializeInner(root)
}
export * from './triggerEvent'
export * from './serialize'
export * from './nodeOps'
export * from '@vue/runtime-core'