2019-11-01 15:32:53 +00:00
|
|
|
import {
|
|
|
|
createRenderer,
|
|
|
|
warn,
|
|
|
|
App,
|
|
|
|
RootRenderFunction
|
|
|
|
} from '@vue/runtime-core'
|
2019-06-20 13:28:37 +00:00
|
|
|
import { nodeOps } from './nodeOps'
|
|
|
|
import { patchProp } from './patchProp'
|
2019-10-21 20:25:16 +00:00
|
|
|
// Importing from the compiler, will be tree-shaken in prod
|
2019-11-06 20:22:46 +00:00
|
|
|
import { isFunction, isString, isHTMLTag, isSVGTag } from '@vue/shared'
|
2018-09-19 15:35:38 +00:00
|
|
|
|
2019-11-01 15:32:53 +00:00
|
|
|
const { render: baseRender, createApp: baseCreateApp } = createRenderer({
|
2019-06-20 13:28:37 +00:00
|
|
|
patchProp,
|
|
|
|
...nodeOps
|
2019-09-06 20:58:32 +00:00
|
|
|
})
|
2019-09-02 20:09:34 +00:00
|
|
|
|
2019-11-01 15:32:53 +00:00
|
|
|
// use explicit type casts here to avoid import() calls in rolled-up d.ts
|
|
|
|
export const render = baseRender as RootRenderFunction<Node, Element>
|
|
|
|
|
|
|
|
export const createApp = (): App<Element> => {
|
2019-10-25 01:58:34 +00:00
|
|
|
const app = baseCreateApp()
|
|
|
|
|
|
|
|
if (__DEV__) {
|
|
|
|
// Inject `isNativeTag`
|
|
|
|
// this is used for component name validation (dev only)
|
|
|
|
Object.defineProperty(app.config, 'isNativeTag', {
|
|
|
|
value: (tag: string) => isHTMLTag(tag) || isSVGTag(tag),
|
|
|
|
writable: false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const mount = app.mount
|
|
|
|
app.mount = (component, container, props): any => {
|
|
|
|
if (isString(container)) {
|
|
|
|
container = document.querySelector(container)!
|
|
|
|
if (!container) {
|
|
|
|
__DEV__ &&
|
|
|
|
warn(`Failed to mount app: mount target selector returned null.`)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
__RUNTIME_COMPILE__ &&
|
|
|
|
!isFunction(component) &&
|
|
|
|
!component.render &&
|
|
|
|
!component.template
|
|
|
|
) {
|
|
|
|
component.template = container.innerHTML
|
|
|
|
}
|
|
|
|
// clear content before mounting
|
|
|
|
container.innerHTML = ''
|
|
|
|
return mount(component, container, props)
|
|
|
|
}
|
|
|
|
|
2019-10-14 19:36:30 +00:00
|
|
|
return app
|
|
|
|
}
|
|
|
|
|
2019-10-10 22:02:51 +00:00
|
|
|
// DOM-only runtime helpers
|
|
|
|
export {
|
|
|
|
vModelText,
|
|
|
|
vModelCheckbox,
|
|
|
|
vModelRadio,
|
|
|
|
vModelSelect,
|
|
|
|
vModelDynamic
|
|
|
|
} from './directives/vModel'
|
2019-10-18 20:20:45 +00:00
|
|
|
export { withModifiers, withKeys } from './directives/vOn'
|
2019-10-14 04:33:23 +00:00
|
|
|
|
2019-11-22 18:15:59 +00:00
|
|
|
// DOM-only components
|
2019-11-23 04:21:39 +00:00
|
|
|
export { CSSTransition, CSSTransitionProps } from './components/CSSTransition'
|
2019-11-22 18:15:59 +00:00
|
|
|
|
2018-09-20 01:51:21 +00:00
|
|
|
// re-export everything from core
|
2019-08-20 13:58:10 +00:00
|
|
|
// h, Component, reactivity API, nextTick, flags & types
|
2018-10-26 19:44:50 +00:00
|
|
|
export * from '@vue/runtime-core'
|