From 3b8aa08d17f828fff406d10181899a2f6d1546f6 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Sat, 24 Jun 2017 01:23:49 +0100 Subject: [PATCH] mediawiki.Title: Remove needless $.type() and minor clean up * Use typeof instead of $.type() for primitives. * Remove needless type check before instanceof. * Use early-return pattern. Change-Id: Ibfdbc3912961fd017cefb7115951f07b92f6d435 --- resources/src/mediawiki/mediawiki.Title.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/resources/src/mediawiki/mediawiki.Title.js b/resources/src/mediawiki/mediawiki.Title.js index 6765270a2b..253e0efe1d 100644 --- a/resources/src/mediawiki/mediawiki.Title.js +++ b/resources/src/mediawiki/mediawiki.Title.js @@ -699,22 +699,21 @@ */ Title.exists = function ( title ) { var match, - type = $.type( title ), obj = Title.exist.pages; - if ( type === 'string' ) { + if ( typeof title === 'string' ) { match = obj[ title ]; - } else if ( type === 'object' && title instanceof Title ) { + } else if ( title instanceof Title ) { match = obj[ title.toString() ]; } else { throw new Error( 'mw.Title.exists: title must be a string or an instance of Title' ); } - if ( typeof match === 'boolean' ) { - return match; + if ( typeof match !== 'boolean' ) { + return null; } - return null; + return match; }; /** -- 2.20.1