mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Merge "Simplify partly redundant findFirstSelectedItem implementation"
This commit is contained in:
commit
a1bd30f35d
|
@ -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
|
||||||
|
|
|
@ -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;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue