Merge "Simplify partly redundant findFirstSelectedItem implementation"

This commit is contained in:
jenkins-bot 2022-08-01 11:45:08 +00:00 committed by Gerrit Code Review
commit a1bd30f35d
2 changed files with 8 additions and 11 deletions

View file

@ -4,6 +4,10 @@
* *
* @class * @class
* @extends OO.ui.OptionWidget * @extends OO.ui.OptionWidget
* @mixins OO.ui.mixin.ButtonElement
* @mixins OO.ui.mixin.IconElement
* @mixins OO.ui.mixin.TabIndexedElement
* @mixins ve.ui.MWAriaDescribe
* *
* @constructor * @constructor
* @param {Object} config * @param {Object} config

View file

@ -8,6 +8,8 @@
* *
* @class * @class
* @extends OO.ui.SelectWidget * @extends OO.ui.SelectWidget
* @mixins OO.ui.mixin.TabIndexedElement
* @mixins ve.ui.MWAriaDescribe
* *
* @constructor * @constructor
* @param {Object} config * @param {Object} config
@ -92,17 +94,8 @@ ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.addItems = function (
* @return {ve.ui.MWTransclusionOutlineParameterWidget|null} * @return {ve.ui.MWTransclusionOutlineParameterWidget|null}
*/ */
ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.findFirstSelectedItem = function () { ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.findFirstSelectedItem = function () {
var firstSelected; var selected = this.findSelectedItems();
return Array.isArray( selected ) ? selected[ 0 ] || null : selected;
this.items.some( function ( item ) {
if ( !firstSelected && item.isSelected() ) {
firstSelected = item;
return true;
}
return false;
} );
return firstSelected;
}; };
/** /**