updated() {
childUpdated()
}
- render(props: any) {
+ render() {
return h(
'div',
{
class: 'c2',
style: { fontWeight: 'bold' }
},
- props.foo
+ this.$props.foo
)
}
}
updated() {
childUpdated()
}
- render(props: any) {
+ render() {
return h(
'div',
{
class: 'c2',
style: { fontWeight: 'bold' }
},
- props.foo
+ this.$props.foo
)
}
}
import { EMPTY_OBJ } from './utils'
+import { createElement } from './h'
import { VNode, Slots, RenderNode, MountedVNode } from './vdom'
import {
Data,
RenderFunction,
ComponentOptions,
ComponentPropsOptions,
- WatchOptions
+ WatchOptions,
+ RenderContext
} from './componentOptions'
import { setupWatcher } from './componentWatch'
import { Autorun, DebuggerEvent, ComputedGetter } from '@vue/observer'
$children: MountedComponent[]
$options: ComponentOptions<D, P>
- render(props: P, slots: Slots, attrs: Data): any
+ render(h: createElement, ctx: RenderContext<P>): any
renderError?(e: Error): any
renderTracked?(e: DebuggerEvent): void
renderTriggered?(e: DebuggerEvent): void
+import { createElement } from './h'
import { Slots } from './vdom'
import { MountedComponent } from './component'
export type Data = Record<string, any>
+export interface RenderContext<P> {
+ props: P
+ slots: Slots
+ attrs: Data
+}
+
export interface RenderFunction<P = Data> {
- (props: P, slots: Slots, attrs: Data): any
+ (h: createElement, ctx: RenderContext<P>): any
}
export interface ComponentOptions<D = Data, P = Data> {
export function renderInstanceRoot(instance: MountedComponent): VNode {
let vnode
try {
- vnode = instance.render.call(
- instance.$proxy,
- instance.$props,
- instance.$slots,
- instance.$attrs
- )
+ vnode = instance.render.call(instance.$proxy, h, {
+ props: instance.$props,
+ slots: instance.$slots,
+ attrs: instance.$attrs
+ })
} catch (e1) {
handleError(e1, instance, ErrorTypes.RENDER)
if (__DEV__ && instance.renderError) {
+import { h } from './h'
import { autorun, stop } from '@vue/observer'
import { queueJob } from '@vue/scheduler'
import { VNodeFlags, ChildrenFlags } from './flags'
const render = tag as FunctionalComponent
const { props, attrs } = resolveProps(data, render.props)
const subTree = (vnode.children = normalizeComponentRoot(
- render(props, slots || EMPTY_OBJ, attrs || EMPTY_OBJ),
+ render(h, {
+ props,
+ slots: slots || EMPTY_OBJ,
+ attrs: attrs || EMPTY_OBJ
+ }),
vnode,
attrs,
render.inheritAttrs
if (shouldUpdate) {
const { props, attrs } = resolveProps(nextData, render.props)
const nextTree = (nextVNode.children = normalizeComponentRoot(
- render(props, nextSlots || EMPTY_OBJ, attrs || EMPTY_OBJ),
+ render(h, {
+ props,
+ slots: nextSlots || EMPTY_OBJ,
+ attrs: attrs || EMPTY_OBJ
+ }),
nextVNode,
attrs,
render.inheritAttrs
function logError(err: Error, instance: MountedComponent, type: ErrorTypes) {
if (__DEV__) {
const info = ErrorTypeStrings[type]
- console.warn(
- `Unhandled error${info ? ` in ${info}` : ``}: "${err.toString()}"`,
- instance
- )
+ console.warn(`Unhandled error${info ? ` in ${info}` : ``}:`)
+ console.error(err)
} else {
throw err
}