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
*/
@@ -405,6 +405,7 @@ var UA = inBrowser && window.navigator.userAgent.toLowerCase();
405
405
var isIE = UA && UA . indexOf ( 'trident' ) > 0 ;
406
406
var isIE9 = UA && UA . indexOf ( 'msie 9.0' ) > 0 ;
407
407
var isAndroid = UA && UA . indexOf ( 'android' ) > 0 ;
408
+ var isIOS = UA && / i p h o n e | i p a d | i p o d | i o s / . test ( UA ) ;
408
409
409
410
var transitionProp = undefined ;
410
411
var transitionEndEvent = undefined ;
@@ -421,6 +422,12 @@ if (inBrowser && !isIE9) {
421
422
animationEndEvent = isWebkitAnim ? 'webkitAnimationEnd' : 'animationend' ;
422
423
}
423
424
425
+ /* istanbul ignore next */
426
+ function isNative ( Ctor ) {
427
+ return ( / n a t i v e c o d e / . test ( Ctor . toString ( ) )
428
+ ) ;
429
+ }
430
+
424
431
/**
425
432
* Defer a task to execute it asynchronously. Ideally this
426
433
* should be executed as a microtask, so we leverage
@@ -434,33 +441,53 @@ if (inBrowser && !isIE9) {
434
441
var nextTick = ( function ( ) {
435
442
var callbacks = [ ] ;
436
443
var pending = false ;
437
- var timerFunc ;
444
+ var timerFunc = undefined ;
445
+
438
446
function nextTickHandler ( ) {
439
447
pending = false ;
440
448
var copies = callbacks . slice ( 0 ) ;
441
- callbacks = [ ] ;
449
+ callbacks . length = 0 ;
442
450
for ( var i = 0 ; i < copies . length ; i ++ ) {
443
451
copies [ i ] ( ) ;
444
452
}
445
453
}
446
454
447
- /* istanbul ignore else */
448
- if ( inBrowser && window . postMessage && ! window . importScripts && // not in WebWorker
449
- ! ( isAndroid && ! window . requestAnimationFrame ) // not in Android <= 4.3
450
- ) {
451
- ( function ( ) {
452
- var NEXT_TICK_TOKEN = '__vue__nextTick__' ;
453
- window . addEventListener ( 'message' , function ( e ) {
454
- if ( e . source === window && e . data === NEXT_TICK_TOKEN ) {
455
- nextTickHandler ( ) ;
456
- }
457
- } ) ;
458
- timerFunc = function ( ) {
459
- window . postMessage ( NEXT_TICK_TOKEN , '*' ) ;
460
- } ;
461
- } ) ( ) ;
462
- } else {
463
- timerFunc = typeof global !== 'undefined' && global . setImmediate || setTimeout ;
455
+ // the nextTick behavior leverages the microtask queue, which can be accessed
456
+ // via either native Promise.then or MutationObserver.
457
+ // MutationObserver has wider support, however it is seriously bugged in
458
+ // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
459
+ // completely stops working after triggering a few times... so, if native
460
+ // Promise is available, we will use it:
461
+ /* istanbul ignore if */
462
+ if ( typeof Promise !== 'undefined' && isNative ( Promise ) ) {
463
+ var p = Promise . resolve ( ) ;
464
+ var noop = function noop ( ) { } ;
465
+ timerFunc = function ( ) {
466
+ p . then ( nextTickHandler ) ;
467
+ // in problematic UIWebViews, Promise.then doesn't completely break, but
468
+ // it can get stuck in a weird state where callbacks are pushed into the
469
+ // microtask queue but the queue isn't being flushed, until the browser
470
+ // needs to do some other work, e.g. handle a timer. Therefore we can
471
+ // "force" the microtask queue to be flushed by adding an empty timer.
472
+ if ( isIOS ) setTimeout ( noop ) ;
473
+ } ;
474
+ } else if ( typeof MutationObserver !== 'undefined' ) {
475
+ // use MutationObserver where native Promise is not available,
476
+ // e.g. IE11, iOS7, Android 4.4
477
+ var counter = 1 ;
478
+ var observer = new MutationObserver ( nextTickHandler ) ;
479
+ var textNode = document . createTextNode ( String ( counter ) ) ;
480
+ observer . observe ( textNode , {
481
+ characterData : true
482
+ } ) ;
483
+ timerFunc = function ( ) {
484
+ counter = ( counter + 1 ) % 2 ;
485
+ textNode . data = String ( counter ) ;
486
+ } ;
487
+ } else {
488
+ // fallback to setTimeout
489
+ /* istanbul ignore next */
490
+ timerFunc = setTimeout ;
464
491
}
465
492
466
493
return function ( cb , ctx ) {
@@ -476,7 +503,7 @@ var nextTick = (function () {
476
503
477
504
var _Set = undefined ;
478
505
/* istanbul ignore if */
479
- if ( typeof Set !== 'undefined' && Set . toString ( ) . match ( / n a t i v e c o d e / ) ) {
506
+ if ( typeof Set !== 'undefined' && isNative ( Set ) ) {
480
507
// use native Set when available.
481
508
_Set = Set ;
482
509
} else {
@@ -1638,24 +1665,6 @@ function getOuterHTML(el) {
1638
1665
}
1639
1666
}
1640
1667
1641
- /**
1642
- * Find a vm from a fragment.
1643
- *
1644
- * @param {Fragment } frag
1645
- * @return {Vue|undefined }
1646
- */
1647
-
1648
- function findVmFromFrag ( frag ) {
1649
- var node = frag . node ;
1650
- // handle multi-node frag
1651
- if ( frag . end ) {
1652
- while ( ! node . __vue__ && node !== frag . end && node . nextSibling ) {
1653
- node = node . nextSibling ;
1654
- }
1655
- }
1656
- return node . __vue__ ;
1657
- }
1658
-
1659
1668
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;
1660
1669
var reservedTagRE = / ^ ( s l o t | p a r t i a l | c o m p o n e n t ) $ / i;
1661
1670
@@ -2439,6 +2448,7 @@ var util = Object.freeze({
2439
2448
isIE : isIE ,
2440
2449
isIE9 : isIE9 ,
2441
2450
isAndroid : isAndroid ,
2451
+ isIOS : isIOS ,
2442
2452
get transitionProp ( ) { return transitionProp ; } ,
2443
2453
get transitionEndEvent ( ) { return transitionEndEvent ; } ,
2444
2454
get animationProp ( ) { return animationProp ; } ,
@@ -2469,7 +2479,6 @@ var util = Object.freeze({
2469
2479
removeNodeRange : removeNodeRange ,
2470
2480
isFragment : isFragment ,
2471
2481
getOuterHTML : getOuterHTML ,
2472
- findVmFromFrag : findVmFromFrag ,
2473
2482
mergeOptions : mergeOptions ,
2474
2483
resolveAsset : resolveAsset ,
2475
2484
checkComponentAttr : checkComponentAttr ,
@@ -4105,6 +4114,10 @@ var vFor = {
4105
4114
params : [ 'track-by' , 'stagger' , 'enter-stagger' , 'leave-stagger' ] ,
4106
4115
4107
4116
bind : function bind ( ) {
4117
+ if ( 'development' !== 'production' && this . el . hasAttribute ( 'v-if' ) ) {
4118
+ 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 ) ;
4119
+ }
4120
+
4108
4121
// support "item in/of items" syntax
4109
4122
var inMatch = this . expression . match ( / ( .* ) (?: i n | o f ) ( .* ) / ) ;
4110
4123
if ( inMatch ) {
@@ -4684,6 +4697,24 @@ if ('development' !== 'production') {
4684
4697
} ;
4685
4698
}
4686
4699
4700
+ /**
4701
+ * Find a vm from a fragment.
4702
+ *
4703
+ * @param {Fragment } frag
4704
+ * @return {Vue|undefined }
4705
+ */
4706
+
4707
+ function findVmFromFrag ( frag ) {
4708
+ var node = frag . node ;
4709
+ // handle multi-node frag
4710
+ if ( frag . end ) {
4711
+ while ( ! node . __vue__ && node !== frag . end && node . nextSibling ) {
4712
+ node = node . nextSibling ;
4713
+ }
4714
+ }
4715
+ return node . __vue__ ;
4716
+ }
4717
+
4687
4718
var vIf = {
4688
4719
4689
4720
priority : IF ,
@@ -4712,10 +4743,8 @@ var vIf = {
4712
4743
if ( value ) {
4713
4744
if ( ! this . frag ) {
4714
4745
this . insert ( ) ;
4715
- this . updateRef ( value ) ;
4716
4746
}
4717
4747
} else {
4718
- this . updateRef ( value ) ;
4719
4748
this . remove ( ) ;
4720
4749
}
4721
4750
} ,
@@ -4747,29 +4776,6 @@ var vIf = {
4747
4776
}
4748
4777
} ,
4749
4778
4750
- updateRef : function updateRef ( value ) {
4751
- var ref = this . descriptor . ref ;
4752
- if ( ! ref ) return ;
4753
- var hash = ( this . vm || this . _scope ) . $refs ;
4754
- var refs = hash [ ref ] ;
4755
- var key = this . _frag . scope . $key ;
4756
- if ( ! refs ) return ;
4757
- if ( value ) {
4758
- if ( Array . isArray ( refs ) ) {
4759
- refs . push ( findVmFromFrag ( this . _frag ) ) ;
4760
- } else {
4761
- refs [ key ] = findVmFromFrag ( this . _frag ) ;
4762
- }
4763
- } else {
4764
- if ( Array . isArray ( refs ) ) {
4765
- refs . $remove ( findVmFromFrag ( this . _frag ) ) ;
4766
- } else {
4767
- refs [ key ] = null ;
4768
- delete refs [ key ] ;
4769
- }
4770
- }
4771
- } ,
4772
-
4773
4779
unbind : function unbind ( ) {
4774
4780
if ( this . frag ) {
4775
4781
this . frag . destroy ( ) ;
@@ -7061,18 +7067,20 @@ function sortDirectives(dirs) {
7061
7067
7062
7068
var groupedMap = { } ;
7063
7069
var i , j , k , l ;
7070
+ var index = 0 ;
7071
+ var priorities = [ ] ;
7064
7072
for ( i = 0 , j = dirs . length ; i < j ; i ++ ) {
7065
7073
var dir = dirs [ i ] ;
7066
7074
var priority = dir . descriptor . def . priority || DEFAULT_PRIORITY ;
7067
7075
var array = groupedMap [ priority ] ;
7068
7076
if ( ! array ) {
7069
7077
array = groupedMap [ priority ] = [ ] ;
7078
+ priorities . push ( priority ) ;
7070
7079
}
7071
7080
array . push ( dir ) ;
7072
7081
}
7073
7082
7074
- var index = 0 ;
7075
- var priorities = Object . keys ( groupedMap ) . sort ( function ( a , b ) {
7083
+ priorities . sort ( function ( a , b ) {
7076
7084
return a > b ? - 1 : a === b ? 0 : 1 ;
7077
7085
} ) ;
7078
7086
for ( i = 0 , j = priorities . length ; i < j ; i ++ ) {
@@ -7594,7 +7602,7 @@ function makeTerminalNodeLinkFn(el, dirName, value, options, def, rawName, arg,
7594
7602
def : def
7595
7603
} ;
7596
7604
// check ref for v-for, v-if and router-view
7597
- if ( dirName === 'for' || dirName === 'if' || dirName === ' router-view') {
7605
+ if ( dirName === 'for' || dirName === 'router-view' ) {
7598
7606
descriptor . ref = findRef ( el ) ;
7599
7607
}
7600
7608
var fn = function terminalNodeLinkFn ( vm , el , host , scope , frag ) {
@@ -10210,7 +10218,7 @@ function installGlobalAPI (Vue) {
10210
10218
10211
10219
installGlobalAPI ( Vue ) ;
10212
10220
10213
- Vue . version = '1.0.27 ' ;
10221
+ Vue . version = '1.0.28 ' ;
10214
10222
10215
10223
// devtools global hook
10216
10224
/* istanbul ignore next */
0 commit comments