6
6
7
7
/* */
8
8
9
+ var emptyObject = Object . freeze ( { } ) ;
10
+
9
11
// these helpers produces better vm code in JS engines due to their
10
12
// explicitness and function inlining
11
13
function isUndef ( v ) {
@@ -568,8 +570,6 @@ function setText (node, text, raw) {
568
570
569
571
/* */
570
572
571
- var emptyObject = Object . freeze ( { } ) ;
572
-
573
573
/**
574
574
* Check if a string starts with $ or _
575
575
*/
@@ -607,17 +607,20 @@ function parsePath (path) {
607
607
608
608
/* */
609
609
610
+
610
611
// can we use __proto__?
611
612
var hasProto = '__proto__' in { } ;
612
613
613
614
// Browser environment sniffing
614
615
var inBrowser = typeof window !== 'undefined' ;
616
+ var inWeex = typeof WXEnvironment !== 'undefined' && ! ! WXEnvironment . platform ;
617
+ var weexPlatform = inWeex && WXEnvironment . platform . toLowerCase ( ) ;
615
618
var UA = inBrowser && window . navigator . userAgent . toLowerCase ( ) ;
616
619
var isIE = UA && / m s i e | t r i d e n t / . test ( UA ) ;
617
620
var isIE9 = UA && UA . indexOf ( 'msie 9.0' ) > 0 ;
618
621
var isEdge = UA && UA . indexOf ( 'edge/' ) > 0 ;
619
- var isAndroid = UA && UA . indexOf ( 'android' ) > 0 ;
620
- var isIOS = UA && / i p h o n e | i p a d | i p o d | i o s / . test ( UA ) ;
622
+ var isAndroid = ( UA && UA . indexOf ( 'android' ) > 0 ) || ( weexPlatform === 'android' ) ;
623
+ var isIOS = ( UA && / i p h o n e | i p a d | i p o d | i o s / . test ( UA ) ) || ( weexPlatform === 'ios' ) ;
621
624
var isChrome = UA && / c h r o m e \/ \d + / . test ( UA ) && ! isEdge ;
622
625
623
626
// Firefox has a "watch" function on Object.prototype...
@@ -1820,7 +1823,7 @@ function logError (err, vm, info) {
1820
1823
warn ( ( "Error in " + info + ": \"" + ( err . toString ( ) ) + "\"" ) , vm ) ;
1821
1824
}
1822
1825
/* istanbul ignore else */
1823
- if ( inBrowser && typeof console !== 'undefined' ) {
1826
+ if ( ( inBrowser || inWeex ) && typeof console !== 'undefined' ) {
1824
1827
console . error ( err ) ;
1825
1828
} else {
1826
1829
throw err
@@ -2577,39 +2580,59 @@ function addHandler (
2577
2580
important ,
2578
2581
warn
2579
2582
) {
2583
+ modifiers = modifiers || emptyObject ;
2580
2584
// warn prevent and passive modifier
2581
2585
/* istanbul ignore if */
2582
2586
if (
2583
2587
"development" !== 'production' && warn &&
2584
- modifiers && modifiers . prevent && modifiers . passive
2588
+ modifiers . prevent && modifiers . passive
2585
2589
) {
2586
2590
warn (
2587
2591
'passive and prevent can\'t be used together. ' +
2588
2592
'Passive handler can\'t prevent default event.'
2589
2593
) ;
2590
2594
}
2595
+
2591
2596
// check capture modifier
2592
- if ( modifiers && modifiers . capture ) {
2597
+ if ( modifiers . capture ) {
2593
2598
delete modifiers . capture ;
2594
2599
name = '!' + name ; // mark the event as captured
2595
2600
}
2596
- if ( modifiers && modifiers . once ) {
2601
+ if ( modifiers . once ) {
2597
2602
delete modifiers . once ;
2598
2603
name = '~' + name ; // mark the event as once
2599
2604
}
2600
2605
/* istanbul ignore if */
2601
- if ( modifiers && modifiers . passive ) {
2606
+ if ( modifiers . passive ) {
2602
2607
delete modifiers . passive ;
2603
2608
name = '&' + name ; // mark the event as passive
2604
2609
}
2610
+
2611
+ // normalize click.right and click.middle since they don't actually fire
2612
+ // this is technically browser-specific, but at least for now browsers are
2613
+ // the only target envs that have right/middle clicks.
2614
+ if ( name === 'click' ) {
2615
+ if ( modifiers . right ) {
2616
+ name = 'contextmenu' ;
2617
+ delete modifiers . right ;
2618
+ } else if ( modifiers . middle ) {
2619
+ name = 'mouseup' ;
2620
+ }
2621
+ }
2622
+
2605
2623
var events ;
2606
- if ( modifiers && modifiers . native ) {
2624
+ if ( modifiers . native ) {
2607
2625
delete modifiers . native ;
2608
2626
events = el . nativeEvents || ( el . nativeEvents = { } ) ;
2609
2627
} else {
2610
2628
events = el . events || ( el . events = { } ) ;
2611
2629
}
2612
- var newHandler = { value : value , modifiers : modifiers } ;
2630
+
2631
+ var newHandler = { value : value } ;
2632
+ if ( modifiers !== emptyObject ) {
2633
+ newHandler . modifiers = modifiers ;
2634
+ }
2635
+
2613
2636
var handlers = events [ name ] ;
2614
2637
/* istanbul ignore if */
2615
2638
if ( Array . isArray ( handlers ) ) {
@@ -4511,18 +4534,7 @@ function genHandlers (
4511
4534
) {
4512
4535
var res = isNative ? 'nativeOn:{' : 'on:{' ;
4513
4536
for ( var name in events ) {
4514
- var handler = events [ name ] ;
4515
- // #5330: warn click.right, since right clicks do not actually fire click events.
4516
- if ( "development" !== 'production' &&
4517
- name === 'click' &&
4518
- handler && handler . modifiers && handler . modifiers . right
4519
- ) {
4520
- warn (
4521
- "Use \"contextmenu\" instead of \"click.right\" since right clicks " +
4522
- "do not actually fire \"click\" events."
4523
- ) ;
4524
- }
4525
- res += "\"" + name + "\":" + ( genHandler ( name , handler ) ) + "," ;
4537
+ res += "\"" + name + "\":" + ( genHandler ( name , events [ name ] ) ) + "," ;
4526
4538
}
4527
4539
return res . slice ( 0 , - 1 ) + '}'
4528
4540
}
@@ -4689,10 +4701,10 @@ function genElement (el, state) {
4689
4701
}
4690
4702
4691
4703
// hoist static sub-trees out
4692
- function genStatic ( el , state ) {
4704
+ function genStatic ( el , state , once$$1 ) {
4693
4705
el . staticProcessed = true ;
4694
4706
state . staticRenderFns . push ( ( "with(this){return " + ( genElement ( el , state ) ) + "}" ) ) ;
4695
- return ( "_m(" + ( state . staticRenderFns . length - 1 ) + ( el . staticInFor ? ', true' : '' ) + ")" )
4707
+ return ( "_m(" + ( state . staticRenderFns . length - 1 ) + "," + ( el . staticInFor ? 'true' : 'false' ) + "," + ( once$$1 ? ' true' : 'false ' ) + ")" )
4696
4708
}
4697
4709
4698
4710
// v-once
@@ -4718,7 +4730,7 @@ function genOnce (el, state) {
4718
4730
}
4719
4731
return ( "_o(" + ( genElement ( el , state ) ) + "," + ( state . onceId ++ ) + "," + key + ")" )
4720
4732
} else {
4721
- return genStatic ( el , state )
4733
+ return genStatic ( el , state , true )
4722
4734
}
4723
4735
}
4724
4736
@@ -6047,6 +6059,43 @@ function renderSSRStyle (
6047
6059
6048
6060
}
6049
6061
6062
+ /* */
6063
+
6064
+ var seenObjects = new _Set ( ) ;
6065
+
6066
+ /**
6067
+ * Recursively traverse an object to evoke all converted
6068
+ * getters, so that every nested property inside the object
6069
+ * is collected as a "deep" dependency.
6070
+ */
6071
+ function traverse ( val ) {
6072
+ _traverse ( val , seenObjects ) ;
6073
+ seenObjects . clear ( ) ;
6074
+ }
6075
+
6076
+ function _traverse ( val , seen ) {
6077
+ var i , keys ;
6078
+ var isA = Array . isArray ( val ) ;
6079
+ if ( ( ! isA && ! isObject ( val ) ) || ! Object . isExtensible ( val ) ) {
6080
+ return
6081
+ }
6082
+ if ( val . __ob__ ) {
6083
+ var depId = val . __ob__ . dep . id ;
6084
+ if ( seen . has ( depId ) ) {
6085
+ return
6086
+ }
6087
+ seen . add ( depId ) ;
6088
+ }
6089
+ if ( isA ) {
6090
+ i = val . length ;
6091
+ while ( i -- ) { _traverse ( val [ i ] , seen ) ; }
6092
+ } else {
6093
+ keys = Object . keys ( val ) ;
6094
+ i = keys . length ;
6095
+ while ( i -- ) { _traverse ( val [ keys [ i ] ] , seen ) ; }
6096
+ }
6097
+ }
6098
+
6050
6099
{
6051
6100
6052
6101
}
@@ -6399,7 +6448,7 @@ function resolveSlots (
6399
6448
}
6400
6449
6401
6450
function isWhitespace ( node ) {
6402
- return node . isComment || node . text === ' '
6451
+ return ( node . isComment && ! node . asyncFactory ) || node . text === ' '
6403
6452
}
6404
6453
6405
6454
function resolveScopedSlots (
@@ -6897,40 +6946,6 @@ Watcher.prototype.teardown = function teardown () {
6897
6946
}
6898
6947
} ;
6899
6948
6900
- /**
6901
- * Recursively traverse an object to evoke all converted
6902
- * getters, so that every nested property inside the object
6903
- * is collected as a "deep" dependency.
6904
- */
6905
- var seenObjects = new _Set ( ) ;
6906
- function traverse ( val ) {
6907
- seenObjects . clear ( ) ;
6908
- _traverse ( val , seenObjects ) ;
6909
- }
6910
-
6911
- function _traverse ( val , seen ) {
6912
- var i , keys ;
6913
- var isA = Array . isArray ( val ) ;
6914
- if ( ( ! isA && ! isObject ( val ) ) || ! Object . isExtensible ( val ) ) {
6915
- return
6916
- }
6917
- if ( val . __ob__ ) {
6918
- var depId = val . __ob__ . dep . id ;
6919
- if ( seen . has ( depId ) ) {
6920
- return
6921
- }
6922
- seen . add ( depId ) ;
6923
- }
6924
- if ( isA ) {
6925
- i = val . length ;
6926
- while ( i -- ) { _traverse ( val [ i ] , seen ) ; }
6927
- } else {
6928
- keys = Object . keys ( val ) ;
6929
- i = keys . length ;
6930
- while ( i -- ) { _traverse ( val [ keys [ i ] ] , seen ) ; }
6931
- }
6932
- }
6933
-
6934
6949
/* */
6935
6950
6936
6951
/* */
@@ -7234,12 +7249,19 @@ function bindObjectProps (
7234
7249
*/
7235
7250
function renderStatic (
7236
7251
index ,
7237
- isInFor
7252
+ isInFor ,
7253
+ isOnce
7238
7254
) {
7239
- // static trees can be rendered once and cached on the contructor options
7240
- // so every instance shares the same cached trees
7241
- var options = this . $options ;
7242
- var cached = options . cached || ( options . cached = [ ] ) ;
7255
+ // render fns generated by compiler < 2.5.4 does not provide v-once
7256
+ // information to runtime so be conservative
7257
+ var isOldVersion = arguments . length < 3 ;
7258
+ // if a static tree is generated by v-once, it is cached on the instance;
7259
+ // otherwise it is purely static and can be cached on the shared options
7260
+ // across all instances.
7261
+ var renderFns = this . $options . staticRenderFns ;
7262
+ var cached = isOldVersion || isOnce
7263
+ ? ( this . _staticTrees || ( this . _staticTrees = [ ] ) )
7264
+ : ( renderFns . cached || ( renderFns . cached = [ ] ) ) ;
7243
7265
var tree = cached [ index ] ;
7244
7266
// if has already-rendered static tree and not inside v-for,
7245
7267
// we can reuse the same tree by doing a shallow clone.
@@ -7249,7 +7271,7 @@ function renderStatic (
7249
7271
: cloneVNode ( tree )
7250
7272
}
7251
7273
// otherwise, render a fresh tree.
7252
- tree = cached [ index ] = options . staticRenderFns [ index ] . call ( this . _renderProxy , null , this ) ;
7274
+ tree = cached [ index ] = renderFns [ index ] . call ( this . _renderProxy , null , this ) ;
7253
7275
markStatic ( tree , ( "__static__" + index ) , false ) ;
7254
7276
return tree
7255
7277
}
0 commit comments