@@ -355,18 +355,16 @@ var nextTick = function () {
355355
356356 /* istanbul ignore else */
357357 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+ } ;
370368 } else {
371369 // webpack attempts to inject a shim for setImmediate
372370 // if it is used as a global, so we have to work around that to
@@ -418,19 +416,19 @@ var proxyHandlers = void 0;
418416var initProxy = void 0 ;
419417if ( process . env . NODE_ENV !== 'production' ) {
420418 ( 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
422420 ) ;
423421
424422 hasProxy = typeof Proxy !== 'undefined' && Proxy . toString ( ) . match ( / n a t i v e c o d e / ) ;
425423
426424 proxyHandlers = {
427425 has : function has ( target , key ) {
428426 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 ) {
431429 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 ) ;
432430 }
433- return ! isAllowedGlobal ;
431+ return has || ! isAllowed ;
434432 }
435433 } ;
436434
@@ -1217,6 +1215,9 @@ function stateMixin(Vue) {
12171215 }
12181216 Object . defineProperty ( Vue . prototype , '$data' , dataDef ) ;
12191217
1218+ Vue . prototype . $set = set ;
1219+ Vue . prototype . $delete = del ;
1220+
12201221 Vue . prototype . $watch = function ( expOrFn , cb , options ) {
12211222 var vm = this ;
12221223 options = options || { } ;
@@ -1631,28 +1632,7 @@ function createComponent(Ctor, data, context, children, tag) {
16311632
16321633 // functional component
16331634 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 ) ;
16561636 }
16571637
16581638 // extract listeners, since these needs to be treated as
@@ -1676,6 +1656,25 @@ function createComponent(Ctor, data, context, children, tag) {
16761656 return vnode ;
16771657}
16781658
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+
16791678function createComponentInstanceForVnode ( vnode , // we know it's MountedComponentVNode but flow doesn't
16801679parent // activeInstance in lifecycle state
16811680) {
@@ -1742,7 +1741,7 @@ function resolveAsyncComponent(factory, cb) {
17421741 // pool callbacks
17431742 factory . pendingCallbacks . push ( cb ) ;
17441743 } else {
1745- var _ret2 = function ( ) {
1744+ var _ret = function ( ) {
17461745 factory . requested = true ;
17471746 var cbs = factory . pendingCallbacks = [ cb ] ;
17481747 var sync = true ;
@@ -1773,7 +1772,7 @@ function resolveAsyncComponent(factory, cb) {
17731772 } ;
17741773 } ( ) ;
17751774
1776- if ( typeof _ret2 === "object" ) return _ret2 . v ;
1775+ if ( typeof _ret === "object" ) return _ret . v ;
17771776 }
17781777}
17791778
@@ -2245,7 +2244,7 @@ if (process.env.NODE_ENV !== 'production') {
22452244
22462245 var formatLocation = function formatLocation ( str ) {
22472246 if ( str === 'anonymous component' ) {
2248- str += ' - use the "name" option for better debugging messages.) ' ;
2247+ str += ' - use the "name" option for better debugging messages.' ;
22492248 }
22502249 return '(found in ' + str + ')' ;
22512250 } ;
@@ -2271,7 +2270,7 @@ if (process.env.NODE_ENV !== 'production') {
22712270 } ;
22722271
22732272 strats . name = function ( parent , child , vm ) {
2274- if ( vm ) {
2273+ if ( vm && child ) {
22752274 warn ( 'options "name" can only be used as a component definition option, ' + 'not during instance creation.' ) ;
22762275 }
22772276 return defaultStrat ( parent , child ) ;
@@ -2879,7 +2878,7 @@ Object.defineProperty(Vue.prototype, '$isServer', {
28792878 }
28802879} ) ;
28812880
2882- Vue . version = '2.0.0-rc.2 ' ;
2881+ Vue . version = '2.0.0-rc.3 ' ;
28832882
28842883// attributes that should be using props for binding
28852884var mustUseProp = makeMap ( 'value,selected,checked,muted' ) ;
@@ -3130,6 +3129,47 @@ var nodeOps = Object.freeze({
31303129 setAttribute : setAttribute
31313130} ) ;
31323131
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+
31333173var emptyData = { } ;
31343174var emptyNode = new VNode ( '' , emptyData , [ ] ) ;
31353175var hooks$1 = [ 'create' , 'update' , 'postpatch' , 'remove' , 'destroy' ] ;
@@ -3263,6 +3303,10 @@ function createPatchFunction(backend) {
32633303 invokeCreateHooks ( vnode , insertedVnodeQueue ) ;
32643304 setScope ( vnode ) ;
32653305 } 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
32663310 insertedVnodeQueue . push ( vnode ) ;
32673311 }
32683312 }
@@ -3311,8 +3355,8 @@ function createPatchFunction(backend) {
33113355 var ch = vnodes [ startIdx ] ;
33123356 if ( isDef ( ch ) ) {
33133357 if ( isDef ( ch . tag ) ) {
3314- invokeDestroyHook ( ch ) ;
33153358 removeAndInvokeRemoveHook ( ch ) ;
3359+ invokeDestroyHook ( ch ) ;
33163360 } else {
33173361 // Text node
33183362 nodeOps . removeChild ( parentElm , ch . elm ) ;
@@ -3644,47 +3688,6 @@ function applyDirectives(oldVnode, vnode, hook) {
36443688 }
36453689}
36463690
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-
36883691var baseModules = [ ref , directives ] ;
36893692
36903693function updateAttrs ( oldVnode , vnode ) {
@@ -4154,14 +4157,21 @@ function enter(vnode) {
41544157
41554158 if ( ! vnode . data . show ) {
41564159 // 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 ( ) {
41584162 var parent = el . parentNode ;
4159- var pendingNode = parent . _pending && parent . _pending [ vnode . key ] ;
4163+ var pendingNode = parent && parent . _pending && parent . _pending [ vnode . key ] ;
41604164 if ( pendingNode && pendingNode . tag === vnode . tag && pendingNode . elm . _leaveCb ) {
41614165 pendingNode . elm . _leaveCb ( ) ;
41624166 }
41634167 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+ }
41654175 }
41664176
41674177 // start enter transition
@@ -4450,7 +4460,7 @@ var show = {
44504460 if ( value && transition && transition . appear && ! isIE9 ) {
44514461 enter ( vnode ) ;
44524462 }
4453- var originalDisplay = el . style . display ;
4463+ var originalDisplay = el . style . display === 'none' ? '' : el . style . display ;
44544464 el . style . display = value ? originalDisplay : 'none' ;
44554465 el . __vOriginalDisplay = originalDisplay ;
44564466 } ,
@@ -4594,6 +4604,14 @@ var Transition = {
45944604 var oldRawChild = this . _vnode ;
45954605 var oldChild = getRealChild ( oldRawChild ) ;
45964606
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+
45974615 if ( oldChild && oldChild . data && oldChild . key !== child . key ) {
45984616 // replace old child transition data with fresh one
45994617 // important for dynamic transitions!
@@ -4609,17 +4627,15 @@ var Transition = {
46094627 } ) ;
46104628 return placeholder ( h , rawChild ) ;
46114629 } 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+ } ) ;
46234639 }
46244640 }
46254641
@@ -4718,20 +4734,18 @@ var TransitionGroup = {
47184734
47194735 children . forEach ( function ( c ) {
47204736 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+ } ) ;
47354749 }
47364750 } ) ;
47374751 } ,
0 commit comments