Skip to content

Commit

Permalink
types: refactor VNodeRef types
Browse files Browse the repository at this point in the history
fix #836
  • Loading branch information
underfin committed Mar 15, 2020
1 parent 60ed4e7 commit 79deb41
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 4 additions & 4 deletions packages/runtime-core/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
VNodeArrayChildren,
createVNode,
isSameVNodeType,
Static
Static,
VNodeRef
} from './vnode'
import {
ComponentInternalInstance,
Expand Down Expand Up @@ -44,7 +45,6 @@ import {
stop,
ReactiveEffectOptions,
isRef,
Ref,
toRaw,
DebuggerEvent
} from '@vue/reactivity'
Expand Down Expand Up @@ -1789,8 +1789,8 @@ function baseCreateRenderer<
}

const setRef = (
ref: string | Function | Ref | [ComponentPublicInstance, string],
oldRef: string | Function | Ref | [ComponentPublicInstance, string] | null,
ref: VNodeRef,
oldRef: VNodeRef | null,
parent: ComponentInternalInstance,
value: HostNode | ComponentPublicInstance | null
) => {
Expand Down
11 changes: 9 additions & 2 deletions packages/runtime-core/src/vnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { TransitionHooks } from './components/BaseTransition'
import { warn } from './warning'
import { currentScopeId } from './helpers/scopeId'
import { PortalImpl, isPortal } from './components/Portal'
import { ComponentPublicInstance } from './componentProxy'

export const Fragment = (Symbol(__DEV__ ? 'Fragment' : undefined) as any) as {
__isFragment: true
Expand All @@ -54,7 +55,7 @@ export type VNodeTypes =
export interface VNodeProps {
[key: string]: any
key?: string | number
ref?: string | Ref | ((ref: object | null) => void)
ref?: VNodeRef

// vnode hooks
onVnodeBeforeMount?: (vnode: VNode) => void
Expand Down Expand Up @@ -89,12 +90,18 @@ export type VNodeNormalizedChildren<HostNode = any, HostElement = any> =
| RawSlots
| null

export type VNodeRef =
| string
| ((ref: object | null) => unknown)
| Ref
| [ComponentPublicInstance, string]

export interface VNode<HostNode = any, HostElement = any> {
_isVNode: true
type: VNodeTypes
props: VNodeProps | null
key: string | number | null
ref: string | Ref | ((ref: object | null) => void) | null
ref: VNodeRef | null
scopeId: string | null // SFC only
children: VNodeNormalizedChildren<HostNode, HostElement>
component: ComponentInternalInstance | null
Expand Down

0 comments on commit 79deb41

Please sign in to comment.