66
77/* */
88
9+ var emptyObject = Object . freeze ( { } ) ;
10+
911// these helpers produces better vm code in JS engines due to their
1012// explicitness and function inlining
1113function isUndef ( v ) {
@@ -568,8 +570,6 @@ function setText (node, text, raw) {
568570
569571/* */
570572
571- var emptyObject = Object . freeze ( { } ) ;
572-
573573/**
574574 * Check if a string starts with $ or _
575575 */
@@ -607,17 +607,20 @@ function parsePath (path) {
607607
608608/* */
609609
610+
610611// can we use __proto__?
611612var hasProto = '__proto__' in { } ;
612613
613614// Browser environment sniffing
614615var inBrowser = typeof window !== 'undefined' ;
616+ var inWeex = typeof WXEnvironment !== 'undefined' && ! ! WXEnvironment . platform ;
617+ var weexPlatform = inWeex && WXEnvironment . platform . toLowerCase ( ) ;
615618var UA = inBrowser && window . navigator . userAgent . toLowerCase ( ) ;
616619var isIE = UA && / m s i e | t r i d e n t / . test ( UA ) ;
617620var isIE9 = UA && UA . indexOf ( 'msie 9.0' ) > 0 ;
618621var 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' ) ;
621624var isChrome = UA && / c h r o m e \/ \d + / . test ( UA ) && ! isEdge ;
622625
623626// Firefox has a "watch" function on Object.prototype...
@@ -1820,7 +1823,7 @@ function logError (err, vm, info) {
18201823 warn ( ( "Error in " + info + ": \"" + ( err . toString ( ) ) + "\"" ) , vm ) ;
18211824 }
18221825 /* istanbul ignore else */
1823- if ( inBrowser && typeof console !== 'undefined' ) {
1826+ if ( ( inBrowser || inWeex ) && typeof console !== 'undefined' ) {
18241827 console . error ( err ) ;
18251828 } else {
18261829 throw err
@@ -2577,39 +2580,59 @@ function addHandler (
25772580 important ,
25782581 warn
25792582) {
2583+ modifiers = modifiers || emptyObject ;
25802584 // warn prevent and passive modifier
25812585 /* istanbul ignore if */
25822586 if (
25832587 "development" !== 'production' && warn &&
2584- modifiers && modifiers . prevent && modifiers . passive
2588+ modifiers . prevent && modifiers . passive
25852589 ) {
25862590 warn (
25872591 'passive and prevent can\'t be used together. ' +
25882592 'Passive handler can\'t prevent default event.'
25892593 ) ;
25902594 }
2595+
25912596 // check capture modifier
2592- if ( modifiers && modifiers . capture ) {
2597+ if ( modifiers . capture ) {
25932598 delete modifiers . capture ;
25942599 name = '!' + name ; // mark the event as captured
25952600 }
2596- if ( modifiers && modifiers . once ) {
2601+ if ( modifiers . once ) {
25972602 delete modifiers . once ;
25982603 name = '~' + name ; // mark the event as once
25992604 }
26002605 /* istanbul ignore if */
2601- if ( modifiers && modifiers . passive ) {
2606+ if ( modifiers . passive ) {
26022607 delete modifiers . passive ;
26032608 name = '&' + name ; // mark the event as passive
26042609 }
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+
26052623 var events ;
2606- if ( modifiers && modifiers . native ) {
2624+ if ( modifiers . native ) {
26072625 delete modifiers . native ;
26082626 events = el . nativeEvents || ( el . nativeEvents = { } ) ;
26092627 } else {
26102628 events = el . events || ( el . events = { } ) ;
26112629 }
2612- var newHandler = { value : value , modifiers : modifiers } ;
2630+
2631+ var newHandler = { value : value } ;
2632+ if ( modifiers !== emptyObject ) {
2633+ newHandler . modifiers = modifiers ;
2634+ }
2635+
26132636 var handlers = events [ name ] ;
26142637 /* istanbul ignore if */
26152638 if ( Array . isArray ( handlers ) ) {
@@ -4511,18 +4534,7 @@ function genHandlers (
45114534) {
45124535 var res = isNative ? 'nativeOn:{' : 'on:{' ;
45134536 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 ] ) ) + "," ;
45264538 }
45274539 return res . slice ( 0 , - 1 ) + '}'
45284540}
@@ -4689,10 +4701,10 @@ function genElement (el, state) {
46894701}
46904702
46914703// hoist static sub-trees out
4692- function genStatic ( el , state ) {
4704+ function genStatic ( el , state , once$$1 ) {
46934705 el . staticProcessed = true ;
46944706 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 ' ) + ")" )
46964708}
46974709
46984710// v-once
@@ -4718,7 +4730,7 @@ function genOnce (el, state) {
47184730 }
47194731 return ( "_o(" + ( genElement ( el , state ) ) + "," + ( state . onceId ++ ) + "," + key + ")" )
47204732 } else {
4721- return genStatic ( el , state )
4733+ return genStatic ( el , state , true )
47224734 }
47234735}
47244736
@@ -6047,6 +6059,43 @@ function renderSSRStyle (
60476059
60486060}
60496061
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+
60506099{
60516100
60526101}
@@ -6399,7 +6448,7 @@ function resolveSlots (
63996448}
64006449
64016450function isWhitespace ( node ) {
6402- return node . isComment || node . text === ' '
6451+ return ( node . isComment && ! node . asyncFactory ) || node . text === ' '
64036452}
64046453
64056454function resolveScopedSlots (
@@ -6897,40 +6946,6 @@ Watcher.prototype.teardown = function teardown () {
68976946 }
68986947} ;
68996948
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-
69346949/* */
69356950
69366951/* */
@@ -7234,12 +7249,19 @@ function bindObjectProps (
72347249 */
72357250function renderStatic (
72367251 index ,
7237- isInFor
7252+ isInFor ,
7253+ isOnce
72387254) {
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 = [ ] ) ) ;
72437265 var tree = cached [ index ] ;
72447266 // if has already-rendered static tree and not inside v-for,
72457267 // we can reuse the same tree by doing a shallow clone.
@@ -7249,7 +7271,7 @@ function renderStatic (
72497271 : cloneVNode ( tree )
72507272 }
72517273 // 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 ) ;
72537275 markStatic ( tree , ( "__static__" + index ) , false ) ;
72547276 return tree
72557277}
0 commit comments