@@ -537,6 +537,7 @@ function parseHTML (html, options) {
537
537
var stack = [ ] ;
538
538
var expectHTML = options . expectHTML ;
539
539
var isUnaryTag$$1 = options . isUnaryTag || no ;
540
+ var canBeLeftOpenTag$$1 = options . canBeLeftOpenTag || no ;
540
541
var index = 0 ;
541
542
var last , lastTag ;
542
543
while ( html ) {
@@ -685,7 +686,7 @@ function parseHTML (html, options) {
685
686
if ( lastTag === 'p' && isNonPhrasingTag ( tagName ) ) {
686
687
parseEndTag ( lastTag ) ;
687
688
}
688
- if ( canBeLeftOpenTag ( tagName ) && lastTag === tagName ) {
689
+ if ( canBeLeftOpenTag$$1 ( tagName ) && lastTag === tagName ) {
689
690
parseEndTag ( tagName ) ;
690
691
}
691
692
}
@@ -1231,6 +1232,7 @@ function parse (
1231
1232
warn : warn ,
1232
1233
expectHTML : options . expectHTML ,
1233
1234
isUnaryTag : options . isUnaryTag ,
1235
+ canBeLeftOpenTag : options . canBeLeftOpenTag ,
1234
1236
shouldDecodeNewlines : options . shouldDecodeNewlines ,
1235
1237
start : function start ( tag , attrs , unary ) {
1236
1238
// check namespace.
@@ -2567,11 +2569,13 @@ if (process.env.NODE_ENV !== 'production') {
2567
2569
if ( vm . $root === vm ) {
2568
2570
return '<Root>'
2569
2571
}
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 ;
2575
2579
2576
2580
var file = vm . _isVue && vm . $options . __file ;
2577
2581
if ( ! name && file ) {
@@ -3724,7 +3728,7 @@ function defineReactive$$1 (
3724
3728
* already exist.
3725
3729
*/
3726
3730
function set ( target , key , val ) {
3727
- if ( Array . isArray ( target ) ) {
3731
+ if ( Array . isArray ( target ) && typeof key === 'number' ) {
3728
3732
target . length = Math . max ( target . length , key ) ;
3729
3733
target . splice ( key , 1 , val ) ;
3730
3734
return val
@@ -3733,7 +3737,7 @@ function set (target, key, val) {
3733
3737
target [ key ] = val ;
3734
3738
return val
3735
3739
}
3736
- var ob = target . __ob__ ;
3740
+ var ob = ( target ) . __ob__ ;
3737
3741
if ( target . _isVue || ( ob && ob . vmCount ) ) {
3738
3742
process . env . NODE_ENV !== 'production' && warn$2 (
3739
3743
'Avoid adding reactive properties to a Vue instance or its root $data ' +
@@ -3754,11 +3758,11 @@ function set (target, key, val) {
3754
3758
* Delete a property and trigger change if necessary.
3755
3759
*/
3756
3760
function del ( target , key ) {
3757
- if ( Array . isArray ( target ) ) {
3761
+ if ( Array . isArray ( target ) && typeof key === 'number' ) {
3758
3762
target . splice ( key , 1 ) ;
3759
3763
return
3760
3764
}
3761
- var ob = target . __ob__ ;
3765
+ var ob = ( target ) . __ob__ ;
3762
3766
if ( target . _isVue || ( ob && ob . vmCount ) ) {
3763
3767
process . env . NODE_ENV !== 'production' && warn$2 (
3764
3768
'Avoid deleting properties on a Vue instance or its root $data ' +
@@ -4035,6 +4039,18 @@ function eventsMixin (Vue) {
4035
4039
4036
4040
Vue . prototype . $emit = function ( event ) {
4037
4041
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
+ }
4038
4054
var cbs = vm . _events [ event ] ;
4039
4055
if ( cbs ) {
4040
4056
cbs = cbs . length > 1 ? toArray ( cbs ) : cbs ;
@@ -4392,10 +4408,14 @@ function flushSchedulerQueue () {
4392
4408
}
4393
4409
}
4394
4410
4411
+ // reset scheduler before updated hook called
4412
+ var oldQueue = queue . slice ( ) ;
4413
+ resetSchedulerState ( ) ;
4414
+
4395
4415
// call updated hooks
4396
- index$1 = queue . length ;
4416
+ index$1 = oldQueue . length ;
4397
4417
while ( index$1 -- ) {
4398
- watcher = queue [ index$1 ] ;
4418
+ watcher = oldQueue [ index$1 ] ;
4399
4419
vm = watcher . vm ;
4400
4420
if ( vm . _watcher === watcher && vm . _isMounted ) {
4401
4421
callHook ( vm , 'updated' ) ;
@@ -4407,8 +4427,6 @@ function flushSchedulerQueue () {
4407
4427
if ( devtools && config . devtools ) {
4408
4428
devtools . emit ( 'flush' ) ;
4409
4429
}
4410
-
4411
- resetSchedulerState ( ) ;
4412
4430
}
4413
4431
4414
4432
/**
@@ -4765,7 +4783,7 @@ function initProps (vm, propsOptions) {
4765
4783
function initData ( vm ) {
4766
4784
var data = vm . $options . data ;
4767
4785
data = vm . _data = typeof data === 'function'
4768
- ? data . call ( vm )
4786
+ ? getData ( data , vm )
4769
4787
: data || { } ;
4770
4788
if ( ! isPlainObject ( data ) ) {
4771
4789
data = { } ;
@@ -4794,6 +4812,15 @@ function initData (vm) {
4794
4812
observe ( data , true /* asRootData */ ) ;
4795
4813
}
4796
4814
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
+
4797
4824
var computedWatcherOptions = { lazy : true } ;
4798
4825
4799
4826
function initComputed ( vm , computed ) {
@@ -5050,7 +5077,7 @@ function createComponent (
5050
5077
}
5051
5078
5052
5079
// extract props
5053
- var propsData = extractProps ( data , Ctor ) ;
5080
+ var propsData = extractProps ( data , Ctor , tag ) ;
5054
5081
5055
5082
// functional component
5056
5083
if ( Ctor . options . functional ) {
@@ -5191,7 +5218,7 @@ function resolveAsyncComponent (
5191
5218
}
5192
5219
}
5193
5220
5194
- function extractProps ( data , Ctor ) {
5221
+ function extractProps ( data , Ctor , tag ) {
5195
5222
// we are only extracting raw values here.
5196
5223
// validation and default values are handled in the child
5197
5224
// component itself.
@@ -5212,12 +5239,13 @@ function extractProps (data, Ctor) {
5212
5239
key !== keyInLowerCase &&
5213
5240
attrs && attrs . hasOwnProperty ( keyInLowerCase )
5214
5241
) {
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 + "\"."
5221
5249
) ;
5222
5250
}
5223
5251
}
@@ -5703,18 +5731,32 @@ function initInjections (vm) {
5703
5731
? Reflect . ownKeys ( inject )
5704
5732
: Object . keys ( inject ) ;
5705
5733
5706
- for ( var i = 0 ; i < keys . length ; i ++ ) {
5734
+ var loop = function ( i ) {
5707
5735
var key = keys [ i ] ;
5708
5736
var provideKey = isArray ? key : inject [ key ] ;
5709
5737
var source = vm ;
5710
5738
while ( source ) {
5711
5739
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
+ }
5713
5753
break
5714
5754
}
5715
5755
source = source . $parent ;
5716
5756
}
5717
- }
5757
+ } ;
5758
+
5759
+ for ( var i = 0 ; i < keys . length ; i ++ ) loop ( i ) ;
5718
5760
}
5719
5761
}
5720
5762
@@ -5724,14 +5766,18 @@ var uid = 0;
5724
5766
5725
5767
function initMixin ( Vue ) {
5726
5768
Vue . prototype . _init = function ( options ) {
5769
+ var vm = this ;
5770
+ // a uid
5771
+ vm . _uid = uid ++ ;
5772
+
5773
+ var startTag , endTag ;
5727
5774
/* istanbul ignore if */
5728
5775
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 ) ;
5730
5779
}
5731
5780
5732
- var vm = this ;
5733
- // a uid
5734
- vm . _uid = uid ++ ;
5735
5781
// a flag to avoid this being observed
5736
5782
vm . _isVue = true ;
5737
5783
// merge options
@@ -5767,8 +5813,8 @@ function initMixin (Vue) {
5767
5813
/* istanbul ignore if */
5768
5814
if ( process . env . NODE_ENV !== 'production' && config . performance && mark ) {
5769
5815
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 ) ;
5772
5818
}
5773
5819
5774
5820
if ( vm . $options . el ) {
@@ -6538,6 +6584,7 @@ var baseOptions = {
6538
6584
isPreTag : isPreTag ,
6539
6585
isUnaryTag : isUnaryTag ,
6540
6586
mustUseProp : mustUseProp ,
6587
+ canBeLeftOpenTag : canBeLeftOpenTag ,
6541
6588
isReservedTag : isReservedTag ,
6542
6589
getTagNamespace : getTagNamespace ,
6543
6590
staticKeys : genStaticKeys ( modules )
@@ -6688,6 +6735,22 @@ function hasAncestorData (node) {
6688
6735
return parentNode && ( parentNode . data || hasAncestorData ( parentNode ) )
6689
6736
}
6690
6737
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
+
6691
6754
function renderStartingTag ( node , context ) {
6692
6755
var markup = "<" + ( node . tag ) ;
6693
6756
var directives = context . directives ;
@@ -6703,14 +6766,22 @@ function renderStartingTag (node, context) {
6703
6766
var dirs = node . data . directives ;
6704
6767
if ( dirs ) {
6705
6768
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' ) {
6708
6772
// directives mutate the node's data
6709
6773
// which then gets rendered by modules
6710
6774
dirRenderer ( node , dirs [ i ] ) ;
6711
6775
}
6712
6776
}
6713
6777
}
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
+
6714
6785
// apply other modules
6715
6786
for ( var i$1 = 0 ; i$1 < modules . length ; i$1 ++ ) {
6716
6787
var res = modules [ i$1 ] ( node ) ;
@@ -7242,6 +7313,7 @@ function createRenderer$$1 (options) {
7242
7313
7243
7314
return createRenderer$1 ( {
7244
7315
isUnaryTag : isUnaryTag ,
7316
+ canBeLeftOpenTag : canBeLeftOpenTag ,
7245
7317
modules : modules$1 ,
7246
7318
// user can provide server-side implementations for custom directives
7247
7319
// when creating the renderer.
0 commit comments