1
1
/*!
2
- * Vue.js v2.5.9
2
+ * Vue.js v2.5.10
3
3
* (c) 2014-2017 Evan You
4
4
* Released under the MIT License.
5
5
*/
@@ -1149,18 +1149,18 @@ function mergeDataOrFn (
1149
1149
// it has to be a function to pass previous merges.
1150
1150
return function mergedDataFn ( ) {
1151
1151
return mergeData (
1152
- typeof childVal === 'function' ? childVal . call ( this ) : childVal ,
1153
- typeof parentVal === 'function' ? parentVal . call ( this ) : parentVal
1152
+ typeof childVal === 'function' ? childVal . call ( this , this ) : childVal ,
1153
+ typeof parentVal === 'function' ? parentVal . call ( this , this ) : parentVal
1154
1154
)
1155
1155
}
1156
1156
} else {
1157
1157
return function mergedInstanceDataFn ( ) {
1158
1158
// instance merge
1159
1159
var instanceData = typeof childVal === 'function'
1160
- ? childVal . call ( vm )
1160
+ ? childVal . call ( vm , vm )
1161
1161
: childVal ;
1162
1162
var defaultData = typeof parentVal === 'function'
1163
- ? parentVal . call ( vm )
1163
+ ? parentVal . call ( vm , vm )
1164
1164
: parentVal ;
1165
1165
if ( instanceData ) {
1166
1166
return mergeData ( instanceData , defaultData )
@@ -1312,13 +1312,24 @@ var defaultStrat = function (parentVal, childVal) {
1312
1312
*/
1313
1313
function checkComponents ( options ) {
1314
1314
for ( var key in options . components ) {
1315
- var lower = key . toLowerCase ( ) ;
1316
- if ( isBuiltInTag ( lower ) || config . isReservedTag ( lower ) ) {
1317
- warn (
1318
- 'Do not use built-in or reserved HTML elements as component ' +
1319
- 'id: ' + key
1320
- ) ;
1321
- }
1315
+ validateComponentName ( key ) ;
1316
+ }
1317
+ }
1318
+
1319
+ function validateComponentName ( name ) {
1320
+ if ( ! / ^ [ a - z A - Z ] [ \w - ] * $ / . test ( name ) ) {
1321
+ warn (
1322
+ 'Invalid component name: "' + name + '". Component names ' +
1323
+ 'can only contain alphanumeric characters and the hyphen, ' +
1324
+ 'and must start with a letter.'
1325
+ ) ;
1326
+ }
1327
+ var lower = name . toLowerCase ( ) ;
1328
+ if ( isBuiltInTag ( lower ) || config . isReservedTag ( lower ) ) {
1329
+ warn (
1330
+ 'Do not use built-in or reserved HTML elements as component ' +
1331
+ 'id: ' + name
1332
+ ) ;
1322
1333
}
1323
1334
}
1324
1335
@@ -3814,19 +3825,9 @@ function bindObjectProps (
3814
3825
*/
3815
3826
function renderStatic (
3816
3827
index ,
3817
- isInFor ,
3818
- isOnce
3828
+ isInFor
3819
3829
) {
3820
- // render fns generated by compiler < 2.5.4 does not provide v-once
3821
- // information to runtime so be conservative
3822
- var isOldVersion = arguments . length < 3 ;
3823
- // if a static tree is generated by v-once, it is cached on the instance;
3824
- // otherwise it is purely static and can be cached on the shared options
3825
- // across all instances.
3826
- var renderFns = this . $options . staticRenderFns ;
3827
- var cached = isOldVersion || isOnce
3828
- ? ( this . _staticTrees || ( this . _staticTrees = [ ] ) )
3829
- : ( renderFns . cached || ( renderFns . cached = [ ] ) ) ;
3830
+ var cached = this . _staticTrees || ( this . _staticTrees = [ ] ) ;
3830
3831
var tree = cached [ index ] ;
3831
3832
// if has already-rendered static tree and not inside v-for,
3832
3833
// we can reuse the same tree by doing a shallow clone.
@@ -3836,7 +3837,11 @@ function renderStatic (
3836
3837
: cloneVNode ( tree )
3837
3838
}
3838
3839
// otherwise, render a fresh tree.
3839
- tree = cached [ index ] = renderFns [ index ] . call ( this . _renderProxy , null , this ) ;
3840
+ tree = cached [ index ] = this . $options . staticRenderFns [ index ] . call (
3841
+ this . _renderProxy ,
3842
+ null ,
3843
+ this // for render fns generated for functional component templates
3844
+ ) ;
3840
3845
markStatic ( tree , ( "__static__" + index ) , false ) ;
3841
3846
return tree
3842
3847
}
@@ -4188,15 +4193,10 @@ function createComponentInstanceForVnode (
4188
4193
parentElm ,
4189
4194
refElm
4190
4195
) {
4191
- var vnodeComponentOptions = vnode . componentOptions ;
4192
4196
var options = {
4193
4197
_isComponent : true ,
4194
4198
parent : parent ,
4195
- propsData : vnodeComponentOptions . propsData ,
4196
- _componentTag : vnodeComponentOptions . tag ,
4197
4199
_parentVnode : vnode ,
4198
- _parentListeners : vnodeComponentOptions . listeners ,
4199
- _renderChildren : vnodeComponentOptions . children ,
4200
4200
_parentElm : parentElm || null ,
4201
4201
_refElm : refElm || null
4202
4202
} ;
@@ -4206,7 +4206,7 @@ function createComponentInstanceForVnode (
4206
4206
options . render = inlineTemplate . render ;
4207
4207
options . staticRenderFns = inlineTemplate . staticRenderFns ;
4208
4208
}
4209
- return new vnodeComponentOptions . Ctor ( options )
4209
+ return new vnode . componentOptions . Ctor ( options )
4210
4210
}
4211
4211
4212
4212
function mergeHooks ( data ) {
@@ -4540,14 +4540,18 @@ function initMixin (Vue) {
4540
4540
function initInternalComponent ( vm , options ) {
4541
4541
var opts = vm . $options = Object . create ( vm . constructor . options ) ;
4542
4542
// doing this because it's faster than dynamic enumeration.
4543
+ var parentVnode = options . _parentVnode ;
4543
4544
opts . parent = options . parent ;
4544
- opts . propsData = options . propsData ;
4545
- opts . _parentVnode = options . _parentVnode ;
4546
- opts . _parentListeners = options . _parentListeners ;
4547
- opts . _renderChildren = options . _renderChildren ;
4548
- opts . _componentTag = options . _componentTag ;
4545
+ opts . _parentVnode = parentVnode ;
4549
4546
opts . _parentElm = options . _parentElm ;
4550
4547
opts . _refElm = options . _refElm ;
4548
+
4549
+ var vnodeComponentOptions = parentVnode . componentOptions ;
4550
+ opts . propsData = vnodeComponentOptions . propsData ;
4551
+ opts . _parentListeners = vnodeComponentOptions . listeners ;
4552
+ opts . _renderChildren = vnodeComponentOptions . children ;
4553
+ opts . _componentTag = vnodeComponentOptions . tag ;
4554
+
4551
4555
if ( options . render ) {
4552
4556
opts . render = options . render ;
4553
4557
opts . staticRenderFns = options . staticRenderFns ;
@@ -4681,14 +4685,8 @@ function initExtend (Vue) {
4681
4685
}
4682
4686
4683
4687
var name = extendOptions . name || Super . options . name ;
4684
- if ( process . env . NODE_ENV !== 'production' ) {
4685
- if ( ! / ^ [ a - z A - Z ] [ \w - ] * $ / . test ( name ) ) {
4686
- warn (
4687
- 'Invalid component name: "' + name + '". Component names ' +
4688
- 'can only contain alphanumeric characters and the hyphen, ' +
4689
- 'and must start with a letter.'
4690
- ) ;
4691
- }
4688
+ if ( process . env . NODE_ENV !== 'production' && name ) {
4689
+ validateComponentName ( name ) ;
4692
4690
}
4693
4691
4694
4692
var Sub = function VueComponent ( options ) {
@@ -4770,13 +4768,8 @@ function initAssetRegisters (Vue) {
4770
4768
return this . options [ type + 's' ] [ id ]
4771
4769
} else {
4772
4770
/* istanbul ignore if */
4773
- if ( process . env . NODE_ENV !== 'production' ) {
4774
- if ( type === 'component' && config . isReservedTag ( id ) ) {
4775
- warn (
4776
- 'Do not use built-in or reserved HTML elements as component ' +
4777
- 'id: ' + id
4778
- ) ;
4779
- }
4771
+ if ( process . env . NODE_ENV !== 'production' && type === 'component' ) {
4772
+ validateComponentName ( id ) ;
4780
4773
}
4781
4774
if ( type === 'component' && isPlainObject ( definition ) ) {
4782
4775
definition . name = definition . name || id ;
@@ -4983,7 +4976,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
4983
4976
}
4984
4977
} ) ;
4985
4978
4986
- Vue$3 . version = '2.5.9 ' ;
4979
+ Vue$3 . version = '2.5.10 ' ;
4987
4980
4988
4981
/* */
4989
4982
@@ -5551,6 +5544,9 @@ function createPatchFunction (backend) {
5551
5544
5552
5545
function createChildren ( vnode , children , insertedVnodeQueue ) {
5553
5546
if ( Array . isArray ( children ) ) {
5547
+ if ( process . env . NODE_ENV !== 'production' ) {
5548
+ checkDuplicateKeys ( children ) ;
5549
+ }
5554
5550
for ( var i = 0 ; i < children . length ; ++ i ) {
5555
5551
createElm ( children [ i ] , insertedVnodeQueue , vnode . elm , null , true ) ;
5556
5552
}
@@ -5682,6 +5678,10 @@ function createPatchFunction (backend) {
5682
5678
// during leaving transitions
5683
5679
var canMove = ! removeOnly ;
5684
5680
5681
+ if ( process . env . NODE_ENV !== 'production' ) {
5682
+ checkDuplicateKeys ( newCh ) ;
5683
+ }
5684
+
5685
5685
while ( oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx ) {
5686
5686
if ( isUndef ( oldStartVnode ) ) {
5687
5687
oldStartVnode = oldCh [ ++ oldStartIdx ] ; // Vnode has been moved left
@@ -5714,13 +5714,6 @@ function createPatchFunction (backend) {
5714
5714
createElm ( newStartVnode , insertedVnodeQueue , parentElm , oldStartVnode . elm ) ;
5715
5715
} else {
5716
5716
vnodeToMove = oldCh [ idxInOld ] ;
5717
- /* istanbul ignore if */
5718
- if ( process . env . NODE_ENV !== 'production' && ! vnodeToMove ) {
5719
- warn (
5720
- 'It seems there are duplicate keys that is causing an update error. ' +
5721
- 'Make sure each v-for item has a unique key.'
5722
- ) ;
5723
- }
5724
5717
if ( sameVnode ( vnodeToMove , newStartVnode ) ) {
5725
5718
patchVnode ( vnodeToMove , newStartVnode , insertedVnodeQueue ) ;
5726
5719
oldCh [ idxInOld ] = undefined ;
@@ -5741,6 +5734,24 @@ function createPatchFunction (backend) {
5741
5734
}
5742
5735
}
5743
5736
5737
+ function checkDuplicateKeys ( children ) {
5738
+ var seenKeys = { } ;
5739
+ for ( var i = 0 ; i < children . length ; i ++ ) {
5740
+ var vnode = children [ i ] ;
5741
+ var key = vnode . key ;
5742
+ if ( isDef ( key ) ) {
5743
+ if ( seenKeys [ key ] ) {
5744
+ warn (
5745
+ ( "Duplicate keys detected: '" + key + "'. This may cause an update error." ) ,
5746
+ vnode . context
5747
+ ) ;
5748
+ } else {
5749
+ seenKeys [ key ] = true ;
5750
+ }
5751
+ }
5752
+ }
5753
+ }
5754
+
5744
5755
function findIdxInOld ( node , oldCh , start , end ) {
5745
5756
for ( var i = start ; i < end ; i ++ ) {
5746
5757
var c = oldCh [ i ] ;
@@ -6997,12 +7008,12 @@ function updateDOMProps (oldVnode, vnode) {
6997
7008
function shouldUpdateValue ( elm , checkVal ) {
6998
7009
return ( ! elm . composing && (
6999
7010
elm . tagName === 'OPTION' ||
7000
- isDirty ( elm , checkVal ) ||
7001
- isInputChanged ( elm , checkVal )
7011
+ isNotInFocusAndDirty ( elm , checkVal ) ||
7012
+ isDirtyWithModifiers ( elm , checkVal )
7002
7013
) )
7003
7014
}
7004
7015
7005
- function isDirty ( elm , checkVal ) {
7016
+ function isNotInFocusAndDirty ( elm , checkVal ) {
7006
7017
// return true when textbox (.number and .trim) loses focus and its value is
7007
7018
// not equal to the updated value
7008
7019
var notInFocus = true ;
@@ -7012,14 +7023,20 @@ function isDirty (elm, checkVal) {
7012
7023
return notInFocus && elm . value !== checkVal
7013
7024
}
7014
7025
7015
- function isInputChanged ( elm , newVal ) {
7026
+ function isDirtyWithModifiers ( elm , newVal ) {
7016
7027
var value = elm . value ;
7017
7028
var modifiers = elm . _vModifiers ; // injected by v-model runtime
7018
- if ( isDef ( modifiers ) && modifiers . number ) {
7019
- return toNumber ( value ) !== toNumber ( newVal )
7020
- }
7021
- if ( isDef ( modifiers ) && modifiers . trim ) {
7022
- return value . trim ( ) !== newVal . trim ( )
7029
+ if ( isDef ( modifiers ) ) {
7030
+ if ( modifiers . lazy ) {
7031
+ // inputs with lazy should only be updated when not in focus
7032
+ return false
7033
+ }
7034
+ if ( modifiers . number ) {
7035
+ return toNumber ( value ) !== toNumber ( newVal )
7036
+ }
7037
+ if ( modifiers . trim ) {
7038
+ return value . trim ( ) !== newVal . trim ( )
7039
+ }
7023
7040
}
7024
7041
return value !== newVal
7025
7042
}
@@ -8857,7 +8874,7 @@ function parseHTML (html, options) {
8857
8874
var onRE = / ^ @ | ^ v - o n : / ;
8858
8875
var dirRE = / ^ v - | ^ @ | ^ : / ;
8859
8876
var forAliasRE = / ( .* ?) \s + (?: i n | o f ) \s + ( .* ) / ;
8860
- var forIteratorRE = / \( ( \{ [ ^ } ] * \} | [ ^ , { ] * ) , ( [ ^ , ] * ) (?: , ( [ ^ , ] * ) ) ? \) / ;
8877
+ var forIteratorRE = / , ( [ ^ , \} \] ] * ) (?: , ( [ ^ , \} \] ] * ) ) ? $ / ;
8861
8878
var stripParensRE = / ^ \( | \) $ / g;
8862
8879
8863
8880
var argRE = / : ( .* ) $ / ;
@@ -9190,16 +9207,16 @@ function processFor (el) {
9190
9207
return
9191
9208
}
9192
9209
el . for = inMatch [ 2 ] . trim ( ) ;
9193
- var alias = inMatch [ 1 ] . trim ( ) ;
9210
+ var alias = inMatch [ 1 ] . trim ( ) . replace ( stripParensRE , '' ) ;
9194
9211
var iteratorMatch = alias . match ( forIteratorRE ) ;
9195
9212
if ( iteratorMatch ) {
9196
- el . alias = iteratorMatch [ 1 ] . trim ( ) ;
9197
- el . iterator1 = iteratorMatch [ 2 ] . trim ( ) ;
9198
- if ( iteratorMatch [ 3 ] ) {
9199
- el . iterator2 = iteratorMatch [ 3 ] . trim ( ) ;
9213
+ el . alias = alias . replace ( forIteratorRE , '' ) ;
9214
+ el . iterator1 = iteratorMatch [ 1 ] . trim ( ) ;
9215
+ if ( iteratorMatch [ 2 ] ) {
9216
+ el . iterator2 = iteratorMatch [ 2 ] . trim ( ) ;
9200
9217
}
9201
9218
} else {
9202
- el . alias = alias . replace ( stripParensRE , '' ) ;
9219
+ el . alias = alias ;
9203
9220
}
9204
9221
}
9205
9222
}
@@ -9948,10 +9965,10 @@ function genElement (el, state) {
9948
9965
}
9949
9966
9950
9967
// hoist static sub-trees out
9951
- function genStatic ( el , state , once$$1 ) {
9968
+ function genStatic ( el , state ) {
9952
9969
el . staticProcessed = true ;
9953
9970
state . staticRenderFns . push ( ( "with(this){return " + ( genElement ( el , state ) ) + "}" ) ) ;
9954
- return ( "_m(" + ( state . staticRenderFns . length - 1 ) + "," + ( el . staticInFor ? 'true' : 'false' ) + "," + ( once$$1 ? ' true' : 'false ' ) + ")" )
9971
+ return ( "_m(" + ( state . staticRenderFns . length - 1 ) + ( el . staticInFor ? ', true' : '' ) + ")" )
9955
9972
}
9956
9973
9957
9974
// v-once
@@ -9977,7 +9994,7 @@ function genOnce (el, state) {
9977
9994
}
9978
9995
return ( "_o(" + ( genElement ( el , state ) ) + "," + ( state . onceId ++ ) + "," + key + ")" )
9979
9996
} else {
9980
- return genStatic ( el , state , true )
9997
+ return genStatic ( el , state )
9981
9998
}
9982
9999
}
9983
10000
0 commit comments