Skip to content

Commit 7886c26

Browse files
committed
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.
1 parent 5c490f1 commit 7886c26

File tree

6 files changed

+22
-23
lines changed

6 files changed

+22
-23
lines changed

packages/runtime-core/src/component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ export interface FunctionalComponent<
8686
props?: ComponentPropsOptions<P>
8787
emits?: E | (keyof E)[]
8888
inheritAttrs?: boolean
89-
inheritRef?: boolean
9089
displayName?: string
9190
}
9291

packages/runtime-core/src/componentOptions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ export interface ComponentOptionsBase<
105105
components?: Record<string, PublicAPIComponent>
106106
directives?: Record<string, Directive>
107107
inheritAttrs?: boolean
108-
inheritRef?: boolean
109108
emits?: E | EE[]
110109

111110
// Internal ------------------------------------------------------------------

packages/runtime-core/src/componentRenderUtils.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,6 @@ export function renderComponentRoot(
180180
}
181181
root.transition = vnode.transition
182182
}
183-
// inherit ref
184-
if (Component.inheritRef && vnode.ref != null) {
185-
root.ref = vnode.ref
186-
}
187183

188184
if (__DEV__ && setRoot) {
189185
setRoot(root)

packages/runtime-core/src/components/BaseTransition.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ export function useTransitionState(): TransitionState {
108108
const BaseTransitionImpl = {
109109
name: `BaseTransition`,
110110

111-
inheritRef: true,
112-
113111
props: {
114112
mode: String,
115113
appear: Boolean,
@@ -135,11 +133,11 @@ const BaseTransitionImpl = {
135133
const instance = getCurrentInstance()!
136134
const state = useTransitionState()
137135

136+
let prevTransitionKey: any
137+
138138
return () => {
139-
const children = slots.default && getTransitionRawChildren(
140-
slots.default(),
141-
true
142-
)
139+
const children =
140+
slots.default && getTransitionRawChildren(slots.default(), true)
143141
if (!children || !children.length) {
144142
return
145143
}
@@ -183,11 +181,24 @@ const BaseTransitionImpl = {
183181

184182
const oldChild = instance.subTree
185183
const oldInnerChild = oldChild && getKeepAliveChild(oldChild)
184+
185+
let transitionKeyChanged = false
186+
const { getTransitionKey } = innerChild.type as any
187+
if (getTransitionKey) {
188+
const key = getTransitionKey()
189+
if (prevTransitionKey === undefined) {
190+
prevTransitionKey = key
191+
} else if (key !== prevTransitionKey) {
192+
prevTransitionKey = key
193+
transitionKeyChanged = true
194+
}
195+
}
196+
186197
// handle mode
187198
if (
188199
oldInnerChild &&
189200
oldInnerChild.type !== Comment &&
190-
!isSameVNodeType(innerChild, oldInnerChild)
201+
(!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)
191202
) {
192203
const leavingHooks = resolveTransitionHooks(
193204
oldInnerChild,

packages/runtime-core/src/renderer.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import {
1717
ComponentInternalInstance,
1818
createComponentInstance,
1919
Data,
20-
setupComponent,
21-
Component
20+
setupComponent
2221
} from './component'
2322
import {
2423
renderComponentRoot,
@@ -283,14 +282,10 @@ export const setRef = (
283282
if (!vnode) {
284283
value = null
285284
} else {
286-
const { el, component, shapeFlag, type } = vnode
287-
if (shapeFlag & ShapeFlags.COMPONENT && (type as Component).inheritRef) {
288-
return
289-
}
290-
if (shapeFlag & ShapeFlags.STATEFUL_COMPONENT) {
291-
value = component!.proxy
285+
if (vnode.shapeFlag & ShapeFlags.STATEFUL_COMPONENT) {
286+
value = vnode.component!.proxy
292287
} else {
293-
value = el
288+
value = vnode.el
294289
}
295290
}
296291

packages/runtime-dom/src/components/Transition.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export const Transition: FunctionalComponent<TransitionProps> = (
3434
{ slots }
3535
) => h(BaseTransition, resolveTransitionProps(props), slots)
3636

37-
Transition.inheritRef = true
3837
Transition.displayName = 'Transition'
3938

4039
const DOMTransitionPropsValidators = {

0 commit comments

Comments
 (0)