1
1
/*!
2
- * Vue.js v1.0.27
2
+ * Vue.js v1.0.28
3
3
* (c) 2016 Evan You
4
4
* Released under the MIT License.
5
5
*/
@@ -401,6 +401,7 @@ var UA = inBrowser && window.navigator.userAgent.toLowerCase();
401
401
var isIE = UA && UA . indexOf ( 'trident' ) > 0 ;
402
402
var isIE9 = UA && UA . indexOf ( 'msie 9.0' ) > 0 ;
403
403
var isAndroid = UA && UA . indexOf ( 'android' ) > 0 ;
404
+ var isIOS = UA && / i p h o n e | i p a d | i p o d | i o s / . test ( UA ) ;
404
405
405
406
var transitionProp = undefined ;
406
407
var transitionEndEvent = undefined ;
@@ -417,6 +418,12 @@ if (inBrowser && !isIE9) {
417
418
animationEndEvent = isWebkitAnim ? 'webkitAnimationEnd' : 'animationend' ;
418
419
}
419
420
421
+ /* istanbul ignore next */
422
+ function isNative ( Ctor ) {
423
+ return ( / n a t i v e c o d e / . test ( Ctor . toString ( ) )
424
+ ) ;
425
+ }
426
+
420
427
/**
421
428
* Defer a task to execute it asynchronously. Ideally this
422
429
* should be executed as a microtask, so we leverage
@@ -430,33 +437,53 @@ if (inBrowser && !isIE9) {
430
437
var nextTick = ( function ( ) {
431
438
var callbacks = [ ] ;
432
439
var pending = false ;
433
- var timerFunc ;
440
+ var timerFunc = undefined ;
441
+
434
442
function nextTickHandler ( ) {
435
443
pending = false ;
436
444
var copies = callbacks . slice ( 0 ) ;
437
- callbacks = [ ] ;
445
+ callbacks . length = 0 ;
438
446
for ( var i = 0 ; i < copies . length ; i ++ ) {
439
447
copies [ i ] ( ) ;
440
448
}
441
449
}
442
450
443
- /* istanbul ignore else */
444
- if ( inBrowser && window . postMessage && ! window . importScripts && // not in WebWorker
445
- ! ( isAndroid && ! window . requestAnimationFrame ) // not in Android <= 4.3
446
- ) {
447
- ( function ( ) {
448
- var NEXT_TICK_TOKEN = '__vue__nextTick__' ;
449
- window . addEventListener ( 'message' , function ( e ) {
450
- if ( e . source === window && e . data === NEXT_TICK_TOKEN ) {
451
- nextTickHandler ( ) ;
452
- }
453
- } ) ;
454
- timerFunc = function ( ) {
455
- window . postMessage ( NEXT_TICK_TOKEN , '*' ) ;
456
- } ;
457
- } ) ( ) ;
458
- } else {
459
- timerFunc = typeof global !== 'undefined' && global . setImmediate || setTimeout ;
451
+ // the nextTick behavior leverages the microtask queue, which can be accessed
452
+ // via either native Promise.then or MutationObserver.
453
+ // MutationObserver has wider support, however it is seriously bugged in
454
+ // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
455
+ // completely stops working after triggering a few times... so, if native
456
+ // Promise is available, we will use it:
457
+ /* istanbul ignore if */
458
+ if ( typeof Promise !== 'undefined' && isNative ( Promise ) ) {
459
+ var p = Promise . resolve ( ) ;
460
+ var noop = function noop ( ) { } ;
461
+ timerFunc = function ( ) {
462
+ p . then ( nextTickHandler ) ;
463
+ // in problematic UIWebViews, Promise.then doesn't completely break, but
464
+ // it can get stuck in a weird state where callbacks are pushed into the
465
+ // microtask queue but the queue isn't being flushed, until the browser
466
+ // needs to do some other work, e.g. handle a timer. Therefore we can
467
+ // "force" the microtask queue to be flushed by adding an empty timer.
468
+ if ( isIOS ) setTimeout ( noop ) ;
469
+ } ;
470
+ } else if ( typeof MutationObserver !== 'undefined' ) {
471
+ // use MutationObserver where native Promise is not available,
472
+ // e.g. IE11, iOS7, Android 4.4
473
+ var counter = 1 ;
474
+ var observer = new MutationObserver ( nextTickHandler ) ;
475
+ var textNode = document . createTextNode ( String ( counter ) ) ;
476
+ observer . observe ( textNode , {
477
+ characterData : true
478
+ } ) ;
479
+ timerFunc = function ( ) {
480
+ counter = ( counter + 1 ) % 2 ;
481
+ textNode . data = String ( counter ) ;
482
+ } ;
483
+ } else {
484
+ // fallback to setTimeout
485
+ /* istanbul ignore next */
486
+ timerFunc = setTimeout ;
460
487
}
461
488
462
489
return function ( cb , ctx ) {
@@ -472,7 +499,7 @@ var nextTick = (function () {
472
499
473
500
var _Set = undefined ;
474
501
/* istanbul ignore if */
475
- if ( typeof Set !== 'undefined' && Set . toString ( ) . match ( / n a t i v e c o d e / ) ) {
502
+ if ( typeof Set !== 'undefined' && isNative ( Set ) ) {
476
503
// use native Set when available.
477
504
_Set = Set ;
478
505
} else {
@@ -1634,24 +1661,6 @@ function getOuterHTML(el) {
1634
1661
}
1635
1662
}
1636
1663
1637
- /**
1638
- * Find a vm from a fragment.
1639
- *
1640
- * @param {Fragment } frag
1641
- * @return {Vue|undefined }
1642
- */
1643
-
1644
- function findVmFromFrag ( frag ) {
1645
- var node = frag . node ;
1646
- // handle multi-node frag
1647
- if ( frag . end ) {
1648
- while ( ! node . __vue__ && node !== frag . end && node . nextSibling ) {
1649
- node = node . nextSibling ;
1650
- }
1651
- }
1652
- return node . __vue__ ;
1653
- }
1654
-
1655
1664
var commonTagRE = / ^ ( d i v | p | s p a n | i m g | a | b | i | b r | u l | o l | l i | h 1 | h 2 | h 3 | h 4 | h 5 | h 6 | c o d e | p r e | t a b l e | t h | t d | t r | f o r m | l a b e l | i n p u t | s e l e c t | o p t i o n | n a v | a r t i c l e | s e c t i o n | h e a d e r | f o o t e r ) $ / i;
1656
1665
var reservedTagRE = / ^ ( s l o t | p a r t i a l | c o m p o n e n t ) $ / i;
1657
1666
@@ -2435,6 +2444,7 @@ var util = Object.freeze({
2435
2444
isIE : isIE ,
2436
2445
isIE9 : isIE9 ,
2437
2446
isAndroid : isAndroid ,
2447
+ isIOS : isIOS ,
2438
2448
get transitionProp ( ) { return transitionProp ; } ,
2439
2449
get transitionEndEvent ( ) { return transitionEndEvent ; } ,
2440
2450
get animationProp ( ) { return animationProp ; } ,
@@ -2465,7 +2475,6 @@ var util = Object.freeze({
2465
2475
removeNodeRange : removeNodeRange ,
2466
2476
isFragment : isFragment ,
2467
2477
getOuterHTML : getOuterHTML ,
2468
- findVmFromFrag : findVmFromFrag ,
2469
2478
mergeOptions : mergeOptions ,
2470
2479
resolveAsset : resolveAsset ,
2471
2480
checkComponentAttr : checkComponentAttr ,
@@ -4101,6 +4110,10 @@ var vFor = {
4101
4110
params : [ 'track-by' , 'stagger' , 'enter-stagger' , 'leave-stagger' ] ,
4102
4111
4103
4112
bind : function bind ( ) {
4113
+ if ( process . env . NODE_ENV !== 'production' && this . el . hasAttribute ( 'v-if' ) ) {
4114
+ warn ( '<' + this . el . tagName . toLowerCase ( ) + ' v-for="' + this . expression + '" v-if="' + this . el . getAttribute ( 'v-if' ) + '">: ' + 'Using v-if and v-for on the same element is not recommended - ' + 'consider filtering the source Array instead.' , this . vm ) ;
4115
+ }
4116
+
4104
4117
// support "item in/of items" syntax
4105
4118
var inMatch = this . expression . match ( / ( .* ) (?: i n | o f ) ( .* ) / ) ;
4106
4119
if ( inMatch ) {
@@ -4680,6 +4693,24 @@ if (process.env.NODE_ENV !== 'production') {
4680
4693
} ;
4681
4694
}
4682
4695
4696
+ /**
4697
+ * Find a vm from a fragment.
4698
+ *
4699
+ * @param {Fragment } frag
4700
+ * @return {Vue|undefined }
4701
+ */
4702
+
4703
+ function findVmFromFrag ( frag ) {
4704
+ var node = frag . node ;
4705
+ // handle multi-node frag
4706
+ if ( frag . end ) {
4707
+ while ( ! node . __vue__ && node !== frag . end && node . nextSibling ) {
4708
+ node = node . nextSibling ;
4709
+ }
4710
+ }
4711
+ return node . __vue__ ;
4712
+ }
4713
+
4683
4714
var vIf = {
4684
4715
4685
4716
priority : IF ,
@@ -4708,10 +4739,8 @@ var vIf = {
4708
4739
if ( value ) {
4709
4740
if ( ! this . frag ) {
4710
4741
this . insert ( ) ;
4711
- this . updateRef ( value ) ;
4712
4742
}
4713
4743
} else {
4714
- this . updateRef ( value ) ;
4715
4744
this . remove ( ) ;
4716
4745
}
4717
4746
} ,
@@ -4743,29 +4772,6 @@ var vIf = {
4743
4772
}
4744
4773
} ,
4745
4774
4746
- updateRef : function updateRef ( value ) {
4747
- var ref = this . descriptor . ref ;
4748
- if ( ! ref ) return ;
4749
- var hash = ( this . vm || this . _scope ) . $refs ;
4750
- var refs = hash [ ref ] ;
4751
- var key = this . _frag . scope . $key ;
4752
- if ( ! refs ) return ;
4753
- if ( value ) {
4754
- if ( Array . isArray ( refs ) ) {
4755
- refs . push ( findVmFromFrag ( this . _frag ) ) ;
4756
- } else {
4757
- refs [ key ] = findVmFromFrag ( this . _frag ) ;
4758
- }
4759
- } else {
4760
- if ( Array . isArray ( refs ) ) {
4761
- refs . $remove ( findVmFromFrag ( this . _frag ) ) ;
4762
- } else {
4763
- refs [ key ] = null ;
4764
- delete refs [ key ] ;
4765
- }
4766
- }
4767
- } ,
4768
-
4769
4775
unbind : function unbind ( ) {
4770
4776
if ( this . frag ) {
4771
4777
this . frag . destroy ( ) ;
@@ -7064,18 +7070,20 @@ function sortDirectives(dirs) {
7064
7070
7065
7071
var groupedMap = { } ;
7066
7072
var i , j , k , l ;
7073
+ var index = 0 ;
7074
+ var priorities = [ ] ;
7067
7075
for ( i = 0 , j = dirs . length ; i < j ; i ++ ) {
7068
7076
var dir = dirs [ i ] ;
7069
7077
var priority = dir . descriptor . def . priority || DEFAULT_PRIORITY ;
7070
7078
var array = groupedMap [ priority ] ;
7071
7079
if ( ! array ) {
7072
7080
array = groupedMap [ priority ] = [ ] ;
7081
+ priorities . push ( priority ) ;
7073
7082
}
7074
7083
array . push ( dir ) ;
7075
7084
}
7076
7085
7077
- var index = 0 ;
7078
- var priorities = Object . keys ( groupedMap ) . sort ( function ( a , b ) {
7086
+ priorities . sort ( function ( a , b ) {
7079
7087
return a > b ? - 1 : a === b ? 0 : 1 ;
7080
7088
} ) ;
7081
7089
for ( i = 0 , j = priorities . length ; i < j ; i ++ ) {
@@ -7597,7 +7605,7 @@ function makeTerminalNodeLinkFn(el, dirName, value, options, def, rawName, arg,
7597
7605
def : def
7598
7606
} ;
7599
7607
// check ref for v-for, v-if and router-view
7600
- if ( dirName === 'for' || dirName === 'if' || dirName === ' router-view') {
7608
+ if ( dirName === 'for' || dirName === 'router-view' ) {
7601
7609
descriptor . ref = findRef ( el ) ;
7602
7610
}
7603
7611
var fn = function terminalNodeLinkFn ( vm , el , host , scope , frag ) {
@@ -10213,7 +10221,7 @@ function installGlobalAPI (Vue) {
10213
10221
10214
10222
installGlobalAPI ( Vue ) ;
10215
10223
10216
- Vue . version = '1.0.27 ' ;
10224
+ Vue . version = '1.0.28 ' ;
10217
10225
10218
10226
// devtools global hook
10219
10227
/* istanbul ignore next */
0 commit comments