refactor: remove unused inheritRef option
This is technically a breaking change, but the option was not meant for public use and ended up not solving the problem it was introduced for.
This commit is contained in:
parent
5c490f1c45
commit
7886c267f7
@ -86,7 +86,6 @@ export interface FunctionalComponent<
|
|||||||
props?: ComponentPropsOptions<P>
|
props?: ComponentPropsOptions<P>
|
||||||
emits?: E | (keyof E)[]
|
emits?: E | (keyof E)[]
|
||||||
inheritAttrs?: boolean
|
inheritAttrs?: boolean
|
||||||
inheritRef?: boolean
|
|
||||||
displayName?: string
|
displayName?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,6 @@ export interface ComponentOptionsBase<
|
|||||||
components?: Record<string, PublicAPIComponent>
|
components?: Record<string, PublicAPIComponent>
|
||||||
directives?: Record<string, Directive>
|
directives?: Record<string, Directive>
|
||||||
inheritAttrs?: boolean
|
inheritAttrs?: boolean
|
||||||
inheritRef?: boolean
|
|
||||||
emits?: E | EE[]
|
emits?: E | EE[]
|
||||||
|
|
||||||
// Internal ------------------------------------------------------------------
|
// Internal ------------------------------------------------------------------
|
||||||
|
@ -180,10 +180,6 @@ export function renderComponentRoot(
|
|||||||
}
|
}
|
||||||
root.transition = vnode.transition
|
root.transition = vnode.transition
|
||||||
}
|
}
|
||||||
// inherit ref
|
|
||||||
if (Component.inheritRef && vnode.ref != null) {
|
|
||||||
root.ref = vnode.ref
|
|
||||||
}
|
|
||||||
|
|
||||||
if (__DEV__ && setRoot) {
|
if (__DEV__ && setRoot) {
|
||||||
setRoot(root)
|
setRoot(root)
|
||||||
|
@ -108,8 +108,6 @@ export function useTransitionState(): TransitionState {
|
|||||||
const BaseTransitionImpl = {
|
const BaseTransitionImpl = {
|
||||||
name: `BaseTransition`,
|
name: `BaseTransition`,
|
||||||
|
|
||||||
inheritRef: true,
|
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
mode: String,
|
mode: String,
|
||||||
appear: Boolean,
|
appear: Boolean,
|
||||||
@ -135,11 +133,11 @@ const BaseTransitionImpl = {
|
|||||||
const instance = getCurrentInstance()!
|
const instance = getCurrentInstance()!
|
||||||
const state = useTransitionState()
|
const state = useTransitionState()
|
||||||
|
|
||||||
|
let prevTransitionKey: any
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
const children = slots.default && getTransitionRawChildren(
|
const children =
|
||||||
slots.default(),
|
slots.default && getTransitionRawChildren(slots.default(), true)
|
||||||
true
|
|
||||||
)
|
|
||||||
if (!children || !children.length) {
|
if (!children || !children.length) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -183,11 +181,24 @@ const BaseTransitionImpl = {
|
|||||||
|
|
||||||
const oldChild = instance.subTree
|
const oldChild = instance.subTree
|
||||||
const oldInnerChild = oldChild && getKeepAliveChild(oldChild)
|
const oldInnerChild = oldChild && getKeepAliveChild(oldChild)
|
||||||
|
|
||||||
|
let transitionKeyChanged = false
|
||||||
|
const { getTransitionKey } = innerChild.type as any
|
||||||
|
if (getTransitionKey) {
|
||||||
|
const key = getTransitionKey()
|
||||||
|
if (prevTransitionKey === undefined) {
|
||||||
|
prevTransitionKey = key
|
||||||
|
} else if (key !== prevTransitionKey) {
|
||||||
|
prevTransitionKey = key
|
||||||
|
transitionKeyChanged = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// handle mode
|
// handle mode
|
||||||
if (
|
if (
|
||||||
oldInnerChild &&
|
oldInnerChild &&
|
||||||
oldInnerChild.type !== Comment &&
|
oldInnerChild.type !== Comment &&
|
||||||
!isSameVNodeType(innerChild, oldInnerChild)
|
(!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)
|
||||||
) {
|
) {
|
||||||
const leavingHooks = resolveTransitionHooks(
|
const leavingHooks = resolveTransitionHooks(
|
||||||
oldInnerChild,
|
oldInnerChild,
|
||||||
|
@ -17,8 +17,7 @@ import {
|
|||||||
ComponentInternalInstance,
|
ComponentInternalInstance,
|
||||||
createComponentInstance,
|
createComponentInstance,
|
||||||
Data,
|
Data,
|
||||||
setupComponent,
|
setupComponent
|
||||||
Component
|
|
||||||
} from './component'
|
} from './component'
|
||||||
import {
|
import {
|
||||||
renderComponentRoot,
|
renderComponentRoot,
|
||||||
@ -283,14 +282,10 @@ export const setRef = (
|
|||||||
if (!vnode) {
|
if (!vnode) {
|
||||||
value = null
|
value = null
|
||||||
} else {
|
} else {
|
||||||
const { el, component, shapeFlag, type } = vnode
|
if (vnode.shapeFlag & ShapeFlags.STATEFUL_COMPONENT) {
|
||||||
if (shapeFlag & ShapeFlags.COMPONENT && (type as Component).inheritRef) {
|
value = vnode.component!.proxy
|
||||||
return
|
|
||||||
}
|
|
||||||
if (shapeFlag & ShapeFlags.STATEFUL_COMPONENT) {
|
|
||||||
value = component!.proxy
|
|
||||||
} else {
|
} else {
|
||||||
value = el
|
value = vnode.el
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ export const Transition: FunctionalComponent<TransitionProps> = (
|
|||||||
{ slots }
|
{ slots }
|
||||||
) => h(BaseTransition, resolveTransitionProps(props), slots)
|
) => h(BaseTransition, resolveTransitionProps(props), slots)
|
||||||
|
|
||||||
Transition.inheritRef = true
|
|
||||||
Transition.displayName = 'Transition'
|
Transition.displayName = 'Transition'
|
||||||
|
|
||||||
const DOMTransitionPropsValidators = {
|
const DOMTransitionPropsValidators = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user