@@ -74,7 +74,7 @@ module.exports = {
74
74
return {
75
75
search : '' ,
76
76
isOpen : false ,
77
- internalValue : this . value || this . value === 0 ? ( 0 , _utils2 . default ) ( this . value ) : this . multiple ? [ ] : null
77
+ internalValue : this . value || this . value === 0 ? this . multiple ? ( 0 , _utils2 . default ) ( this . value ) : ( 0 , _utils2 . default ) ( [ this . value ] ) : [ ]
78
78
} ;
79
79
} ,
80
80
@@ -213,9 +213,9 @@ module.exports = {
213
213
var _this = this ;
214
214
215
215
if ( this . trackBy ) {
216
- return this . multiple ? this . internalValue . map ( function ( element ) {
216
+ return this . internalValue . map ( function ( element ) {
217
217
return element [ _this . trackBy ] ;
218
- } ) : this . internalValue [ this . trackBy ] ;
218
+ } ) ;
219
219
} else {
220
220
return this . internalValue ;
221
221
}
@@ -231,13 +231,13 @@ module.exports = {
231
231
} ) ;
232
232
} ,
233
233
currentOptionLabel : function currentOptionLabel ( ) {
234
- return this . getOptionLabel ( this . internalValue ) + '' ;
234
+ return this . getOptionLabel ( this . internalValue [ 0 ] ) + '' ;
235
235
}
236
236
} ,
237
237
watch : {
238
238
'internalValue' : function internalValue ( ) {
239
239
if ( this . resetAfter ) {
240
- this . internalValue = null ;
240
+ this . internalValue = [ ] ;
241
241
this . search = '' ;
242
242
}
243
243
this . adjustSearch ( ) ;
@@ -248,7 +248,7 @@ module.exports = {
248
248
this . $emit ( 'search-change' , this . search , this . id ) ;
249
249
} ,
250
250
'value' : function value ( ) {
251
- this . internalValue = ( 0 , _utils2 . default ) ( this . value ) ;
251
+ this . internalValue = ( 0 , _utils2 . default ) ( this . multiple ? this . value : [ this . value ] ) ;
252
252
}
253
253
} ,
254
254
methods : {
@@ -265,14 +265,8 @@ module.exports = {
265
265
return ! this . options ? false : this . optionKeys . indexOf ( query ) > - 1 ;
266
266
} ,
267
267
isSelected : function isSelected ( option ) {
268
- if ( ! this . internalValue ) return false ;
269
268
var opt = this . trackBy ? option [ this . trackBy ] : option ;
270
-
271
- if ( this . multiple ) {
272
- return this . valueKeys . indexOf ( opt ) > - 1 ;
273
- } else {
274
- return this . valueKeys === opt ;
275
- }
269
+ return this . valueKeys . indexOf ( opt ) > - 1 ;
276
270
} ,
277
271
isNotSelected : function isNotSelected ( option ) {
278
272
return ! this . isSelected ( option ) ;
@@ -290,22 +284,18 @@ module.exports = {
290
284
this . $emit ( 'tag' , option . label , this . id ) ;
291
285
this . search = '' ;
292
286
} else {
293
- if ( this . multiple ) {
294
- if ( this . isSelected ( option ) ) {
295
- if ( key !== 'Tab' ) this . removeElement ( option ) ;
296
- return ;
297
- } else {
298
- this . internalValue . push ( option ) ;
299
- }
287
+ var isSelected = this . isSelected ( option ) ;
288
+ if ( isSelected ) {
289
+ if ( key !== 'Tab' ) this . removeElement ( option ) ;
290
+ return ;
291
+ } else if ( this . multiple ) {
292
+ this . internalValue . push ( option ) ;
300
293
} else {
301
- var isSelected = this . isSelected ( option ) ;
302
-
303
- if ( isSelected && ( ! this . allowEmpty || key === 'Tab' ) ) return ;
304
-
305
- this . internalValue = isSelected ? null : option ;
294
+ this . internalValue = [ option ] ;
306
295
}
307
296
this . $emit ( 'select' , ( 0 , _utils2 . default ) ( option ) , this . id ) ;
308
- this . $emit ( 'input' , ( 0 , _utils2 . default ) ( this . internalValue ) , this . id ) ;
297
+ var value = this . multiple ? this . internalValue : this . internalValue [ 0 ] ;
298
+ this . $emit ( 'input' , ( 0 , _utils2 . default ) ( value ) , this . id ) ;
309
299
310
300
if ( this . closeOnSelect ) this . deactivate ( ) ;
311
301
}
@@ -314,11 +304,12 @@ module.exports = {
314
304
if ( this . disabled ) return ;
315
305
if ( ! this . allowEmpty && this . internalValue . length <= 1 ) return ;
316
306
317
- var index = this . multiple && ( typeof option === 'undefined' ? 'undefined' : _typeof ( option ) ) === 'object' ? this . valueKeys . indexOf ( option [ this . trackBy ] ) : this . valueKeys . indexOf ( option ) ;
307
+ var index = ( typeof option === 'undefined' ? 'undefined' : _typeof ( option ) ) === 'object' ? this . valueKeys . indexOf ( option [ this . trackBy ] ) : this . valueKeys . indexOf ( option ) ;
318
308
319
309
this . internalValue . splice ( index , 1 ) ;
320
310
this . $emit ( 'remove' , ( 0 , _utils2 . default ) ( option ) , this . id ) ;
321
- this . $emit ( 'input' , ( 0 , _utils2 . default ) ( this . internalValue ) , this . id ) ;
311
+ var value = this . multiple ? this . internalValue : this . internalValue [ 0 ] ;
312
+ this . $emit ( 'input' , ( 0 , _utils2 . default ) ( value ) , this . id ) ;
322
313
} ,
323
314
removeLastElement : function removeLastElement ( ) {
324
315
if ( this . blockKeys . indexOf ( 'Delete' ) !== - 1 ) return ;
@@ -351,7 +342,8 @@ module.exports = {
351
342
} else {
352
343
this . $el . blur ( ) ;
353
344
}
354
- this . $emit ( 'close' , ( 0 , _utils2 . default ) ( this . internalValue ) , this . id ) ;
345
+ var value = this . multiple ? this . internalValue : this . internalValue [ 0 ] ;
346
+ this . $emit ( 'close' , ( 0 , _utils2 . default ) ( value ) , this . id ) ;
355
347
} ,
356
348
adjustSearch : function adjustSearch ( ) {
357
349
if ( ! this . searchable || ! this . clearOnSelect ) return ;
0 commit comments