@@ -1334,15 +1334,10 @@ function applyNS(vnode, ns) {
1334
1334
}
1335
1335
}
1336
1336
1337
- // in case the child is also an abstract component, e.g. <transition-control>
1338
- // we want to recrusively retrieve the real component to be rendered
1339
- function getRealChild ( vnode ) {
1340
- var compOptions = vnode && vnode . componentOptions ;
1341
- if ( compOptions && compOptions . Ctor . options . abstract ) {
1342
- return getRealChild ( compOptions . propsData && compOptions . propsData . child ) ;
1343
- } else {
1344
- return vnode ;
1345
- }
1337
+ function getFirstComponentChild ( children ) {
1338
+ return children && children . filter ( function ( c ) {
1339
+ return c && c . componentOptions ;
1340
+ } ) [ 0 ] ;
1346
1341
}
1347
1342
1348
1343
function mergeVNodeHook ( def , key , hook ) {
@@ -1528,8 +1523,9 @@ function lifecycleMixin(Vue) {
1528
1523
vm . $options . _parentListeners = listeners ;
1529
1524
vm . _updateListeners ( listeners , oldListeners ) ;
1530
1525
}
1531
- // force udpate if has children
1526
+ // resolve slots + force update if has children
1532
1527
if ( hasChildren ) {
1528
+ vm . $slots = resolveSlots ( renderChildren ) ;
1533
1529
vm . $forceUpdate ( ) ;
1534
1530
}
1535
1531
} ;
@@ -1890,7 +1886,7 @@ function initRender(vm) {
1890
1886
vm . $vnode = null ; // the placeholder node in parent tree
1891
1887
vm . _vnode = null ; // the root of the child tree
1892
1888
vm . _staticTrees = null ;
1893
- vm . $slots = { } ;
1889
+ vm . $slots = resolveSlots ( vm . $options . _renderChildren ) ;
1894
1890
// bind the public createElement fn to this instance
1895
1891
// so that we get proper render context inside it.
1896
1892
vm . $createElement = bind ( createElement , vm ) ;
@@ -1909,7 +1905,6 @@ function renderMixin(Vue) {
1909
1905
var _vm$$options = vm . $options ;
1910
1906
var render = _vm$$options . render ;
1911
1907
var staticRenderFns = _vm$$options . staticRenderFns ;
1912
- var _renderChildren = _vm$$options . _renderChildren ;
1913
1908
var _parentVnode = _vm$$options . _parentVnode ;
1914
1909
1915
1910
@@ -1919,9 +1914,6 @@ function renderMixin(Vue) {
1919
1914
// set parent vnode. this allows render functions to have access
1920
1915
// to the data on the placeholder node.
1921
1916
vm . $vnode = _parentVnode ;
1922
- // resolve slots. becaues slots are rendered in parent scope,
1923
- // we set the activeInstance to parent.
1924
- vm . $slots = resolveSlots ( _renderChildren ) ;
1925
1917
// render self
1926
1918
var vnode = void 0 ;
1927
1919
try {
@@ -1965,11 +1957,23 @@ function renderMixin(Vue) {
1965
1957
Vue . prototype . _n = toNumber ;
1966
1958
1967
1959
// render static tree by index
1968
- Vue . prototype . _m = function renderStatic ( index ) {
1960
+ Vue . prototype . _m = function renderStatic ( index , isInFor ) {
1969
1961
var tree = this . _staticTrees [ index ] ;
1970
- if ( ! tree ) {
1971
- tree = this . _staticTrees [ index ] = this . $options . staticRenderFns [ index ] . call ( this . _renderProxy ) ;
1962
+ // if has already-rendered static tree and not inside v-for,
1963
+ // we can reuse the same tree by indentity.
1964
+ if ( tree && ! isInFor ) {
1965
+ return tree ;
1966
+ }
1967
+ // otherwise, render a fresh tree.
1968
+ tree = this . _staticTrees [ index ] = this . $options . staticRenderFns [ index ] . call ( this . _renderProxy ) ;
1969
+ if ( Array . isArray ( tree ) ) {
1970
+ for ( var i = 0 ; i < tree . length ; i ++ ) {
1971
+ tree [ i ] . isStatic = true ;
1972
+ tree [ i ] . key = '__static__' + index + '_' + i ;
1973
+ }
1974
+ } else {
1972
1975
tree . isStatic = true ;
1976
+ tree . key = '__static__' + index ;
1973
1977
}
1974
1978
return tree ;
1975
1979
} ;
@@ -2020,12 +2024,12 @@ function renderMixin(Vue) {
2020
2024
value = toObject ( value ) ;
2021
2025
}
2022
2026
var data = vnode . data ;
2023
- for ( var key in value ) {
2024
- if ( key === 'class' || key === 'style' ) {
2025
- data [ key ] = value [ key ] ;
2027
+ for ( var _key in value ) {
2028
+ if ( _key === 'class' || _key === 'style' ) {
2029
+ data [ _key ] = value [ _key ] ;
2026
2030
} else {
2027
- var hash = asProp || config . mustUseProp ( key ) ? data . domProps || ( data . domProps = { } ) : data . attrs || ( data . attrs = { } ) ;
2028
- hash [ key ] = value [ key ] ;
2031
+ var hash = asProp || config . mustUseProp ( _key ) ? data . domProps || ( data . domProps = { } ) : data . attrs || ( data . attrs = { } ) ;
2032
+ hash [ _key ] = value [ _key ] ;
2029
2033
}
2030
2034
}
2031
2035
}
@@ -2803,29 +2807,26 @@ function initAssetRegisters(Vue) {
2803
2807
var KeepAlive = {
2804
2808
name : 'keep-alive' ,
2805
2809
abstract : true ,
2806
- props : {
2807
- child : Object
2808
- } ,
2809
2810
created : function created ( ) {
2810
2811
this . cache = Object . create ( null ) ;
2811
2812
} ,
2812
2813
render : function render ( ) {
2813
- var rawChild = this . child ;
2814
- var realChild = getRealChild ( this . child ) ;
2815
- if ( realChild && realChild . componentOptions ) {
2816
- var opts = realChild . componentOptions ;
2814
+ var vnode = getFirstComponentChild ( this . $slots . default ) ;
2815
+ if ( vnode && vnode . componentOptions ) {
2816
+ var opts = vnode . componentOptions ;
2817
+ var key = vnode . key == null
2817
2818
// same constructor may get registered as different local components
2818
2819
// so cid alone is not enough (#3269)
2819
- var key = opts . Ctor . cid + '::' + opts . tag ;
2820
+ ? opts . Ctor . cid + '::' + opts . tag : vnode . key ;
2820
2821
if ( this . cache [ key ] ) {
2821
- var child = realChild . child = this . cache [ key ] . child ;
2822
- realChild . elm = this . $el = child . $el ;
2822
+ var child = vnode . child = this . cache [ key ] . child ;
2823
+ vnode . elm = this . $el = child . $el ;
2823
2824
} else {
2824
- this . cache [ key ] = realChild ;
2825
+ this . cache [ key ] = vnode ;
2825
2826
}
2826
- realChild . data . keepAlive = true ;
2827
+ vnode . data . keepAlive = true ;
2827
2828
}
2828
- return rawChild ;
2829
+ return vnode ;
2829
2830
} ,
2830
2831
destroyed : function destroyed ( ) {
2831
2832
for ( var key in this . cache ) {
@@ -2878,7 +2879,7 @@ Object.defineProperty(Vue.prototype, '$isServer', {
2878
2879
}
2879
2880
} ) ;
2880
2881
2881
- Vue . version = '2.0.0-beta.7 ' ;
2882
+ Vue . version = '2.0.0-beta.8 ' ;
2882
2883
2883
2884
// attributes that should be using props for binding
2884
2885
var mustUseProp = makeMap ( 'value,selected,checked,muted' ) ;
@@ -3035,8 +3036,10 @@ var isIE = UA$1 && /msie|trident/.test(UA$1);
3035
3036
var isIE9 = UA$1 && UA$1 . indexOf ( 'msie 9.0' ) > 0 ;
3036
3037
var isAndroid = UA$1 && UA$1 . indexOf ( 'android' ) > 0 ;
3037
3038
3038
- // some browsers, e.g. PhantomJS, encodes angular brackets
3039
- // inside attribute values when retrieving innerHTML.
3039
+ // According to
3040
+ // https://w3c.github.io/DOM-Parsing/#dfn-serializing-an-attribute-value
3041
+ // when serializing innerHTML, <, >, ", & should be encoded as entities.
3042
+ // However, only some browsers, e.g. PhantomJS, encodes < and >.
3040
3043
// this causes problems with the in-browser parser.
3041
3044
var shouldDecodeTags = inBrowser ? function ( ) {
3042
3045
var div = document . createElement ( 'div' ) ;
@@ -3140,9 +3143,6 @@ function isDef(s) {
3140
3143
}
3141
3144
3142
3145
function sameVnode ( vnode1 , vnode2 ) {
3143
- if ( vnode1 . isStatic || vnode2 . isStatic ) {
3144
- return vnode1 === vnode2 ;
3145
- }
3146
3146
return vnode1 . key === vnode2 . key && vnode1 . tag === vnode2 . tag && vnode1 . isComment === vnode2 . isComment && ! vnode1 . data === ! vnode2 . data ;
3147
3147
}
3148
3148
@@ -3384,8 +3384,8 @@ function createPatchFunction(backend) {
3384
3384
newStartVnode = newCh [ ++ newStartIdx ] ;
3385
3385
} else {
3386
3386
if ( isUndef ( oldKeyToIdx ) ) oldKeyToIdx = createKeyToOldIdx ( oldCh , oldStartIdx , oldEndIdx ) ;
3387
- idxInOld = isDef ( newStartVnode . key ) ? oldKeyToIdx [ newStartVnode . key ] : newStartVnode . isStatic ? oldCh . indexOf ( newStartVnode ) : null ;
3388
- if ( isUndef ( idxInOld ) || idxInOld === - 1 ) {
3387
+ idxInOld = isDef ( newStartVnode . key ) ? oldKeyToIdx [ newStartVnode . key ] : null ;
3388
+ if ( isUndef ( idxInOld ) ) {
3389
3389
// New element
3390
3390
nodeOps . insertBefore ( parentElm , createElm ( newStartVnode , insertedVnodeQueue ) , oldStartVnode . elm ) ;
3391
3391
newStartVnode = newCh [ ++ newStartIdx ] ;
@@ -3417,7 +3417,13 @@ function createPatchFunction(backend) {
3417
3417
}
3418
3418
3419
3419
function patchVnode ( oldVnode , vnode , insertedVnodeQueue , removeOnly ) {
3420
- if ( oldVnode === vnode ) return ;
3420
+ if ( oldVnode === vnode ) {
3421
+ return ;
3422
+ }
3423
+ if ( vnode . isStatic && oldVnode . isStatic && vnode . key === oldVnode . key ) {
3424
+ vnode . elm = oldVnode . elm ;
3425
+ return ;
3426
+ }
3421
3427
var i = void 0 ,
3422
3428
hook = void 0 ;
3423
3429
var hasData = isDef ( i = vnode . data ) ;
@@ -4072,7 +4078,7 @@ function enter(vnode) {
4072
4078
}
4073
4079
4074
4080
/* istanbul ignore if */
4075
- if ( el . _enterCb ) {
4081
+ if ( el . _enterCb || el . nodeType !== 1 ) {
4076
4082
return ;
4077
4083
}
4078
4084
@@ -4176,7 +4182,7 @@ function leave(vnode, rm) {
4176
4182
}
4177
4183
4178
4184
/* istanbul ignore if */
4179
- if ( el . _leaveCb ) {
4185
+ if ( el . _leaveCb || el . nodeType !== 1 ) {
4180
4186
return ;
4181
4187
}
4182
4188
@@ -4429,7 +4435,10 @@ var show = {
4429
4435
} ,
4430
4436
update : function update ( el , _ref2 , vnode ) {
4431
4437
var value = _ref2 . value ;
4438
+ var oldValue = _ref2 . oldValue ;
4432
4439
4440
+ /* istanbul ignore if */
4441
+ if ( value === oldValue ) return ;
4433
4442
vnode = locateNode ( vnode ) ;
4434
4443
var transition = vnode . data && vnode . data . transition ;
4435
4444
if ( transition && ! isIE9 ) {
@@ -4466,6 +4475,17 @@ var transitionProps = {
4466
4475
appearActiveClass : String
4467
4476
} ;
4468
4477
4478
+ // in case the child is also an abstract component, e.g. <keep-alive>
4479
+ // we want to recrusively retrieve the real component to be rendered
4480
+ function getRealChild ( vnode ) {
4481
+ var compOptions = vnode && vnode . componentOptions ;
4482
+ if ( compOptions && compOptions . Ctor . options . abstract ) {
4483
+ return getRealChild ( getFirstComponentChild ( compOptions . children ) ) ;
4484
+ } else {
4485
+ return vnode ;
4486
+ }
4487
+ }
4488
+
4469
4489
function extractTransitionData ( comp ) {
4470
4490
var data = { } ;
4471
4491
var options = comp . $options ;
@@ -4527,8 +4547,11 @@ var Transition = {
4527
4547
// use getRealChild() to ignore abstract components e.g. keep-alive
4528
4548
var child = getRealChild ( rawChild ) ;
4529
4549
/* istanbul ignore if */
4530
- if ( ! child ) return ;
4531
- child . key = child . key || '__v' + ( child . tag + this . _uid ) + '__' ;
4550
+ if ( ! child ) {
4551
+ return rawChild ;
4552
+ }
4553
+
4554
+ child . key = child . key == null ? '__v' + ( child . tag + this . _uid ) + '__' : child . key ;
4532
4555
var data = ( child . data || ( child . data = { } ) ) . transition = extractTransitionData ( this ) ;
4533
4556
var oldRawChild = this . _vnode ;
4534
4557
var oldChild = getRealChild ( oldRawChild ) ;
0 commit comments