Make use of JavaScript "in" feature instead of "undefined"

Change-Id: I914f7281101bc4873eff3574c884253775e9b4bb
This commit is contained in:
Thiemo Kreuz 2018-08-02 09:35:37 +02:00
parent 91c157e0f4
commit 2d5b40c40b
3 changed files with 11 additions and 11 deletions

View file

@ -63,7 +63,7 @@
}
revs.forEach( function ( rev ) {
if ( typeof rev.user !== 'undefined' && typeof genderData[ rev.user ] !== 'undefined' ) {
if ( 'user' in rev && rev.user in genderData ) {
rev.userGender = genderData[ rev.user ];
}
} );
@ -99,7 +99,7 @@
var dir, data;
options = options || {};
dir = options.dir !== undefined ? options.dir : 'older';
dir = 'dir' in options ? options.dir : 'older';
data = {
action: 'query',
prop: 'revisions',
@ -112,13 +112,13 @@
rvdir: dir
};
if ( options.startId !== undefined ) {
if ( 'startId' in options ) {
data.rvstartid = options.startId;
}
if ( options.endId !== undefined ) {
if ( 'endId' in options ) {
data.rvendid = options.endId;
}
if ( options.limit !== undefined && options.limit <= 500 ) {
if ( 'limit' in options && options.limit <= 500 ) {
data.rvlimit = options.limit;
}

View file

@ -11,15 +11,15 @@
this.minor = data.hasOwnProperty( 'minor' ) && ( data.minor || data.minor === '' );
// Comments and users can be suppressed thus we must check if they exist
if ( typeof data.comment !== 'undefined' ) {
if ( 'comment' in data ) {
this.comment = data.comment;
}
if ( typeof data.parsedcomment !== 'undefined' ) {
if ( 'parsedcomment' in data ) {
this.parsedComment = data.parsedcomment;
}
if ( typeof data.user !== 'undefined' ) {
if ( 'user' in data ) {
this.user = data.user;
if ( typeof data.userGender !== 'undefined' ) {
if ( 'userGender' in data ) {
this.userGender = data.userGender;
}
}

View file

@ -894,7 +894,7 @@
self.addRevisionsAtEnd( $slider, revs );
if ( data.continue === undefined ) {
if ( !( 'continue' in data ) ) {
self.noMoreNewerRevisions = true;
}
} );
@ -933,7 +933,7 @@
}
self.addRevisionsAtStart( $slider, revs, precedingRevisionSize );
if ( data.continue === undefined ) {
if ( !( 'continue' in data ) ) {
self.noMoreOlderRevisions = true;
}
} );