jenkins-bot has submitted this change and it was merged. Change subject: Prefer ES5 over jQuery methods ......................................................................
Prefer ES5 over jQuery methods * Prefer Array#indexOf over $.inArray. The latter is confusingly named, it returns the index too, not a boolean. * Prefer Function#bind over $.proxy. Change-Id: I0b4010e09b972efa5134cc873ddb7fcaa6513b9c --- M src/core.js M src/layouts/BookletLayout.js M src/layouts/IndexLayout.js M src/layouts/StackLayout.js M src/mixins/DraggableGroupElement.js M src/mixins/GroupElement.js M src/widgets/SelectFileWidget.js M src/widgets/SelectWidget.js 8 files changed, 13 insertions(+), 13 deletions(-) Approvals: Esanders: Looks good to me, approved jenkins-bot: Verified diff --git a/src/core.js b/src/core.js index d84c75b..988480e 100644 --- a/src/core.js +++ b/src/core.js @@ -364,7 +364,7 @@ } // Safe if in the whitelist - return $.inArray( protocol, whitelist ) !== -1; + return whitelist.indexOf( protocol ) !== -1; }; } )(); diff --git a/src/layouts/BookletLayout.js b/src/layouts/BookletLayout.js index 91903b3..7ab43cb 100644 --- a/src/layouts/BookletLayout.js +++ b/src/layouts/BookletLayout.js @@ -297,7 +297,7 @@ OO.ui.BookletLayout.prototype.getClosestPage = function ( page ) { var next, prev, level, pages = this.stackLayout.getItems(), - index = $.inArray( page, pages ); + index = pages.indexOf( page ); if ( index !== -1 ) { next = pages[ index + 1 ]; @@ -397,7 +397,7 @@ if ( Object.prototype.hasOwnProperty.call( this.pages, name ) ) { // Correct the insertion index - currentIndex = $.inArray( this.pages[ name ], stackLayoutPages ); + currentIndex = stackLayoutPages.indexOf( this.pages[ name ] ); if ( currentIndex !== -1 && currentIndex + 1 < index ) { index--; } diff --git a/src/layouts/IndexLayout.js b/src/layouts/IndexLayout.js index 4d48de5..340b5c2 100644 --- a/src/layouts/IndexLayout.js +++ b/src/layouts/IndexLayout.js @@ -230,7 +230,7 @@ OO.ui.IndexLayout.prototype.getClosestCard = function ( card ) { var next, prev, level, cards = this.stackLayout.getItems(), - index = $.inArray( card, cards ); + index = cards.indexOf( card ); if ( index !== -1 ) { next = cards[ index + 1 ]; @@ -315,7 +315,7 @@ if ( Object.prototype.hasOwnProperty.call( this.cards, name ) ) { // Correct the insertion index - currentIndex = $.inArray( this.cards[ name ], stackLayoutCards ); + currentIndex = stackLayoutCards.indexOf( this.cards[ name ] ); if ( currentIndex !== -1 && currentIndex + 1 < index ) { index--; } diff --git a/src/layouts/StackLayout.js b/src/layouts/StackLayout.js index 3b5de3b..7b851e0 100644 --- a/src/layouts/StackLayout.js +++ b/src/layouts/StackLayout.js @@ -137,7 +137,7 @@ // Mixin method OO.ui.mixin.GroupElement.prototype.removeItems.call( this, items ); - if ( $.inArray( this.currentItem, items ) !== -1 ) { + if ( items.indexOf( this.currentItem ) !== -1 ) { if ( this.items.length ) { this.setItem( this.items[ 0 ] ); } else { @@ -177,7 +177,7 @@ if ( item !== this.currentItem ) { this.updateHiddenState( this.items, item ); - if ( $.inArray( item, this.items ) !== -1 ) { + if ( this.items.indexOf( item ) !== -1 ) { this.currentItem = item; this.emit( 'set', item ); } else { diff --git a/src/mixins/DraggableGroupElement.js b/src/mixins/DraggableGroupElement.js index dc5cd4b..8d63c10 100644 --- a/src/mixins/DraggableGroupElement.js +++ b/src/mixins/DraggableGroupElement.js @@ -40,8 +40,8 @@ itemDragEnd: 'onItemDragEnd' } ); this.$element.on( { - dragover: $.proxy( this.onDragOver, this ), - dragleave: $.proxy( this.onDragLeave, this ) + dragover: this.onDragOver.bind( this ), + dragleave: this.onDragLeave.bind( this ) } ); // Initialize diff --git a/src/mixins/GroupElement.js b/src/mixins/GroupElement.js index 90a5802..5bd052f 100644 --- a/src/mixins/GroupElement.js +++ b/src/mixins/GroupElement.js @@ -187,7 +187,7 @@ item = items[ i ]; // Check if item exists then remove it first, effectively "moving" it - currentIndex = $.inArray( item, this.items ); + currentIndex = this.items.indexOf( item ); if ( currentIndex >= 0 ) { this.removeItems( [ item ] ); // Adjust index to compensate for removal @@ -236,7 +236,7 @@ // Remove specific items for ( i = 0, len = items.length; i < len; i++ ) { item = items[ i ]; - index = $.inArray( item, this.items ); + index = this.items.indexOf( item ); if ( index !== -1 ) { if ( item.connect && item.disconnect && diff --git a/src/widgets/SelectFileWidget.js b/src/widgets/SelectFileWidget.js index 2a9a9ee..ac8945b 100644 --- a/src/widgets/SelectFileWidget.js +++ b/src/widgets/SelectFileWidget.js @@ -330,7 +330,7 @@ if ( !this.isFileAcceptable( file ) ) { file = null; } - } else if ( dt && dt.types && $.inArray( 'Files', dt.types ) !== -1 ) { + } else if ( dt && dt.types && dt.types.indexOf( 'Files' ) !== -1 ) { // We know we have files so set 'file' to something truthy, we just // can't know any details about them. // * https://bugzilla.mozilla.org/show_bug.cgi?id=640534 diff --git a/src/widgets/SelectWidget.js b/src/widgets/SelectWidget.js index 3cb8fc8..4840ba8 100644 --- a/src/widgets/SelectWidget.js +++ b/src/widgets/SelectWidget.js @@ -727,7 +727,7 @@ } if ( item instanceof OO.ui.OptionWidget ) { - currentIndex = $.inArray( item, this.items ); + currentIndex = this.items.indexOf( item ); nextIndex = ( currentIndex + increase + len ) % len; } else { // If no item is selected and moving forward, start at the beginning. -- To view, visit https://gerrit.wikimedia.org/r/233442 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0b4010e09b972efa5134cc873ddb7fcaa6513b9c Gerrit-PatchSet: 1 Gerrit-Project: oojs/ui Gerrit-Branch: master Gerrit-Owner: Bartosz Dziewoński <matma....@gmail.com> Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com> Gerrit-Reviewer: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits