mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-11-23 23:13:29 +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}
|
* @return {jQuery.jqXHR}
|
||||||
*/
|
*/
|
||||||
fetchUserGenderData: function ( users ) {
|
fetchUserGenderData: function ( users ) {
|
||||||
if ( users.length === 0 ) {
|
if ( !users.length ) {
|
||||||
return $.Deferred().resolve();
|
return $.Deferred().resolve();
|
||||||
}
|
}
|
||||||
return $.ajax( {
|
return $.ajax( {
|
||||||
|
|
|
@ -154,7 +154,7 @@ Object.assign( RevisionListView.prototype, {
|
||||||
$neighborRevisionWrapper = $revisionWrapper.next();
|
$neighborRevisionWrapper = $revisionWrapper.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $neighborRevisionWrapper.length === 0 ) {
|
if ( !$neighborRevisionWrapper.length ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -726,7 +726,7 @@ Object.assign( SliderView.prototype, {
|
||||||
if ( this.getOlderPointerPos() !== 0 || this.getNewerPointerPos() !== 0 ) {
|
if ( this.getOlderPointerPos() !== 0 || this.getNewerPointerPos() !== 0 ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( $oldRevElement.length === 0 && $newRevElement.length === 0 ) {
|
if ( !$oldRevElement.length && !$newRevElement.length ) {
|
||||||
// Note: this is currently caught in init.js
|
// Note: this is currently caught in init.js
|
||||||
throw new Error( 'RS-revs-not-specified' );
|
throw new Error( 'RS-revs-not-specified' );
|
||||||
}
|
}
|
||||||
|
@ -966,7 +966,7 @@ Object.assign( SliderView.prototype, {
|
||||||
changeTags: this.slider.getRevisionList().getAvailableTags()
|
changeTags: this.slider.getRevisionList().getAvailableTags()
|
||||||
} ).then( ( data ) => {
|
} ).then( ( data ) => {
|
||||||
const revs = data.revisions.slice( 1 );
|
const revs = data.revisions.slice( 1 );
|
||||||
if ( revs.length === 0 ) {
|
if ( !revs.length ) {
|
||||||
self.noMoreNewerRevisions = true;
|
self.noMoreNewerRevisions = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1002,7 +1002,7 @@ Object.assign( SliderView.prototype, {
|
||||||
changeTags: this.slider.getRevisionList().getAvailableTags()
|
changeTags: this.slider.getRevisionList().getAvailableTags()
|
||||||
} ).then( ( data ) => {
|
} ).then( ( data ) => {
|
||||||
let revs = data.revisions.slice( 1 ).reverse();
|
let revs = data.revisions.slice( 1 ).reverse();
|
||||||
if ( revs.length === 0 ) {
|
if ( !revs.length ) {
|
||||||
self.noMoreOlderRevisions = true;
|
self.noMoreOlderRevisions = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue