Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

types: refactor VNodeRef types #839

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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