wip: root Vue compat
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { VNodeFlags } from './flags'
|
||||
import { EMPTY_OBJ } from './utils'
|
||||
import { h } from './h'
|
||||
import { VNode, createFragment } from './vdom'
|
||||
import { Component, MountedComponent, ComponentClass } from './component'
|
||||
import { createTextVNode, cloneVNode } from './vdom'
|
||||
@@ -153,6 +154,7 @@ export function shouldUpdateFunctionalComponent(
|
||||
return shouldUpdate
|
||||
}
|
||||
|
||||
// compat only
|
||||
export function createComponentClassFromOptions(
|
||||
options: ComponentOptions
|
||||
): ComponentClass {
|
||||
@@ -165,7 +167,13 @@ export function createComponentClassFromOptions(
|
||||
for (const key in options) {
|
||||
const value = options[key]
|
||||
if (typeof value === 'function') {
|
||||
;(ObjectComponent.prototype as any)[key] = value
|
||||
;(ObjectComponent.prototype as any)[key] =
|
||||
key === 'render'
|
||||
? // normalize render for legacy signature
|
||||
function render() {
|
||||
return value.call(this, h)
|
||||
}
|
||||
: value
|
||||
}
|
||||
if (key === 'computed') {
|
||||
const isGet = typeof value === 'function'
|
||||
|
||||
@@ -1174,11 +1174,11 @@ export function createRenderer(options: RendererOptions) {
|
||||
isSVG: boolean,
|
||||
endNode: RenderNode | RenderFragment | null
|
||||
): RenderNode {
|
||||
const instance = createComponentInstance(
|
||||
parentVNode,
|
||||
Component,
|
||||
parentComponent
|
||||
)
|
||||
// a vnode may already have an instance if this is a compat call
|
||||
// with new Vue()
|
||||
const instance =
|
||||
(__COMPAT__ && (parentVNode.children as MountedComponent)) ||
|
||||
createComponentInstance(parentVNode, Component, parentComponent)
|
||||
|
||||
const queueUpdate = (instance.$forceUpdate = () => {
|
||||
queueJob(instance._updateHandle, flushHooks)
|
||||
|
||||
@@ -10,8 +10,11 @@ export const Component = InternalComponent as ComponentClass
|
||||
// observer api
|
||||
export * from '@vue/observer'
|
||||
|
||||
// internal api
|
||||
export { createComponentInstance } from './componentUtils'
|
||||
|
||||
// flags & types
|
||||
export { FunctionalComponent } from './component'
|
||||
export { ComponentClass, FunctionalComponent } from './component'
|
||||
export { ComponentOptions, PropType } from './componentOptions'
|
||||
export { VNodeFlags, ChildrenFlags } from './flags'
|
||||
export { VNode, VNodeData, VNodeChildren, Key, Ref, Slots, Slot } from './vdom'
|
||||
|
||||
Reference in New Issue
Block a user