From f3be60464e7f847ec473a4f01b9d5b07e69a0a5a Mon Sep 17 00:00:00 2001 From: thiemowmde Date: Thu, 21 Nov 2024 09:50:19 +0100 Subject: [PATCH] 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 --- modules/ext.RevisionSlider.Api.js | 2 +- modules/ext.RevisionSlider.RevisionListView.js | 2 +- modules/ext.RevisionSlider.SliderView.js | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/ext.RevisionSlider.Api.js b/modules/ext.RevisionSlider.Api.js index 789090a8..d3946cd6 100644 --- a/modules/ext.RevisionSlider.Api.js +++ b/modules/ext.RevisionSlider.Api.js @@ -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( { diff --git a/modules/ext.RevisionSlider.RevisionListView.js b/modules/ext.RevisionSlider.RevisionListView.js index f5970f6c..245593b8 100644 --- a/modules/ext.RevisionSlider.RevisionListView.js +++ b/modules/ext.RevisionSlider.RevisionListView.js @@ -154,7 +154,7 @@ Object.assign( RevisionListView.prototype, { $neighborRevisionWrapper = $revisionWrapper.next(); } - if ( $neighborRevisionWrapper.length === 0 ) { + if ( !$neighborRevisionWrapper.length ) { return; } diff --git a/modules/ext.RevisionSlider.SliderView.js b/modules/ext.RevisionSlider.SliderView.js index 6e54dd9d..6f65703c 100644 --- a/modules/ext.RevisionSlider.SliderView.js +++ b/modules/ext.RevisionSlider.SliderView.js @@ -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; }