Skip to content

Commit

Permalink
refactor: remove unused inheritRef option
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yyx990803 committed Jul 1, 2020
1 parent 5c490f1 commit 7886c26
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 23 deletions.
1 change: 0 additions & 1 deletion packages/runtime-core/src/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export interface FunctionalComponent<
props?: ComponentPropsOptions<P>
emits?: E | (keyof E)[]
inheritAttrs?: boolean
inheritRef?: boolean
displayName?: string
}

Expand Down
1 change: 0 additions & 1 deletion packages/runtime-core/src/componentOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ export interface ComponentOptionsBase<
components?: Record<string, PublicAPIComponent>
directives?: Record<string, Directive>
inheritAttrs?: boolean
inheritRef?: boolean
emits?: E | EE[]

// Internal ------------------------------------------------------------------
Expand Down
4 changes: 0 additions & 4 deletions packages/runtime-core/src/componentRenderUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,6 @@ export function renderComponentRoot(
}
root.transition = vnode.transition
}
// inherit ref
if (Component.inheritRef && vnode.ref != null) {
root.ref = vnode.ref
}

if (__DEV__ && setRoot) {
setRoot(root)
Expand Down
25 changes: 18 additions & 7 deletions packages/runtime-core/src/components/BaseTransition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ export function useTransitionState(): TransitionState {
const BaseTransitionImpl = {
name: `BaseTransition`,

inheritRef: true,

props: {
mode: String,
appear: Boolean,
Expand All @@ -135,11 +133,11 @@ const BaseTransitionImpl = {
const instance = getCurrentInstance()!
const state = useTransitionState()

let prevTransitionKey: any

return () => {
const children = slots.default && getTransitionRawChildren(
slots.default(),
true
)
const children =
slots.default && getTransitionRawChildren(slots.default(), true)
if (!children || !children.length) {
return
}
Expand Down Expand Up @@ -183,11 +181,24 @@ const BaseTransitionImpl = {

const oldChild = instance.subTree
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
if (
oldInnerChild &&
oldInnerChild.type !== Comment &&
!isSameVNodeType(innerChild, oldInnerChild)
(!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)
) {
const leavingHooks = resolveTransitionHooks(
oldInnerChild,
Expand Down
13 changes: 4 additions & 9 deletions packages/runtime-core/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import {
ComponentInternalInstance,
createComponentInstance,
Data,
setupComponent,
Component
setupComponent
} from './component'
import {
renderComponentRoot,
Expand Down Expand Up @@ -283,14 +282,10 @@ export const setRef = (
if (!vnode) {
value = null
} else {
const { el, component, shapeFlag, type } = vnode
if (shapeFlag & ShapeFlags.COMPONENT && (type as Component).inheritRef) {
return
}
if (shapeFlag & ShapeFlags.STATEFUL_COMPONENT) {
value = component!.proxy
if (vnode.shapeFlag & ShapeFlags.STATEFUL_COMPONENT) {
value = vnode.component!.proxy
} else {
value = el
value = vnode.el
}
}

Expand Down
1 change: 0 additions & 1 deletion packages/runtime-dom/src/components/Transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const Transition: FunctionalComponent<TransitionProps> = (
{ slots }
) => h(BaseTransition, resolveTransitionProps(props), slots)

Transition.inheritRef = true
Transition.displayName = 'Transition'

const DOMTransitionPropsValidators = {
Expand Down

0 comments on commit 7886c26

Please sign in to comment.