@@ -170,12 +170,6 @@ export default Vue.extend({
170170 ( this . popupContentClass ? ' ' + this . popupContentClass : '' )
171171 } ,
172172
173- optionValueKey ( ) {
174- return typeof this . optionValue === 'string'
175- ? this . optionValue
176- : 'value'
177- } ,
178-
179173 innerValue ( ) {
180174 const
181175 mapNull = this . mapOptions === true && this . multiple !== true ,
@@ -240,7 +234,7 @@ export default Vue.extend({
240234 const { from, to } = this . virtualScrollSliceRange
241235
242236 return this . options . slice ( from , to ) . map ( ( opt , i ) => {
243- const disable = this . __isDisabled ( opt )
237+ const disable = this . __getOptionDisabled ( opt ) === true
244238 const index = from + i
245239
246240 const itemProps = {
@@ -300,6 +294,18 @@ export default Vue.extend({
300294 return this . optionsSelectedClass !== void 0
301295 ? this . optionsSelectedClass
302296 : ( this . color !== void 0 ? `text-${ this . color } ` : '' )
297+ } ,
298+
299+ __getOptionValue ( ) {
300+ return this . __getPropValueFn ( 'optionValue' , 'value' )
301+ } ,
302+
303+ __getOptionLabel ( ) {
304+ return this . __getPropValueFn ( 'optionLabel' , 'label' )
305+ } ,
306+
307+ __getOptionDisabled ( ) {
308+ return this . __getPropValueFn ( 'optionDisable' , 'disable' )
303309 }
304310 } ,
305311
@@ -354,7 +360,7 @@ export default Vue.extend({
354360 } ,
355361
356362 toggleOption ( opt , keepOpen ) {
357- if ( this . editable !== true || opt === void 0 || this . __isDisabled ( opt ) === true ) {
363+ if ( this . editable !== true || opt === void 0 || this . __getOptionDisabled ( opt ) === true ) {
358364 return
359365 }
360366
@@ -431,7 +437,7 @@ export default Vue.extend({
431437 this . virtualScrollLength - 1
432438 )
433439 }
434- while ( index !== - 1 && index !== this . optionIndex && this . __isDisabled ( this . options [ index ] ) === true )
440+ while ( index !== - 1 && index !== this . optionIndex && this . __getOptionDisabled ( this . options [ index ] ) === true )
435441
436442 if ( this . optionIndex !== index ) {
437443 this . setOptionIndex ( index )
@@ -452,38 +458,16 @@ export default Vue.extend({
452458 return this . options . find ( fn ) || innerValueCache . find ( fn ) || value
453459 } ,
454460
455- __getOptionValue ( opt ) {
456- if ( typeof this . optionValue === 'function' ) {
457- return this . optionValue ( opt )
458- }
459- if ( Object ( opt ) === opt && this . optionValueKey in opt ) {
460- return opt [ this . optionValueKey ]
461- }
462- return opt
463- } ,
464-
465- __getOptionLabel ( opt ) {
466- if ( typeof this . optionLabel === 'function' ) {
467- return this . optionLabel ( opt )
468- }
469- if ( Object ( opt ) === opt ) {
470- return typeof this . optionLabel === 'string'
471- ? opt [ this . optionLabel ]
472- : opt . label
473- }
474- return opt
475- } ,
461+ __getPropValueFn ( propName , defaultVal ) {
462+ const val = this [ propName ] !== void 0
463+ ? this [ propName ]
464+ : defaultVal
476465
477- __isDisabled ( opt ) {
478- if ( typeof this . optionDisable === 'function' ) {
479- return this . optionDisable ( opt ) === true
480- }
481- if ( Object ( opt ) === opt ) {
482- return typeof this . optionDisable === 'string'
483- ? opt [ this . optionDisable ] === true
484- : opt . disable === true
485- }
486- return false
466+ return typeof val === 'function'
467+ ? val
468+ : opt => Object ( opt ) === opt && val in opt
469+ ? opt [ val ]
470+ : opt
487471 } ,
488472
489473 __isSelected ( opt ) {
@@ -588,7 +572,7 @@ export default Vue.extend({
588572 index = normalizeToInterval ( index + 1 , - 1 , optionsLength - 1 )
589573 }
590574 while ( index !== this . optionIndex && (
591- this . __isDisabled ( this . options [ index ] ) === true ||
575+ this . __getOptionDisabled ( this . options [ index ] ) === true ||
592576 searchRe . test ( this . __getOptionLabel ( this . options [ index ] ) ) !== true
593577 ) )
594578 }
@@ -714,7 +698,7 @@ export default Vue.extend({
714698 return this . selectedScope . map ( ( scope , i ) => h ( QChip , {
715699 key : 'option-' + i ,
716700 props : {
717- removable : this . __isDisabled ( scope . opt ) !== true ,
701+ removable : this . __getOptionDisabled ( scope . opt ) !== true ,
718702 dense : true ,
719703 textColor : this . color ,
720704 tabindex : this . computedTabindex
@@ -767,23 +751,23 @@ export default Vue.extend({
767751 } ) )
768752 }
769753
770- if ( this . disable !== true && this . innerValue . length > 0 ) {
771- const options = this . innerValue
772- . filter ( value => Object ( value ) !== value )
773- . map ( value => h ( 'option' , {
774- domProps : {
775- value,
776- selected : true
777- }
778- } ) )
779-
780- child . push ( h ( 'select' , {
781- staticClass : 'hidden' ,
754+ if ( this . disable !== true && this . nameProp !== void 0 && this . innerValue . length > 0 ) {
755+ const opts = this . innerValue . map ( value => h ( 'option' , {
782756 attrs : {
783- name : this . targetUid ,
784- multiple : this . multiple
757+ value ,
758+ selected : true
785759 }
786- } , options ) )
760+ } ) )
761+
762+ child . push (
763+ h ( 'select' , {
764+ staticClass : 'hidden' ,
765+ attrs : {
766+ name : this . nameProp ,
767+ multiple : this . multiple
768+ }
769+ } , opts )
770+ )
787771 }
788772
789773 return h ( 'div' , { staticClass : 'q-field__native row items-center' , attrs : this . $attrs } , child )
0 commit comments