1
1
/*!
2
- * Vue.js v2.4.1
2
+ * Vue.js v2.4.2
3
3
* (c) 2014-2017 Evan You
4
4
* Released under the MIT License.
5
5
*/
@@ -29,7 +29,11 @@ function isFalse (v) {
29
29
* Check if value is primitive
30
30
*/
31
31
function isPrimitive ( value ) {
32
- return typeof value === 'string' || typeof value === 'number'
32
+ return (
33
+ typeof value === 'string' ||
34
+ typeof value === 'number' ||
35
+ typeof value === 'boolean'
36
+ )
33
37
}
34
38
35
39
/**
@@ -252,14 +256,30 @@ function genStaticKeys (modules) {
252
256
* if they are plain objects, do they have the same shape?
253
257
*/
254
258
function looseEqual ( a , b ) {
259
+ if ( a === b ) { return true }
255
260
var isObjectA = isObject ( a ) ;
256
261
var isObjectB = isObject ( b ) ;
257
262
if ( isObjectA && isObjectB ) {
258
263
try {
259
- return JSON . stringify ( a ) === JSON . stringify ( b )
264
+ var isArrayA = Array . isArray ( a ) ;
265
+ var isArrayB = Array . isArray ( b ) ;
266
+ if ( isArrayA && isArrayB ) {
267
+ return a . length === b . length && a . every ( function ( e , i ) {
268
+ return looseEqual ( e , b [ i ] )
269
+ } )
270
+ } else if ( ! isArrayA && ! isArrayB ) {
271
+ var keysA = Object . keys ( a ) ;
272
+ var keysB = Object . keys ( b ) ;
273
+ return keysA . length === keysB . length && keysA . every ( function ( key ) {
274
+ return looseEqual ( a [ key ] , b [ key ] )
275
+ } )
276
+ } else {
277
+ /* istanbul ignore next */
278
+ return false
279
+ }
260
280
} catch ( e ) {
261
- // possible circular reference
262
- return a === b
281
+ /* istanbul ignore next */
282
+ return false
263
283
}
264
284
} else if ( ! isObjectA && ! isObjectB ) {
265
285
return String ( a ) === String ( b )
@@ -1124,7 +1144,7 @@ function mergeDataOrFn (
1124
1144
return function mergedDataFn ( ) {
1125
1145
return mergeData (
1126
1146
typeof childVal === 'function' ? childVal . call ( this ) : childVal ,
1127
- parentVal . call ( this )
1147
+ typeof parentVal === 'function' ? parentVal . call ( this ) : parentVal
1128
1148
)
1129
1149
}
1130
1150
} else if ( parentVal || childVal ) {
@@ -1240,11 +1260,10 @@ strats.props =
1240
1260
strats . methods =
1241
1261
strats . inject =
1242
1262
strats . computed = function ( parentVal , childVal ) {
1243
- if ( ! childVal ) { return Object . create ( parentVal || null ) }
1244
1263
if ( ! parentVal ) { return childVal }
1245
1264
var ret = Object . create ( null ) ;
1246
1265
extend ( ret , parentVal ) ;
1247
- extend ( ret , childVal ) ;
1266
+ if ( childVal ) { extend ( ret , childVal ) ; }
1248
1267
return ret
1249
1268
} ;
1250
1269
strats . provide = mergeDataOrFn ;
@@ -3190,17 +3209,14 @@ function initComputed (vm, computed) {
3190
3209
for ( var key in computed ) {
3191
3210
var userDef = computed [ key ] ;
3192
3211
var getter = typeof userDef === 'function' ? userDef : userDef . get ;
3193
- if ( process . env . NODE_ENV !== 'production' ) {
3194
- if ( getter === undefined ) {
3195
- warn (
3196
- ( "No getter function has been defined for computed property \"" + key + "\"." ) ,
3197
- vm
3198
- ) ;
3199
- getter = noop ;
3200
- }
3212
+ if ( process . env . NODE_ENV !== 'production' && getter == null ) {
3213
+ warn (
3214
+ ( "Getter is missing for computed property \"" + key + "\"." ) ,
3215
+ vm
3216
+ ) ;
3201
3217
}
3202
3218
// create internal watcher for the computed property.
3203
- watchers [ key ] = new Watcher ( vm , getter , noop , computedWatcherOptions ) ;
3219
+ watchers [ key ] = new Watcher ( vm , getter || noop , noop , computedWatcherOptions ) ;
3204
3220
3205
3221
// component-defined computed properties are already defined on the
3206
3222
// component prototype. We only need to define computed properties defined
@@ -3231,6 +3247,15 @@ function defineComputed (target, key, userDef) {
3231
3247
? userDef . set
3232
3248
: noop ;
3233
3249
}
3250
+ if ( process . env . NODE_ENV !== 'production' &&
3251
+ sharedPropertyDefinition . set === noop ) {
3252
+ sharedPropertyDefinition . set = function ( ) {
3253
+ warn (
3254
+ ( "Computed property \"" + key + "\" was assigned to but it has no setter." ) ,
3255
+ this
3256
+ ) ;
3257
+ } ;
3258
+ }
3234
3259
Object . defineProperty ( target , key , sharedPropertyDefinition ) ;
3235
3260
}
3236
3261
@@ -3402,7 +3427,7 @@ function resolveInject (inject, vm) {
3402
3427
}
3403
3428
source = source . $parent ;
3404
3429
}
3405
- if ( process . env . NODE_ENV !== 'production' && ! hasOwn ( result , key ) ) {
3430
+ if ( process . env . NODE_ENV !== 'production' && ! source ) {
3406
3431
warn ( ( "Injection \"" + key + "\" not found" ) , vm ) ;
3407
3432
}
3408
3433
}
@@ -3595,8 +3620,12 @@ function createComponent (
3595
3620
return createFunctionalComponent ( Ctor , propsData , data , context , children )
3596
3621
}
3597
3622
3598
- // keep listeners
3623
+ // extract listeners, since these needs to be treated as
3624
+ // child component listeners instead of DOM listeners
3599
3625
var listeners = data . on ;
3626
+ // replace with listeners with .native modifier
3627
+ // so it gets processed during parent component patch.
3628
+ data . on = data . nativeOn ;
3600
3629
3601
3630
if ( isTrue ( Ctor . options . abstract ) ) {
3602
3631
// abstract components do not keep anything
@@ -4059,12 +4088,12 @@ function initRender (vm) {
4059
4088
defineReactive$$1 ( vm , '$attrs' , parentData && parentData . attrs , function ( ) {
4060
4089
! isUpdatingChildComponent && warn ( "$attrs is readonly." , vm ) ;
4061
4090
} , true ) ;
4062
- defineReactive$$1 ( vm , '$listeners' , parentData && parentData . on , function ( ) {
4091
+ defineReactive$$1 ( vm , '$listeners' , vm . $options . _parentListeners , function ( ) {
4063
4092
! isUpdatingChildComponent && warn ( "$listeners is readonly." , vm ) ;
4064
4093
} , true ) ;
4065
4094
} else {
4066
4095
defineReactive$$1 ( vm , '$attrs' , parentData && parentData . attrs , null , true ) ;
4067
- defineReactive$$1 ( vm , '$listeners' , parentData && parentData . on , null , true ) ;
4096
+ defineReactive$$1 ( vm , '$listeners' , vm . $options . _parentListeners , null , true ) ;
4068
4097
}
4069
4098
}
4070
4099
@@ -4628,7 +4657,7 @@ Object.defineProperty(Vue$3.prototype, '$ssrContext', {
4628
4657
}
4629
4658
} ) ;
4630
4659
4631
- Vue$3 . version = '2.4.1 ' ;
4660
+ Vue$3 . version = '2.4.2 ' ;
4632
4661
4633
4662
/* */
4634
4663
@@ -6288,7 +6317,7 @@ function genCheckboxModel (
6288
6317
'if(Array.isArray($$a)){' +
6289
6318
"var $$v=" + ( number ? '_n(' + valueBinding + ')' : valueBinding ) + "," +
6290
6319
'$$i=_i($$a,$$v);' +
6291
- "if($$c ){$$i<0&&(" + value + "=$$a.concat($$v))}" +
6320
+ "if($$el.checked ){$$i<0&&(" + value + "=$$a.concat($$v))}" +
6292
6321
"else{$$i>-1&&(" + value + "=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}" +
6293
6322
"}else{" + ( genAssignmentCode ( value , '$$c' ) ) + "}" ,
6294
6323
null , true
@@ -6424,14 +6453,11 @@ function remove$2 (
6424
6453
}
6425
6454
6426
6455
function updateDOMListeners ( oldVnode , vnode ) {
6427
- var isComponentRoot = isDef ( vnode . componentOptions ) ;
6428
- var oldOn = isComponentRoot ? oldVnode . data . nativeOn : oldVnode . data . on ;
6429
- var on = isComponentRoot ? vnode . data . nativeOn : vnode . data . on ;
6430
- if ( isUndef ( oldOn ) && isUndef ( on ) ) {
6456
+ if ( isUndef ( oldVnode . data . on ) && isUndef ( vnode . data . on ) ) {
6431
6457
return
6432
6458
}
6433
- on = on || { } ;
6434
- oldOn = oldOn || { } ;
6459
+ var on = vnode . data . on || { } ;
6460
+ var oldOn = oldVnode . data . on || { } ;
6435
6461
target$1 = vnode . elm ;
6436
6462
normalizeEvents ( on ) ;
6437
6463
updateListeners ( on , oldOn , add$1 , remove$2 , vnode . context ) ;
@@ -6505,7 +6531,11 @@ function shouldUpdateValue (
6505
6531
function isDirty ( elm , checkVal ) {
6506
6532
// return true when textbox (.number and .trim) loses focus and its value is
6507
6533
// not equal to the updated value
6508
- return document . activeElement !== elm && elm . value !== checkVal
6534
+ var notInFocus = true ;
6535
+ // #6157
6536
+ // work around IE bug when accessing document.activeElement in an iframe
6537
+ try { notInFocus = document . activeElement !== elm ; } catch ( e ) { }
6538
+ return notInFocus && elm . value !== checkVal
6509
6539
}
6510
6540
6511
6541
function isInputChanged ( elm , newVal ) {
@@ -7285,6 +7315,7 @@ var model$1 = {
7285
7315
if ( isIE || isEdge ) {
7286
7316
setTimeout ( cb , 0 ) ;
7287
7317
}
7318
+ el . _vOptions = [ ] . map . call ( el . options , getValue ) ;
7288
7319
} else if ( vnode . tag === 'textarea' || isTextInputType ( el . type ) ) {
7289
7320
el . _vModifiers = binding . modifiers ;
7290
7321
if ( ! binding . modifiers . lazy ) {
@@ -7311,10 +7342,9 @@ var model$1 = {
7311
7342
// it's possible that the value is out-of-sync with the rendered options.
7312
7343
// detect such cases and filter out values that no longer has a matching
7313
7344
// option in the DOM.
7314
- var needReset = el . multiple
7315
- ? binding . value . some ( function ( v ) { return hasNoMatchingOption ( v , el . options ) ; } )
7316
- : binding . value !== binding . oldValue && hasNoMatchingOption ( binding . value , el . options ) ;
7317
- if ( needReset ) {
7345
+ var prevOptions = el . _vOptions ;
7346
+ var curOptions = el . _vOptions = [ ] . map . call ( el . options , getValue ) ;
7347
+ if ( curOptions . some ( function ( o , i ) { return ! looseEqual ( o , prevOptions [ i ] ) ; } ) ) {
7318
7348
trigger ( el , 'change' ) ;
7319
7349
}
7320
7350
}
@@ -7354,15 +7384,6 @@ function setSelected (el, binding, vm) {
7354
7384
}
7355
7385
}
7356
7386
7357
- function hasNoMatchingOption ( value , options ) {
7358
- for ( var i = 0 , l = options . length ; i < l ; i ++ ) {
7359
- if ( looseEqual ( getValue ( options [ i ] ) , value ) ) {
7360
- return false
7361
- }
7362
- }
7363
- return true
7364
- }
7365
-
7366
7387
function getValue ( option ) {
7367
7388
return '_value' in option
7368
7389
? option . _value
@@ -7403,7 +7424,7 @@ var show = {
7403
7424
var transition$$1 = vnode . data && vnode . data . transition ;
7404
7425
var originalDisplay = el . __vOriginalDisplay =
7405
7426
el . style . display === 'none' ? '' : el . style . display ;
7406
- if ( value && transition$$1 && ! isIE9 ) {
7427
+ if ( value && transition$$1 ) {
7407
7428
vnode . data . show = true ;
7408
7429
enter ( vnode , function ( ) {
7409
7430
el . style . display = originalDisplay ;
@@ -7421,7 +7442,7 @@ var show = {
7421
7442
if ( value === oldValue ) { return }
7422
7443
vnode = locateNode ( vnode ) ;
7423
7444
var transition$$1 = vnode . data && vnode . data . transition ;
7424
- if ( transition$$1 && ! isIE9 ) {
7445
+ if ( transition$$1 ) {
7425
7446
vnode . data . show = true ;
7426
7447
if ( value ) {
7427
7448
enter ( vnode , function ( ) {
@@ -8162,9 +8183,6 @@ function parseHTML (html, options) {
8162
8183
last = html ;
8163
8184
// Make sure we're not in a plaintext content element like script/style
8164
8185
if ( ! lastTag || ! isPlainTextElement ( lastTag ) ) {
8165
- if ( shouldIgnoreFirstNewline ( lastTag , html ) ) {
8166
- advance ( 1 ) ;
8167
- }
8168
8186
var textEnd = html . indexOf ( '<' ) ;
8169
8187
if ( textEnd === 0 ) {
8170
8188
// Comment:
@@ -8210,6 +8228,9 @@ function parseHTML (html, options) {
8210
8228
var startTagMatch = parseStartTag ( ) ;
8211
8229
if ( startTagMatch ) {
8212
8230
handleStartTag ( startTagMatch ) ;
8231
+ if ( shouldIgnoreFirstNewline ( lastTag , html ) ) {
8232
+ advance ( 1 ) ;
8233
+ }
8213
8234
continue
8214
8235
}
8215
8236
}
@@ -8870,8 +8891,8 @@ function processAttrs (el) {
8870
8891
) ;
8871
8892
}
8872
8893
}
8873
- if ( ! el . component && (
8874
- isProp || platformMustUseProp ( el . tag , el . attrsMap . type , name )
8894
+ if ( isProp || (
8895
+ ! el . component && platformMustUseProp ( el . tag , el . attrsMap . type , name )
8875
8896
) ) {
8876
8897
addProp ( el , name , value ) ;
8877
8898
} else {
@@ -9657,7 +9678,7 @@ function genText (text) {
9657
9678
}
9658
9679
9659
9680
function genComment ( comment ) {
9660
- return ( "_e(' " + ( comment . text ) + "' )" )
9681
+ return ( "_e(" + ( JSON . stringify ( comment . text ) ) + ")" )
9661
9682
}
9662
9683
9663
9684
function genSlot ( el , state ) {
0 commit comments