@@ -355,18 +355,16 @@ var nextTick = function () {
355
355
356
356
/* istanbul ignore else */
357
357
if ( typeof MutationObserver !== 'undefined' && ! hasMutationObserverBug ) {
358
- ( function ( ) {
359
- var counter = 1 ;
360
- var observer = new MutationObserver ( nextTickHandler ) ;
361
- var textNode = document . createTextNode ( String ( counter ) ) ;
362
- observer . observe ( textNode , {
363
- characterData : true
364
- } ) ;
365
- timerFunc = function timerFunc ( ) {
366
- counter = ( counter + 1 ) % 2 ;
367
- textNode . data = String ( counter ) ;
368
- } ;
369
- } ) ( ) ;
358
+ var counter = 1 ;
359
+ var observer = new MutationObserver ( nextTickHandler ) ;
360
+ var textNode = document . createTextNode ( String ( counter ) ) ;
361
+ observer . observe ( textNode , {
362
+ characterData : true
363
+ } ) ;
364
+ timerFunc = function timerFunc ( ) {
365
+ counter = ( counter + 1 ) % 2 ;
366
+ textNode . data = String ( counter ) ;
367
+ } ;
370
368
} else {
371
369
// webpack attempts to inject a shim for setImmediate
372
370
// if it is used as a global, so we have to work around that to
@@ -418,19 +416,19 @@ var proxyHandlers = void 0;
418
416
var initProxy = void 0 ;
419
417
if ( process . env . NODE_ENV !== 'production' ) {
420
418
( function ( ) {
421
- var allowedGlobals = makeMap ( 'Infinity,undefined,NaN,isFinite,isNaN,' + 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + 'require,__webpack_require__ ' // for Webpack/Browserify
419
+ var allowedGlobals = makeMap ( 'Infinity,undefined,NaN,isFinite,isNaN,' + 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + 'require' // for Webpack/Browserify
422
420
) ;
423
421
424
422
hasProxy = typeof Proxy !== 'undefined' && Proxy . toString ( ) . match ( / n a t i v e c o d e / ) ;
425
423
426
424
proxyHandlers = {
427
425
has : function has ( target , key ) {
428
426
var has = key in target ;
429
- var isAllowedGlobal = allowedGlobals ( key ) ;
430
- if ( ! has && ! isAllowedGlobal ) {
427
+ var isAllowed = allowedGlobals ( key ) || key . charAt ( 0 ) === '_' ;
428
+ if ( ! has && ! isAllowed ) {
431
429
warn ( 'Property or method "' + key + '" is not defined on the instance but ' + 'referenced during render. Make sure to declare reactive data ' + 'properties in the data option.' , target ) ;
432
430
}
433
- return ! isAllowedGlobal ;
431
+ return has || ! isAllowed ;
434
432
}
435
433
} ;
436
434
@@ -1217,6 +1215,9 @@ function stateMixin(Vue) {
1217
1215
}
1218
1216
Object . defineProperty ( Vue . prototype , '$data' , dataDef ) ;
1219
1217
1218
+ Vue . prototype . $set = set ;
1219
+ Vue . prototype . $delete = del ;
1220
+
1220
1221
Vue . prototype . $watch = function ( expOrFn , cb , options ) {
1221
1222
var vm = this ;
1222
1223
options = options || { } ;
@@ -1631,28 +1632,7 @@ function createComponent(Ctor, data, context, children, tag) {
1631
1632
1632
1633
// functional component
1633
1634
if ( Ctor . options . functional ) {
1634
- var _ret = function ( ) {
1635
- var props = { } ;
1636
- var propOptions = Ctor . options . props ;
1637
- if ( propOptions ) {
1638
- Object . keys ( propOptions ) . forEach ( function ( key ) {
1639
- props [ key ] = validateProp ( key , propOptions , propsData ) ;
1640
- } ) ;
1641
- }
1642
- return {
1643
- v : Ctor . options . render . call ( null , context . $createElement , {
1644
- props : props ,
1645
- data : data ,
1646
- parent : context ,
1647
- children : normalizeChildren ( children ) ,
1648
- slots : function slots ( ) {
1649
- return resolveSlots ( children ) ;
1650
- }
1651
- } )
1652
- } ;
1653
- } ( ) ;
1654
-
1655
- if ( typeof _ret === "object" ) return _ret . v ;
1635
+ return createFunctionalComponent ( Ctor , propsData , data , context , children ) ;
1656
1636
}
1657
1637
1658
1638
// extract listeners, since these needs to be treated as
@@ -1676,6 +1656,25 @@ function createComponent(Ctor, data, context, children, tag) {
1676
1656
return vnode ;
1677
1657
}
1678
1658
1659
+ function createFunctionalComponent ( Ctor , propsData , data , context , children ) {
1660
+ var props = { } ;
1661
+ var propOptions = Ctor . options . props ;
1662
+ if ( propOptions ) {
1663
+ for ( var key in propOptions ) {
1664
+ props [ key ] = validateProp ( key , propOptions , propsData ) ;
1665
+ }
1666
+ }
1667
+ return Ctor . options . render . call ( null , context . $createElement , {
1668
+ props : props ,
1669
+ data : data ,
1670
+ parent : context ,
1671
+ children : normalizeChildren ( children ) ,
1672
+ slots : function slots ( ) {
1673
+ return resolveSlots ( children ) ;
1674
+ }
1675
+ } ) ;
1676
+ }
1677
+
1679
1678
function createComponentInstanceForVnode ( vnode , // we know it's MountedComponentVNode but flow doesn't
1680
1679
parent // activeInstance in lifecycle state
1681
1680
) {
@@ -1742,7 +1741,7 @@ function resolveAsyncComponent(factory, cb) {
1742
1741
// pool callbacks
1743
1742
factory . pendingCallbacks . push ( cb ) ;
1744
1743
} else {
1745
- var _ret2 = function ( ) {
1744
+ var _ret = function ( ) {
1746
1745
factory . requested = true ;
1747
1746
var cbs = factory . pendingCallbacks = [ cb ] ;
1748
1747
var sync = true ;
@@ -1773,7 +1772,7 @@ function resolveAsyncComponent(factory, cb) {
1773
1772
} ;
1774
1773
} ( ) ;
1775
1774
1776
- if ( typeof _ret2 === "object" ) return _ret2 . v ;
1775
+ if ( typeof _ret === "object" ) return _ret . v ;
1777
1776
}
1778
1777
}
1779
1778
@@ -2245,7 +2244,7 @@ if (process.env.NODE_ENV !== 'production') {
2245
2244
2246
2245
var formatLocation = function formatLocation ( str ) {
2247
2246
if ( str === 'anonymous component' ) {
2248
- str += ' - use the "name" option for better debugging messages.) ' ;
2247
+ str += ' - use the "name" option for better debugging messages.' ;
2249
2248
}
2250
2249
return '(found in ' + str + ')' ;
2251
2250
} ;
@@ -2271,7 +2270,7 @@ if (process.env.NODE_ENV !== 'production') {
2271
2270
} ;
2272
2271
2273
2272
strats . name = function ( parent , child , vm ) {
2274
- if ( vm ) {
2273
+ if ( vm && child ) {
2275
2274
warn ( 'options "name" can only be used as a component definition option, ' + 'not during instance creation.' ) ;
2276
2275
}
2277
2276
return defaultStrat ( parent , child ) ;
@@ -2879,7 +2878,7 @@ Object.defineProperty(Vue.prototype, '$isServer', {
2879
2878
}
2880
2879
} ) ;
2881
2880
2882
- Vue . version = '2.0.0-rc.2 ' ;
2881
+ Vue . version = '2.0.0-rc.3 ' ;
2883
2882
2884
2883
// attributes that should be using props for binding
2885
2884
var mustUseProp = makeMap ( 'value,selected,checked,muted' ) ;
@@ -3130,6 +3129,47 @@ var nodeOps = Object.freeze({
3130
3129
setAttribute : setAttribute
3131
3130
} ) ;
3132
3131
3132
+ var ref = {
3133
+ create : function create ( _ , vnode ) {
3134
+ registerRef ( vnode ) ;
3135
+ } ,
3136
+ update : function update ( oldVnode , vnode ) {
3137
+ if ( oldVnode . data . ref !== vnode . data . ref ) {
3138
+ registerRef ( oldVnode , true ) ;
3139
+ registerRef ( vnode ) ;
3140
+ }
3141
+ } ,
3142
+ destroy : function destroy ( vnode ) {
3143
+ registerRef ( vnode , true ) ;
3144
+ }
3145
+ } ;
3146
+
3147
+ function registerRef ( vnode , isRemoval ) {
3148
+ var key = vnode . data . ref ;
3149
+ if ( ! key ) return ;
3150
+
3151
+ var vm = vnode . context ;
3152
+ var ref = vnode . child || vnode . elm ;
3153
+ var refs = vm . $refs ;
3154
+ if ( isRemoval ) {
3155
+ if ( Array . isArray ( refs [ key ] ) ) {
3156
+ remove ( refs [ key ] , ref ) ;
3157
+ } else if ( refs [ key ] === ref ) {
3158
+ refs [ key ] = undefined ;
3159
+ }
3160
+ } else {
3161
+ if ( vnode . data . refInFor ) {
3162
+ if ( Array . isArray ( refs [ key ] ) ) {
3163
+ refs [ key ] . push ( ref ) ;
3164
+ } else {
3165
+ refs [ key ] = [ ref ] ;
3166
+ }
3167
+ } else {
3168
+ refs [ key ] = ref ;
3169
+ }
3170
+ }
3171
+ }
3172
+
3133
3173
var emptyData = { } ;
3134
3174
var emptyNode = new VNode ( '' , emptyData , [ ] ) ;
3135
3175
var hooks$1 = [ 'create' , 'update' , 'postpatch' , 'remove' , 'destroy' ] ;
@@ -3263,6 +3303,10 @@ function createPatchFunction(backend) {
3263
3303
invokeCreateHooks ( vnode , insertedVnodeQueue ) ;
3264
3304
setScope ( vnode ) ;
3265
3305
} else {
3306
+ // empty component root.
3307
+ // skip all element-related modules except for ref (#3455)
3308
+ registerRef ( vnode ) ;
3309
+ // make sure to invoke the insert hook
3266
3310
insertedVnodeQueue . push ( vnode ) ;
3267
3311
}
3268
3312
}
@@ -3311,8 +3355,8 @@ function createPatchFunction(backend) {
3311
3355
var ch = vnodes [ startIdx ] ;
3312
3356
if ( isDef ( ch ) ) {
3313
3357
if ( isDef ( ch . tag ) ) {
3314
- invokeDestroyHook ( ch ) ;
3315
3358
removeAndInvokeRemoveHook ( ch ) ;
3359
+ invokeDestroyHook ( ch ) ;
3316
3360
} else {
3317
3361
// Text node
3318
3362
nodeOps . removeChild ( parentElm , ch . elm ) ;
@@ -3644,47 +3688,6 @@ function applyDirectives(oldVnode, vnode, hook) {
3644
3688
}
3645
3689
}
3646
3690
3647
- var ref = {
3648
- create : function create ( _ , vnode ) {
3649
- registerRef ( vnode ) ;
3650
- } ,
3651
- update : function update ( oldVnode , vnode ) {
3652
- if ( oldVnode . data . ref !== vnode . data . ref ) {
3653
- registerRef ( oldVnode , true ) ;
3654
- registerRef ( vnode ) ;
3655
- }
3656
- } ,
3657
- destroy : function destroy ( vnode ) {
3658
- registerRef ( vnode , true ) ;
3659
- }
3660
- } ;
3661
-
3662
- function registerRef ( vnode , isRemoval ) {
3663
- var key = vnode . data . ref ;
3664
- if ( ! key ) return ;
3665
-
3666
- var vm = vnode . context ;
3667
- var ref = vnode . child || vnode . elm ;
3668
- var refs = vm . $refs ;
3669
- if ( isRemoval ) {
3670
- if ( Array . isArray ( refs [ key ] ) ) {
3671
- remove ( refs [ key ] , ref ) ;
3672
- } else if ( refs [ key ] === ref ) {
3673
- refs [ key ] = undefined ;
3674
- }
3675
- } else {
3676
- if ( vnode . data . refInFor ) {
3677
- if ( Array . isArray ( refs [ key ] ) ) {
3678
- refs [ key ] . push ( ref ) ;
3679
- } else {
3680
- refs [ key ] = [ ref ] ;
3681
- }
3682
- } else {
3683
- refs [ key ] = ref ;
3684
- }
3685
- }
3686
- }
3687
-
3688
3691
var baseModules = [ ref , directives ] ;
3689
3692
3690
3693
function updateAttrs ( oldVnode , vnode ) {
@@ -4154,14 +4157,21 @@ function enter(vnode) {
4154
4157
4155
4158
if ( ! vnode . data . show ) {
4156
4159
// remove pending leave element on enter by injecting an insert hook
4157
- mergeVNodeHook ( vnode . data . hook || ( vnode . data . hook = { } ) , 'insert' , function ( ) {
4160
+ var hooks = vnode . data . hook || ( vnode . data . hook = { } ) ;
4161
+ hooks . _transitionInsert = function ( ) {
4158
4162
var parent = el . parentNode ;
4159
- var pendingNode = parent . _pending && parent . _pending [ vnode . key ] ;
4163
+ var pendingNode = parent && parent . _pending && parent . _pending [ vnode . key ] ;
4160
4164
if ( pendingNode && pendingNode . tag === vnode . tag && pendingNode . elm . _leaveCb ) {
4161
4165
pendingNode . elm . _leaveCb ( ) ;
4162
4166
}
4163
4167
enterHook && enterHook ( el , cb ) ;
4164
- } ) ;
4168
+ } ;
4169
+ if ( ! vnode . data . transitionInjected ) {
4170
+ vnode . data . transitionInjected = true ;
4171
+ mergeVNodeHook ( hooks , 'insert' , function ( ) {
4172
+ hooks . _transitionInsert ( ) ;
4173
+ } ) ;
4174
+ }
4165
4175
}
4166
4176
4167
4177
// start enter transition
@@ -4450,7 +4460,7 @@ var show = {
4450
4460
if ( value && transition && transition . appear && ! isIE9 ) {
4451
4461
enter ( vnode ) ;
4452
4462
}
4453
- var originalDisplay = el . style . display ;
4463
+ var originalDisplay = el . style . display === 'none' ? '' : el . style . display ;
4454
4464
el . style . display = value ? originalDisplay : 'none' ;
4455
4465
el . __vOriginalDisplay = originalDisplay ;
4456
4466
} ,
@@ -4594,6 +4604,14 @@ var Transition = {
4594
4604
var oldRawChild = this . _vnode ;
4595
4605
var oldChild = getRealChild ( oldRawChild ) ;
4596
4606
4607
+ // mark v-show
4608
+ // so that the transition module can hand over the control to the directive
4609
+ if ( child . data . directives && child . data . directives . some ( function ( d ) {
4610
+ return d . name === 'show' ;
4611
+ } ) ) {
4612
+ child . data . show = true ;
4613
+ }
4614
+
4597
4615
if ( oldChild && oldChild . data && oldChild . key !== child . key ) {
4598
4616
// replace old child transition data with fresh one
4599
4617
// important for dynamic transitions!
@@ -4609,17 +4627,15 @@ var Transition = {
4609
4627
} ) ;
4610
4628
return placeholder ( h , rawChild ) ;
4611
4629
} else if ( mode === 'in-out' ) {
4612
- ( function ( ) {
4613
- var delayedLeave = void 0 ;
4614
- var performLeave = function performLeave ( ) {
4615
- delayedLeave ( ) ;
4616
- } ;
4617
- mergeVNodeHook ( data , 'afterEnter' , performLeave ) ;
4618
- mergeVNodeHook ( data , 'enterCancelled' , performLeave ) ;
4619
- mergeVNodeHook ( oldData , 'delayLeave' , function ( leave ) {
4620
- delayedLeave = leave ;
4621
- } ) ;
4622
- } ) ( ) ;
4630
+ var delayedLeave ;
4631
+ var performLeave = function performLeave ( ) {
4632
+ delayedLeave ( ) ;
4633
+ } ;
4634
+ mergeVNodeHook ( data , 'afterEnter' , performLeave ) ;
4635
+ mergeVNodeHook ( data , 'enterCancelled' , performLeave ) ;
4636
+ mergeVNodeHook ( oldData , 'delayLeave' , function ( leave ) {
4637
+ delayedLeave = leave ;
4638
+ } ) ;
4623
4639
}
4624
4640
}
4625
4641
@@ -4718,20 +4734,18 @@ var TransitionGroup = {
4718
4734
4719
4735
children . forEach ( function ( c ) {
4720
4736
if ( c . data . moved ) {
4721
- ( function ( ) {
4722
- var el = c . elm ;
4723
- var s = el . style ;
4724
- addTransitionClass ( el , moveClass ) ;
4725
- s . transform = s . WebkitTransform = s . transitionDuration = '' ;
4726
- el . _moveDest = c . data . pos ;
4727
- el . addEventListener ( transitionEndEvent , el . _moveCb = function cb ( e ) {
4728
- if ( ! e || / t r a n s f o r m $ / . test ( e . propertyName ) ) {
4729
- el . removeEventListener ( transitionEndEvent , cb ) ;
4730
- el . _moveCb = null ;
4731
- removeTransitionClass ( el , moveClass ) ;
4732
- }
4733
- } ) ;
4734
- } ) ( ) ;
4737
+ var el = c . elm ;
4738
+ var s = el . style ;
4739
+ addTransitionClass ( el , moveClass ) ;
4740
+ s . transform = s . WebkitTransform = s . transitionDuration = '' ;
4741
+ el . _moveDest = c . data . pos ;
4742
+ el . addEventListener ( transitionEndEvent , el . _moveCb = function cb ( e ) {
4743
+ if ( ! e || / t r a n s f o r m $ / . test ( e . propertyName ) ) {
4744
+ el . removeEventListener ( transitionEndEvent , cb ) ;
4745
+ el . _moveCb = null ;
4746
+ removeTransitionClass ( el , moveClass ) ;
4747
+ }
4748
+ } ) ;
4735
4749
}
4736
4750
} ) ;
4737
4751
} ,
0 commit comments