瀏覽代碼

always update abstract components

Evan You 9 年之前
父節點
當前提交
b46baac8bb

+ 1 - 1
src/core/components/keep-alive.js

@@ -3,7 +3,7 @@ import { getRealChild } from 'core/vdom/helpers'
 
 export default {
   name: 'keep-alive',
-  _abstract: true,
+  abstract: true,
   props: {
     child: Object
   },

+ 3 - 3
src/core/instance/lifecycle.js

@@ -10,8 +10,8 @@ export function initLifecycle (vm: Component) {
 
   // locate first non-abstract parent
   let parent = options.parent
-  if (parent && !options._abstract) {
-    while (parent.$options._abstract && parent.$parent) {
+  if (parent && !options.abstract) {
+    while (parent.$options.abstract && parent.$parent) {
       parent = parent.$parent
     }
     parent.$children.push(vm)
@@ -154,7 +154,7 @@ export function lifecycleMixin (Vue: Class<Component>) {
     vm._isBeingDestroyed = true
     // remove self from parent
     const parent = vm.$parent
-    if (parent && !parent._isBeingDestroyed && !vm.$options._abstract) {
+    if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
       remove(parent.$children, vm)
     }
     // teardown watchers

+ 6 - 2
src/core/vdom/create-component.js

@@ -137,13 +137,17 @@ function prepatch (
   vnode: MountedComponentVNode
 ) {
   const options = vnode.componentOptions
-  vnode.child = oldVnode.child
-  vnode.child._updateFromParent(
+  const child = vnode.child = oldVnode.child
+  child._updateFromParent(
     options.propsData, // updated props
     options.listeners, // updated listeners
     vnode, // new parent vnode
     options.children // new children
   )
+  // always update abstract components.
+  if (child.$options.abstract) {
+    child.$forceUpdate()
+  }
 }
 
 function insert (vnode: MountedComponentVNode) {

+ 1 - 1
src/core/vdom/helpers.js

@@ -66,7 +66,7 @@ function applyNS (vnode, ns) {
 // we want to recrusively retrieve the real component to be rendered
 export function getRealChild (vnode: ?VNode): ?VNode {
   const compOptions = vnode && vnode.componentOptions
-  if (compOptions && compOptions.Ctor.options._abstract) {
+  if (compOptions && compOptions.Ctor.options.abstract) {
     return getRealChild(compOptions.propsData && compOptions.propsData.child)
   } else {
     return vnode

+ 1 - 1
src/platforms/web/runtime/components/transition.js

@@ -39,7 +39,7 @@ export function extractTransitionData (comp: Component): Object {
 export default {
   name: 'transition',
   props: transitionProps,
-  _abstract: true,
+  abstract: true,
   render (h: Function) {
     let children = this.$slots.default
     if (!children) {