mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-11-27 08:40:35 +00:00
Minimize .length checks in JavaScript
This doesn't change anything but is just a code style question. I find it less confusing than a numeric comparison, to be honest. Change-Id: I6ef220e85e395fe4769103e20402e1e540946778
This commit is contained in:
parent
4396f4453f
commit
f3be60464e
|
@ -153,7 +153,7 @@ Object.assign( Api.prototype, {
|
|||
* @return {jQuery.jqXHR}
|
||||
*/
|
||||
fetchUserGenderData: function ( users ) {
|
||||
if ( users.length === 0 ) {
|
||||
if ( !users.length ) {
|
||||
return $.Deferred().resolve();
|
||||
}
|
||||
return $.ajax( {
|
||||
|
|
|
@ -154,7 +154,7 @@ Object.assign( RevisionListView.prototype, {
|
|||
$neighborRevisionWrapper = $revisionWrapper.next();
|
||||
}
|
||||
|
||||
if ( $neighborRevisionWrapper.length === 0 ) {
|
||||
if ( !$neighborRevisionWrapper.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -726,7 +726,7 @@ Object.assign( SliderView.prototype, {
|
|||
if ( this.getOlderPointerPos() !== 0 || this.getNewerPointerPos() !== 0 ) {
|
||||
return;
|
||||
}
|
||||
if ( $oldRevElement.length === 0 && $newRevElement.length === 0 ) {
|
||||
if ( !$oldRevElement.length && !$newRevElement.length ) {
|
||||
// Note: this is currently caught in init.js
|
||||
throw new Error( 'RS-revs-not-specified' );
|
||||
}
|
||||
|
@ -966,7 +966,7 @@ Object.assign( SliderView.prototype, {
|
|||
changeTags: this.slider.getRevisionList().getAvailableTags()
|
||||
} ).then( ( data ) => {
|
||||
const revs = data.revisions.slice( 1 );
|
||||
if ( revs.length === 0 ) {
|
||||
if ( !revs.length ) {
|
||||
self.noMoreNewerRevisions = true;
|
||||
return;
|
||||
}
|
||||
|
@ -1002,7 +1002,7 @@ Object.assign( SliderView.prototype, {
|
|||
changeTags: this.slider.getRevisionList().getAvailableTags()
|
||||
} ).then( ( data ) => {
|
||||
let revs = data.revisions.slice( 1 ).reverse();
|
||||
if ( revs.length === 0 ) {
|
||||
if ( !revs.length ) {
|
||||
self.noMoreOlderRevisions = true;
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue