feat(core): allow passing explicit refs via props
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { VNode, VNodeChild, isVNode } from './vnode'
|
||||
import { ReactiveEffect, reactive, readonly } from '@vue/reactivity'
|
||||
import { ReactiveEffect, reactive, readonlyProps } from '@vue/reactivity'
|
||||
import {
|
||||
PublicInstanceProxyHandlers,
|
||||
ComponentPublicInstance
|
||||
@@ -269,7 +269,7 @@ export function setupStatefulComponent(
|
||||
// 2. create props proxy
|
||||
// the propsProxy is a reactive AND readonly proxy to the actual props.
|
||||
// it will be updated in resolveProps() on updates before render
|
||||
const propsProxy = (instance.propsProxy = readonly(instance.props))
|
||||
const propsProxy = (instance.propsProxy = readonlyProps(instance.props))
|
||||
// 3. call setup()
|
||||
const { setup } = Component
|
||||
if (setup) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { readonly, toRaw, lock, unlock } from '@vue/reactivity'
|
||||
import { toRaw, lock, unlock } from '@vue/reactivity'
|
||||
import {
|
||||
EMPTY_OBJ,
|
||||
camelize,
|
||||
@@ -200,12 +200,8 @@ export function resolveProps(
|
||||
// lock readonly
|
||||
lock()
|
||||
|
||||
instance.props = __DEV__ ? readonly(props) : props
|
||||
instance.attrs = options
|
||||
? __DEV__ && attrs != null
|
||||
? readonly(attrs)
|
||||
: attrs || EMPTY_OBJ
|
||||
: instance.props
|
||||
instance.props = props
|
||||
instance.attrs = options ? attrs || EMPTY_OBJ : props
|
||||
}
|
||||
|
||||
const normalizationMap = new WeakMap()
|
||||
|
||||
@@ -14,6 +14,7 @@ import { ShapeFlags } from './shapeFlags'
|
||||
import { handleError, ErrorCodes } from './errorHandling'
|
||||
import { PatchFlags, EMPTY_OBJ } from '@vue/shared'
|
||||
import { warn } from './warning'
|
||||
import { readonlyProps } from '@vue/reactivity'
|
||||
|
||||
// mark the current rendering instance for asset resolution (e.g.
|
||||
// resolveComponent, resolveDirective) during render
|
||||
@@ -52,14 +53,15 @@ export function renderComponentRoot(
|
||||
} else {
|
||||
// functional
|
||||
const render = Component as FunctionalComponent
|
||||
const propsToPass = __DEV__ ? readonlyProps(props) : props
|
||||
result = normalizeVNode(
|
||||
render.length > 1
|
||||
? render(props, {
|
||||
? render(propsToPass, {
|
||||
attrs,
|
||||
slots,
|
||||
emit
|
||||
})
|
||||
: render(props, null as any /* we know it doesn't need it */)
|
||||
: render(propsToPass, null as any /* we know it doesn't need it */)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user