mirror of https://github.com/vuejs/core.git
chore: tweaks
This commit is contained in:
parent
26dbd3c902
commit
56cb3b0d46
|
@ -2,6 +2,7 @@ import { type ObjectEmitsOptions, baseEmit } from '@vue/runtime-dom'
|
|||
import type { VaporComponent, VaporComponentInstance } from './component'
|
||||
import { EMPTY_OBJ, hasOwn, isArray } from '@vue/shared'
|
||||
import { resolveSource } from './componentProps'
|
||||
import { interopKey } from './vdomInterop'
|
||||
|
||||
/**
|
||||
* The logic from core isn't too reusable so it's better to duplicate here
|
||||
|
@ -48,7 +49,7 @@ function propGetter(rawProps: Record<string, any>, key: string) {
|
|||
const source = resolveSource(dynamicSources[i])
|
||||
if (hasOwn(source, key))
|
||||
// for props passed from VDOM component, no need to resolve
|
||||
return dynamicSources.__interop
|
||||
return dynamicSources[interopKey]
|
||||
? source[key]
|
||||
: resolveSource(source[key])
|
||||
}
|
||||
|
|
|
@ -34,6 +34,8 @@ import { renderEffect } from './renderEffect'
|
|||
import { createTextNode } from './dom/node'
|
||||
import { optimizePropertyLookup } from './dom/prop'
|
||||
|
||||
export const interopKey: unique symbol = Symbol(`interop`)
|
||||
|
||||
// mounting vapor components and slots in vdom
|
||||
const vaporInteropImpl: Omit<
|
||||
VaporInteropInterface,
|
||||
|
@ -48,11 +50,16 @@ const vaporInteropImpl: Omit<
|
|||
const propsRef = shallowRef(vnode.props)
|
||||
const slotsRef = shallowRef(vnode.children)
|
||||
|
||||
const dynamicPropSource: (() => any)[] & { [interopKey]?: boolean } = [
|
||||
() => propsRef.value,
|
||||
]
|
||||
// mark as interop props
|
||||
dynamicPropSource[interopKey] = true
|
||||
// @ts-expect-error
|
||||
const instance = (vnode.component = createComponent(
|
||||
vnode.type as any as VaporComponent,
|
||||
{
|
||||
$: extend([() => propsRef.value], { __interop: true }),
|
||||
$: dynamicPropSource,
|
||||
} as RawProps,
|
||||
{
|
||||
_: slotsRef, // pass the slots ref
|
||||
|
|
Loading…
Reference in New Issue