test: test for setup()

This commit is contained in:
Evan You
2019-08-26 18:08:56 -04:00
parent 0ede301cf2
commit 5a754aac81
6 changed files with 203 additions and 24 deletions

View File

@@ -92,8 +92,6 @@ interface SetupContext {
attrs: Data
slots: Slots
refs: Data
parent: ComponentInstance | null
root: ComponentInstance
emit: ((event: string, ...args: unknown[]) => void)
}
@@ -288,9 +286,7 @@ function createSetupContext(instance: ComponentInstance): SetupContext {
attrs: new Proxy(instance, SetupProxyHandlers.attrs),
slots: new Proxy(instance, SetupProxyHandlers.slots),
refs: new Proxy(instance, SetupProxyHandlers.refs),
emit: instance.emit,
parent: instance.parent,
root: instance.root
emit: instance.emit
} as any
return __DEV__ ? Object.freeze(context) : context
}
@@ -305,9 +301,7 @@ export function renderComponentRoot(instance: ComponentInstance): VNode {
slots,
attrs,
refs,
emit,
parent,
root
emit
} = instance
if (vnode.shapeFlag & ShapeFlags.STATEFUL_COMPONENT) {
return normalizeVNode(
@@ -322,9 +316,7 @@ export function renderComponentRoot(instance: ComponentInstance): VNode {
attrs,
slots,
refs,
emit,
parent,
root
emit
})
: render(props, null as any)
)
@@ -387,5 +379,6 @@ function hasPropsChanged(prevProps: Data, nextProps: Data): boolean {
return true
}
}
console.log(111)
return false
}

View File

@@ -184,7 +184,7 @@ export function resolveProps(
instance.props = __DEV__ ? readonly(props) : props
instance.attrs = options
? __DEV__
? __DEV__ && attrs != null
? readonly(attrs)
: attrs
: instance.props