1
1
/*!
2
- * Vue.js v2.0.0-rc.8
2
+ * Vue.js v2.0.0
3
3
* (c) 2014-2016 Evan You
4
4
* Released under the MIT License.
5
5
*/
@@ -424,9 +424,13 @@ var nextTick = (function () {
424
424
// "force" the microtask queue to be flushed by adding an empty timer.
425
425
if ( isIOS ) { setTimeout ( noop ) }
426
426
}
427
- } else if ( typeof MutationObserver !== 'undefined' && isNative ( MutationObserver ) ) {
427
+ } else if ( typeof MutationObserver !== 'undefined' && (
428
+ isNative ( MutationObserver ) ||
429
+ // PhantomJS and iOS 7.x
430
+ MutationObserver . toString ( ) === '[object MutationObserverConstructor]'
431
+ ) ) {
428
432
// use MutationObserver where native Promise is not available,
429
- // e.g. IE11, iOS7, Android 4.4
433
+ // e.g. PhantomJS IE11, iOS7, Android 4.4
430
434
var counter = 1
431
435
var observer = new MutationObserver ( nextTickHandler )
432
436
var textNode = document . createTextNode ( String ( counter ) )
@@ -1494,7 +1498,7 @@ function normalizeChildren (
1494
1498
applyNS ( c , ns )
1495
1499
}
1496
1500
// default key for nested array children (likely generated by v-for)
1497
- if ( c . key == null && nestedIndex != null ) {
1501
+ if ( c . tag && c . key == null && nestedIndex != null ) {
1498
1502
c . key = "__vlist_" + nestedIndex + "_" + i + "__"
1499
1503
}
1500
1504
res . push ( c )
@@ -1742,7 +1746,7 @@ function lifecycleMixin (Vue) {
1742
1746
}
1743
1747
// resolve slots + force update if has children
1744
1748
if ( hasChildren ) {
1745
- vm . $slots = resolveSlots ( renderChildren )
1749
+ vm . $slots = resolveSlots ( renderChildren , vm . _renderContext )
1746
1750
vm . $forceUpdate ( )
1747
1751
}
1748
1752
}
@@ -1897,13 +1901,15 @@ function createFunctionalComponent (
1897
1901
}
1898
1902
return Ctor . options . render . call (
1899
1903
null ,
1900
- context . $createElement ,
1904
+ // ensure the createElement function in functional components
1905
+ // gets a unique context - this is necessary for correct named slot check
1906
+ bind$1 ( createElement , { _self : Object . create ( context ) } ) ,
1901
1907
{
1902
1908
props : props ,
1903
1909
data : data ,
1904
1910
parent : context ,
1905
1911
children : normalizeChildren ( children ) ,
1906
- slots : function ( ) { return resolveSlots ( children ) ; }
1912
+ slots : function ( ) { return resolveSlots ( children , context ) ; }
1907
1913
}
1908
1914
)
1909
1915
}
@@ -2158,7 +2164,8 @@ function initRender (vm) {
2158
2164
vm . $vnode = null // the placeholder node in parent tree
2159
2165
vm . _vnode = null // the root of the child tree
2160
2166
vm . _staticTrees = null
2161
- vm . $slots = resolveSlots ( vm . $options . _renderChildren )
2167
+ vm . _renderContext = vm . $options . _parentVnode && vm . $options . _parentVnode . context
2168
+ vm . $slots = resolveSlots ( vm . $options . _renderChildren , vm . _renderContext )
2162
2169
// bind the public createElement fn to this instance
2163
2170
// so that we get proper render context inside it.
2164
2171
vm . $createElement = bind$1 ( createElement , vm )
@@ -2358,7 +2365,8 @@ function renderMixin (Vue) {
2358
2365
}
2359
2366
2360
2367
function resolveSlots (
2361
- renderChildren
2368
+ renderChildren ,
2369
+ context
2362
2370
) {
2363
2371
var slots = { }
2364
2372
if ( ! renderChildren ) {
@@ -2369,8 +2377,10 @@ function resolveSlots (
2369
2377
var name , child
2370
2378
for ( var i = 0 , l = children . length ; i < l ; i ++ ) {
2371
2379
child = children [ i ]
2372
- if ( child . data && ( name = child . data . slot ) ) {
2373
- delete child . data . slot
2380
+ // named slots should only be respected if the vnode was rendered in the
2381
+ // same context.
2382
+ if ( child . context === context &&
2383
+ child . data && ( name = child . data . slot ) ) {
2374
2384
var slot = ( slots [ name ] || ( slots [ name ] = [ ] ) )
2375
2385
if ( child . tag === 'template' ) {
2376
2386
slot . push . apply ( slot , child . children )
@@ -3327,7 +3337,7 @@ Object.defineProperty(Vue$3.prototype, '$isServer', {
3327
3337
get : function ( ) { return config . _isServer ; }
3328
3338
} )
3329
3339
3330
- Vue$3 . version = '2.0.0-rc.8 '
3340
+ Vue$3 . version = '2.0.0'
3331
3341
3332
3342
/* */
3333
3343
@@ -4505,7 +4515,7 @@ function updateStyle (oldVnode, vnode) {
4505
4515
cur = style [ name ]
4506
4516
if ( cur !== oldStyle [ name ] ) {
4507
4517
// ie9 setting to null has no effect, must use empty string
4508
- el . style [ normalize ( name ) ] = cur || ''
4518
+ el . style [ normalize ( name ) ] = cur == null ? '' : cur
4509
4519
}
4510
4520
}
4511
4521
}
@@ -6139,12 +6149,12 @@ function parse (
6139
6149
processFor ( element )
6140
6150
processIf ( element )
6141
6151
processOnce ( element )
6152
+ processKey ( element )
6142
6153
6143
6154
// determine whether this is a plain element after
6144
6155
// removing structural attributes
6145
6156
element . plain = ! element . key && ! attrs . length
6146
6157
6147
- processKey ( element )
6148
6158
processRef ( element )
6149
6159
processSlot ( element )
6150
6160
processComponent ( element )
@@ -6282,6 +6292,9 @@ function processRawAttrs (el) {
6282
6292
function processKey ( el ) {
6283
6293
var exp = getBindingAttr ( el , 'key' )
6284
6294
if ( exp ) {
6295
+ if ( "development" !== 'production' && el . tag === 'template' ) {
6296
+ warn$1 ( "<template> cannot be keyed. Place the key on real elements instead." )
6297
+ }
6285
6298
el . key = exp
6286
6299
}
6287
6300
}
@@ -6740,7 +6753,7 @@ function genFor (el) {
6740
6753
var iterator1 = el . iterator1 ? ( "," + ( el . iterator1 ) ) : ''
6741
6754
var iterator2 = el . iterator2 ? ( "," + ( el . iterator2 ) ) : ''
6742
6755
el . forProcessed = true // avoid recursion
6743
- return "(" + exp + ")&& _l((" + exp + ")," +
6756
+ return "_l((" + exp + ")," +
6744
6757
"function(" + alias + iterator1 + iterator2 + "){" +
6745
6758
"return " + ( genElement ( el ) ) +
6746
6759
'})'
0 commit comments