createSpinner: function ( opts ) {
var $spinner;
- if ( opts !== undefined && $.type( opts ) !== 'object' ) {
+ if ( typeof opts === 'string' ) {
opts = {
id: opts
};
var namespace, m, id, ext, parts;
// defaultNamespace is optional; check whether options moves up
- if ( arguments.length < 3 && $.type( defaultNamespace ) === 'object' ) {
+ if ( arguments.length < 3 && typeof defaultNamespace === 'object' ) {
options = defaultNamespace;
defaultNamespace = undefined;
}
* @param {string} key
* @param {string|null} value Value of cookie. If `value` is `null` then this method will
* instead remove a cookie by name of `key`.
- * @param {Object|Date} [options] Options object, or expiry date
+ * @param {Object|Date|number} [options] Options object, or expiry date
* @param {Date|number|null} [options.expires] The expiry date of the cookie, or lifetime in seconds.
*
* If `options.expires` is null, then a session cookie is set.
};
// Options argument can also be a shortcut for the expiry
- // Expiry can be a Date or null
- if ( $.type( options ) !== 'object' ) {
+ // Expiry can be a Date, number or null
+ if ( !options || options instanceof Date || typeof options === 'number' ) {
// Also takes care of options = undefined, in which case we also don't need $.extend()
defaultOptions.expires = options;
options = defaultOptions;
xhr = $.getJSON( this.getAPIurl(), allParams )
.done( function ( data ) {
- if (
- $.type( data ) !== 'array' ||
- (
- $.type( data ) === 'array' &&
- data.length === 0
- )
- ) {
- deferred.resolve();
- } else {
+ if ( Array.isArray( data ) && data.length ) {
deferred.resolve( data );
+ } else {
+ deferred.resolve();
}
} );
return deferred.promise( { abort: xhr.abort } );
var i;
for ( i = 0; i < cases.valid.length; i++ ) {
assert.strictEqual(
- $.type( mw.Title.newFromText( cases.valid[ i ] ) ),
+ typeof mw.Title.newFromText( cases.valid[ i ] ),
'object',
cases.valid[ i ]
);
}
for ( i = 0; i < cases.invalid.length; i++ ) {
assert.strictEqual(
- $.type( mw.Title.newFromText( cases.invalid[ i ] ) ),
- 'null',
+ mw.Title.newFromText( cases.invalid[ i ] ),
+ null,
cases.invalid[ i ]
);
}