]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor: remove unused inheritRef option
authorEvan You <yyx990803@gmail.com>
Wed, 1 Jul 2020 01:47:12 +0000 (21:47 -0400)
committerEvan You <yyx990803@gmail.com>
Wed, 1 Jul 2020 19:40:11 +0000 (15:40 -0400)
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.

packages/runtime-core/src/component.ts
packages/runtime-core/src/componentOptions.ts
packages/runtime-core/src/componentRenderUtils.ts
packages/runtime-core/src/components/BaseTransition.ts
packages/runtime-core/src/renderer.ts
packages/runtime-dom/src/components/Transition.ts

index ebd46ae6d575d5c524e885d804b447004ea30538..312c583ff4a296ce2c2b0c9c20a20b606776160c 100644 (file)
@@ -86,7 +86,6 @@ export interface FunctionalComponent<
   props?: ComponentPropsOptions<P>
   emits?: E | (keyof E)[]
   inheritAttrs?: boolean
-  inheritRef?: boolean
   displayName?: string
 }
 
index 1fb5d3f747abf6d18072268727640eec847fc076..ee92ef521d0af2694f5ba6e6fb7becefa0a0e88e 100644 (file)
@@ -105,7 +105,6 @@ export interface ComponentOptionsBase<
   components?: Record<string, PublicAPIComponent>
   directives?: Record<string, Directive>
   inheritAttrs?: boolean
-  inheritRef?: boolean
   emits?: E | EE[]
 
   // Internal ------------------------------------------------------------------
index c158f4ad8634d4a46ad057a7e101225c541507eb..9b07b3b413b7e1bf3c03ec605c6b74afb67c23ff 100644 (file)
@@ -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)
index 104fe097710060ef674c88c708fbbb9f5ac5c6a8..666b13dc204761837295060fe1144ba26e63ca25 100644 (file)
@@ -108,8 +108,6 @@ export function useTransitionState(): TransitionState {
 const BaseTransitionImpl = {
   name: `BaseTransition`,
 
-  inheritRef: true,
-
   props: {
     mode: String,
     appear: Boolean,
@@ -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
       }
@@ -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,
index 4b6785ea5658045ab4e818754a1294c97af3b258..4a0830f02f5a8038cb4fcbf94bf8d6fd372523c1 100644 (file)
@@ -17,8 +17,7 @@ import {
   ComponentInternalInstance,
   createComponentInstance,
   Data,
-  setupComponent,
-  Component
+  setupComponent
 } from './component'
 import {
   renderComponentRoot,
@@ -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
     }
   }
 
index 86c0805f565535e6869687b7f41a017fe12ca9e3..2318d19eb9ba2c0b44a1a1b55b8fff2cb8acc8e1 100644 (file)
@@ -34,7 +34,6 @@ export const Transition: FunctionalComponent<TransitionProps> = (
   { slots }
 ) => h(BaseTransition, resolveTransitionProps(props), slots)
 
-Transition.inheritRef = true
 Transition.displayName = 'Transition'
 
 const DOMTransitionPropsValidators = {