jquery.uls.lcd: Handle scenario where selected item is undetermined
Throw an error if during keyboard navigation the selected item could not be determined. Bug: https://phabricator.wikimedia.org/T328956
This commit is contained in:
@@ -155,6 +155,13 @@
|
||||
$listItems.removeClass( 'uls-language-option--highlighted' );
|
||||
|
||||
var $selectedItem = $listItems.eq( this.navigationIndex );
|
||||
if ( $selectedItem.length === 0 ) {
|
||||
throw new Error(
|
||||
'Could not identify selected item with index: ' + this.navigationIndex + '; ' +
|
||||
'Total items in ULS: ' + $listItems.length
|
||||
);
|
||||
}
|
||||
|
||||
$selectedItem.addClass( 'uls-language-option--highlighted' );
|
||||
|
||||
// If the selected item is not visible, then scroll the container to display it
|
||||
|
||||
Reference in New Issue
Block a user