11/*!
2- * Vue.js v2.0.0-rc.8
2+ * Vue.js v2.0.0
33 * (c) 2014-2016 Evan You
44 * Released under the MIT License.
55 */
@@ -424,9 +424,13 @@ var nextTick = (function () {
424424 // "force" the microtask queue to be flushed by adding an empty timer.
425425 if ( isIOS ) { setTimeout ( noop ) }
426426 }
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+ ) ) {
428432 // 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
430434 var counter = 1
431435 var observer = new MutationObserver ( nextTickHandler )
432436 var textNode = document . createTextNode ( String ( counter ) )
@@ -1494,7 +1498,7 @@ function normalizeChildren (
14941498 applyNS ( c , ns )
14951499 }
14961500 // 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 ) {
14981502 c . key = "__vlist_" + nestedIndex + "_" + i + "__"
14991503 }
15001504 res . push ( c )
@@ -1742,7 +1746,7 @@ function lifecycleMixin (Vue) {
17421746 }
17431747 // resolve slots + force update if has children
17441748 if ( hasChildren ) {
1745- vm . $slots = resolveSlots ( renderChildren )
1749+ vm . $slots = resolveSlots ( renderChildren , vm . _renderContext )
17461750 vm . $forceUpdate ( )
17471751 }
17481752 }
@@ -1897,13 +1901,15 @@ function createFunctionalComponent (
18971901 }
18981902 return Ctor . options . render . call (
18991903 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+ bind1ドル ( createElement , { _self : Object . create ( context ) } ) ,
19011907 {
19021908 props : props ,
19031909 data : data ,
19041910 parent : context ,
19051911 children : normalizeChildren ( children ) ,
1906- slots : function ( ) { return resolveSlots ( children ) ; }
1912+ slots : function ( ) { return resolveSlots ( children , context ) ; }
19071913 }
19081914 )
19091915}
@@ -2158,7 +2164,8 @@ function initRender (vm) {
21582164 vm . $vnode = null // the placeholder node in parent tree
21592165 vm . _vnode = null // the root of the child tree
21602166 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 )
21622169 // bind the public createElement fn to this instance
21632170 // so that we get proper render context inside it.
21642171 vm . $createElement = bind1ドル ( createElement , vm )
@@ -2358,7 +2365,8 @@ function renderMixin (Vue) {
23582365}
23592366
23602367function resolveSlots (
2361- renderChildren
2368+ renderChildren ,
2369+ context
23622370) {
23632371 var slots = { }
23642372 if ( ! renderChildren ) {
@@ -2369,8 +2377,10 @@ function resolveSlots (
23692377 var name , child
23702378 for ( var i = 0 , l = children . length ; i < l ; i ++ ) {
23712379 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 ) ) {
23742384 var slot = ( slots [ name ] || ( slots [ name ] = [ ] ) )
23752385 if ( child . tag === 'template' ) {
23762386 slot . push . apply ( slot , child . children )
@@ -3327,7 +3337,7 @@ Object.defineProperty(Vue3ドル.prototype, '$isServer', {
33273337 get : function ( ) { return config . _isServer ; }
33283338} )
33293339
3330- Vue3ドル . version = '2.0.0-rc.8 '
3340+ Vue3ドル . version = '2.0.0'
33313341
33323342/* */
33333343
@@ -4505,7 +4515,7 @@ function updateStyle (oldVnode, vnode) {
45054515 cur = style [ name ]
45064516 if ( cur !== oldStyle [ name ] ) {
45074517 // 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
45094519 }
45104520 }
45114521}
@@ -6139,12 +6149,12 @@ function parse (
61396149 processFor ( element )
61406150 processIf ( element )
61416151 processOnce ( element )
6152+ processKey ( element )
61426153
61436154 // determine whether this is a plain element after
61446155 // removing structural attributes
61456156 element . plain = ! element . key && ! attrs . length
61466157
6147- processKey ( element )
61486158 processRef ( element )
61496159 processSlot ( element )
61506160 processComponent ( element )
@@ -6282,6 +6292,9 @@ function processRawAttrs (el) {
62826292function processKey ( el ) {
62836293 var exp = getBindingAttr ( el , 'key' )
62846294 if ( exp ) {
6295+ if ( "development" !== 'production' && el . tag === 'template' ) {
6296+ warn1ドル ( "<template> cannot be keyed. Place the key on real elements instead." )
6297+ }
62856298 el . key = exp
62866299 }
62876300}
@@ -6740,7 +6753,7 @@ function genFor (el) {
67406753 var iterator1 = el . iterator1 ? ( "," + ( el . iterator1 ) ) : ''
67416754 var iterator2 = el . iterator2 ? ( "," + ( el . iterator2 ) ) : ''
67426755 el . forProcessed = true // avoid recursion
6743- return "(" + exp + ")&& _l((" + exp + ")," +
6756+ return "_l((" + exp + ")," +
67446757 "function(" + alias + iterator1 + iterator2 + "){" +
67456758 "return " + ( genElement ( el ) ) +
67466759 '})'
0 commit comments