@@ -537,6 +537,7 @@ function parseHTML (html, options) {
537537 var stack = [ ] ;
538538 var expectHTML = options . expectHTML ;
539539 var isUnaryTag$$1 = options . isUnaryTag || no ;
540+ var canBeLeftOpenTag$$1 = options . canBeLeftOpenTag || no ;
540541 var index = 0 ;
541542 var last , lastTag ;
542543 while ( html ) {
@@ -685,7 +686,7 @@ function parseHTML (html, options) {
685686 if ( lastTag === 'p' && isNonPhrasingTag ( tagName ) ) {
686687 parseEndTag ( lastTag ) ;
687688 }
688- if ( canBeLeftOpenTag ( tagName ) && lastTag === tagName ) {
689+ if ( canBeLeftOpenTag$$1 ( tagName ) && lastTag === tagName ) {
689690 parseEndTag ( tagName ) ;
690691 }
691692 }
@@ -1231,6 +1232,7 @@ function parse (
12311232 warn : warn ,
12321233 expectHTML : options . expectHTML ,
12331234 isUnaryTag : options . isUnaryTag ,
1235+ canBeLeftOpenTag : options . canBeLeftOpenTag ,
12341236 shouldDecodeNewlines : options . shouldDecodeNewlines ,
12351237 start : function start ( tag , attrs , unary ) {
12361238 // check namespace.
@@ -2567,11 +2569,13 @@ if (process.env.NODE_ENV !== 'production') {
25672569 if ( vm . $root === vm ) {
25682570 return '<Root>'
25692571 }
2570- var name = typeof vm === 'function' && vm . options
2571- ? vm . options . name
2572- : vm . _isVue
2573- ? vm . $options . name || vm . $options . _componentTag
2574- : vm . name ;
2572+ var name = typeof vm === 'string'
2573+ ? vm
2574+ : typeof vm === 'function' && vm . options
2575+ ? vm . options . name
2576+ : vm . _isVue
2577+ ? vm . $options . name || vm . $options . _componentTag
2578+ : vm . name ;
25752579
25762580 var file = vm . _isVue && vm . $options . __file ;
25772581 if ( ! name && file ) {
@@ -3724,7 +3728,7 @@ function defineReactive$$1 (
37243728 * already exist.
37253729 */
37263730function set ( target , key , val ) {
3727- if ( Array . isArray ( target ) ) {
3731+ if ( Array . isArray ( target ) && typeof key === 'number' ) {
37283732 target . length = Math . max ( target . length , key ) ;
37293733 target . splice ( key , 1 , val ) ;
37303734 return val
@@ -3733,7 +3737,7 @@ function set (target, key, val) {
37333737 target [ key ] = val ;
37343738 return val
37353739 }
3736- var ob = target . __ob__ ;
3740+ var ob = ( target ) . __ob__ ;
37373741 if ( target . _isVue || ( ob && ob . vmCount ) ) {
37383742 process . env . NODE_ENV !== 'production' && warn$2 (
37393743 'Avoid adding reactive properties to a Vue instance or its root $data ' +
@@ -3754,11 +3758,11 @@ function set (target, key, val) {
37543758 * Delete a property and trigger change if necessary.
37553759 */
37563760function del ( target , key ) {
3757- if ( Array . isArray ( target ) ) {
3761+ if ( Array . isArray ( target ) && typeof key === 'number' ) {
37583762 target . splice ( key , 1 ) ;
37593763 return
37603764 }
3761- var ob = target . __ob__ ;
3765+ var ob = ( target ) . __ob__ ;
37623766 if ( target . _isVue || ( ob && ob . vmCount ) ) {
37633767 process . env . NODE_ENV !== 'production' && warn$2 (
37643768 'Avoid deleting properties on a Vue instance or its root $data ' +
@@ -4035,6 +4039,18 @@ function eventsMixin (Vue) {
40354039
40364040 Vue . prototype . $emit = function ( event ) {
40374041 var vm = this ;
4042+ if ( process . env . NODE_ENV !== 'production' ) {
4043+ var lowerCaseEvent = event . toLowerCase ( ) ;
4044+ if ( lowerCaseEvent !== event && vm . _events [ lowerCaseEvent ] ) {
4045+ tip (
4046+ "Event \"" + lowerCaseEvent + "\" is emitted in component " +
4047+ ( formatComponentName ( vm ) ) + " but the handler is registered for \"" + event + "\". " +
4048+ "Note that HTML attributes are case-insensitive and you cannot use " +
4049+ "v-on to listen to camelCase events when using in-DOM templates. " +
4050+ "You should probably use \"" + ( hyphenate ( event ) ) + "\" instead of \"" + event + "\"."
4051+ ) ;
4052+ }
4053+ }
40384054 var cbs = vm . _events [ event ] ;
40394055 if ( cbs ) {
40404056 cbs = cbs . length > 1 ? toArray ( cbs ) : cbs ;
@@ -4392,10 +4408,14 @@ function flushSchedulerQueue () {
43924408 }
43934409 }
43944410
4411+ // reset scheduler before updated hook called
4412+ var oldQueue = queue . slice ( ) ;
4413+ resetSchedulerState ( ) ;
4414+
43954415 // call updated hooks
4396- index$1 = queue . length ;
4416+ index$1 = oldQueue . length ;
43974417 while ( index$1 -- ) {
4398- watcher = queue [ index$1 ] ;
4418+ watcher = oldQueue [ index$1 ] ;
43994419 vm = watcher . vm ;
44004420 if ( vm . _watcher === watcher && vm . _isMounted ) {
44014421 callHook ( vm , 'updated' ) ;
@@ -4407,8 +4427,6 @@ function flushSchedulerQueue () {
44074427 if ( devtools && config . devtools ) {
44084428 devtools . emit ( 'flush' ) ;
44094429 }
4410-
4411- resetSchedulerState ( ) ;
44124430}
44134431
44144432/**
@@ -4765,7 +4783,7 @@ function initProps (vm, propsOptions) {
47654783function initData ( vm ) {
47664784 var data = vm . $options . data ;
47674785 data = vm . _data = typeof data === 'function'
4768- ? data . call ( vm )
4786+ ? getData ( data , vm )
47694787 : data || { } ;
47704788 if ( ! isPlainObject ( data ) ) {
47714789 data = { } ;
@@ -4794,6 +4812,15 @@ function initData (vm) {
47944812 observe ( data , true /* asRootData */ ) ;
47954813}
47964814
4815+ function getData ( data , vm ) {
4816+ try {
4817+ return data . call ( vm )
4818+ } catch ( e ) {
4819+ handleError ( e , vm , "data()" ) ;
4820+ return { }
4821+ }
4822+ }
4823+
47974824var computedWatcherOptions = { lazy : true } ;
47984825
47994826function initComputed ( vm , computed ) {
@@ -5050,7 +5077,7 @@ function createComponent (
50505077 }
50515078
50525079 // extract props
5053- var propsData = extractProps ( data , Ctor ) ;
5080+ var propsData = extractProps ( data , Ctor , tag ) ;
50545081
50555082 // functional component
50565083 if ( Ctor . options . functional ) {
@@ -5191,7 +5218,7 @@ function resolveAsyncComponent (
51915218 }
51925219}
51935220
5194- function extractProps ( data , Ctor ) {
5221+ function extractProps ( data , Ctor , tag ) {
51955222 // we are only extracting raw values here.
51965223 // validation and default values are handled in the child
51975224 // component itself.
@@ -5212,12 +5239,13 @@ function extractProps (data, Ctor) {
52125239 key !== keyInLowerCase &&
52135240 attrs && attrs . hasOwnProperty ( keyInLowerCase )
52145241 ) {
5215- warn$2 (
5216- "Prop \"" + keyInLowerCase + "\" is not declared in component " +
5217- ( formatComponentName ( Ctor ) ) + ". Note that HTML attributes are " +
5218- "case-insensitive and camelCased props need to use their kebab-case " +
5219- "equivalents when using in-DOM templates. You should probably use " +
5220- "\"" + altKey + "\" instead of \"" + key + "\"."
5242+ tip (
5243+ "Prop \"" + keyInLowerCase + "\" is passed to component " +
5244+ ( formatComponentName ( tag || Ctor ) ) + ", but the delared prop name is" +
5245+ " \"" + key + "\". " +
5246+ "Note that HTML attributes are case-insensitive and camelCased " +
5247+ "props need to use their kebab-case equivalents when using in-DOM " +
5248+ "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
52215249 ) ;
52225250 }
52235251 }
@@ -5703,18 +5731,32 @@ function initInjections (vm) {
57035731 ? Reflect . ownKeys ( inject )
57045732 : Object . keys ( inject ) ;
57055733
5706- for ( var i = 0 ; i < keys . length ; i ++ ) {
5734+ var loop = function ( i ) {
57075735 var key = keys [ i ] ;
57085736 var provideKey = isArray ? key : inject [ key ] ;
57095737 var source = vm ;
57105738 while ( source ) {
57115739 if ( source . _provided && provideKey in source . _provided ) {
5712- vm [ key ] = source . _provided [ provideKey ] ;
5740+ /* istanbul ignore else */
5741+ if ( process . env . NODE_ENV !== 'production' ) {
5742+ defineReactive$$1 ( vm , key , source . _provided [ provideKey ] , function ( ) {
5743+ warn$2 (
5744+ "Avoid mutating an injected value directly since the changes will be " +
5745+ "overwritten whenever the provided component re-renders. " +
5746+ "injection being mutated: \"" + key + "\"" ,
5747+ vm
5748+ ) ;
5749+ } ) ;
5750+ } else {
5751+ defineReactive$$1 ( vm , key , source . _provided [ provideKey ] ) ;
5752+ }
57135753 break
57145754 }
57155755 source = source . $parent ;
57165756 }
5717- }
5757+ } ;
5758+
5759+ for ( var i = 0 ; i < keys . length ; i ++ ) loop ( i ) ;
57185760 }
57195761}
57205762
@@ -5724,14 +5766,18 @@ var uid = 0;
57245766
57255767function initMixin ( Vue ) {
57265768 Vue . prototype . _init = function ( options ) {
5769+ var vm = this ;
5770+ // a uid
5771+ vm . _uid = uid ++ ;
5772+
5773+ var startTag , endTag ;
57275774 /* istanbul ignore if */
57285775 if ( process . env . NODE_ENV !== 'production' && config . performance && mark ) {
5729- mark ( 'vue-perf-init' ) ;
5776+ startTag = "vue-perf-init:" + ( vm . _uid ) ;
5777+ endTag = "vue-perf-end:" + ( vm . _uid ) ;
5778+ mark ( startTag ) ;
57305779 }
57315780
5732- var vm = this ;
5733- // a uid
5734- vm . _uid = uid ++ ;
57355781 // a flag to avoid this being observed
57365782 vm . _isVue = true ;
57375783 // merge options
@@ -5767,8 +5813,8 @@ function initMixin (Vue) {
57675813 /* istanbul ignore if */
57685814 if ( process . env . NODE_ENV !== 'production' && config . performance && mark ) {
57695815 vm . _name = formatComponentName ( vm , false ) ;
5770- mark ( 'vue-perf-init-end' ) ;
5771- measure ( ( ( vm . _name ) + " init" ) , 'vue-perf-init' , 'vue-perf-init-end' ) ;
5816+ mark ( endTag ) ;
5817+ measure ( ( ( vm . _name ) + " init" ) , startTag , endTag ) ;
57725818 }
57735819
57745820 if ( vm . $options . el ) {
@@ -6538,6 +6584,7 @@ var baseOptions = {
65386584 isPreTag : isPreTag ,
65396585 isUnaryTag : isUnaryTag ,
65406586 mustUseProp : mustUseProp ,
6587+ canBeLeftOpenTag : canBeLeftOpenTag ,
65416588 isReservedTag : isReservedTag ,
65426589 getTagNamespace : getTagNamespace ,
65436590 staticKeys : genStaticKeys ( modules )
@@ -6688,6 +6735,22 @@ function hasAncestorData (node) {
66886735 return parentNode && ( parentNode . data || hasAncestorData ( parentNode ) )
66896736}
66906737
6738+ function getVShowDirectiveInfo ( node ) {
6739+ var dir ;
6740+ var tmp ;
6741+
6742+ while ( node ) {
6743+ if ( node . data && node . data . directives ) {
6744+ tmp = node . data . directives . find ( function ( dir ) { return dir . name === 'show' ; } ) ;
6745+ if ( tmp ) {
6746+ dir = tmp ;
6747+ }
6748+ }
6749+ node = node . parent ;
6750+ }
6751+ return dir
6752+ }
6753+
66916754function renderStartingTag ( node , context ) {
66926755 var markup = "<" + ( node . tag ) ;
66936756 var directives = context . directives ;
@@ -6703,14 +6766,22 @@ function renderStartingTag (node, context) {
67036766 var dirs = node . data . directives ;
67046767 if ( dirs ) {
67056768 for ( var i = 0 ; i < dirs . length ; i ++ ) {
6706- var dirRenderer = directives [ dirs [ i ] . name ] ;
6707- if ( dirRenderer ) {
6769+ var name = dirs [ i ] . name ;
6770+ var dirRenderer = directives [ name ] ;
6771+ if ( dirRenderer && name !== 'show' ) {
67086772 // directives mutate the node's data
67096773 // which then gets rendered by modules
67106774 dirRenderer ( node , dirs [ i ] ) ;
67116775 }
67126776 }
67136777 }
6778+
6779+ // v-show directive needs to be merged from parent to child
6780+ var vshowDirectiveInfo = getVShowDirectiveInfo ( node ) ;
6781+ if ( vshowDirectiveInfo ) {
6782+ directives . show ( node , vshowDirectiveInfo ) ;
6783+ }
6784+
67146785 // apply other modules
67156786 for ( var i$1 = 0 ; i$1 < modules . length ; i$1 ++ ) {
67166787 var res = modules [ i$1 ] ( node ) ;
@@ -7242,6 +7313,7 @@ function createRenderer$$1 (options) {
72427313
72437314 return createRenderer$1 ( {
72447315 isUnaryTag : isUnaryTag ,
7316+ canBeLeftOpenTag : canBeLeftOpenTag ,
72457317 modules : modules$1 ,
72467318 // user can provide server-side implementations for custom directives
72477319 // when creating the renderer.
0 commit comments