Permalink
Browse files

Core: deprecate jQuery.isFunction

Fixes gh-3609
  • Loading branch information...
jbedard committed Dec 13, 2017
1 parent 6c38ebb commit 3d732cca6b5076a9d13eee98e2b075b37384cd91
View
@@ -1,6 +1,7 @@
define( [
"./core",
"./var/document",
"./var/isFunction",
"./var/rnothtmlwhite",
"./ajax/var/location",
"./ajax/var/nonce",
@@ -11,7 +12,7 @@ define( [
"./event/trigger",
"./deferred",
"./serialize" // jQuery.param
], function( jQuery, document, rnothtmlwhite, location, nonce, rquery ) {
], function( jQuery, document, isFunction, rnothtmlwhite, location, nonce, rquery ) {
"use strict";
@@ -66,7 +67,7 @@ function addToPrefiltersOrTransports( structure ) {
i = 0,
dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
if ( jQuery.isFunction( func ) ) {
if ( isFunction( func ) ) {
// For each dataType in the dataTypeExpression
while ( ( dataType = dataTypes[ i++ ] ) ) {
@@ -834,7 +835,7 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
jQuery[ method ] = function( url, data, callback, type ) {
// Shift arguments if data argument was omitted
if ( jQuery.isFunction( data ) ) {
if ( isFunction( data ) ) {
type = type || callback;
callback = data;
data = undefined;
View
@@ -1,9 +1,10 @@
define( [
"../core",
"../var/isFunction",
"./var/nonce",
"./var/rquery",
"../ajax"
], function( jQuery, nonce, rquery ) {
], function( jQuery, isFunction, nonce, rquery ) {
"use strict";
@@ -36,7 +37,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
// Get callback name, remembering preexisting value associated with it
callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
s.jsonpCallback() :
s.jsonpCallback;
@@ -87,7 +88,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
}
// Call if it was a function and we have a response
if ( responseContainer && jQuery.isFunction( overwritten ) ) {
if ( responseContainer && isFunction( overwritten ) ) {
overwritten( responseContainer[ 0 ] );
}
View
@@ -1,12 +1,13 @@
define( [
"../core",
"../core/stripAndCollapse",
"../var/isFunction",
"../core/parseHTML",
"../ajax",
"../traversing",
"../manipulation",
"../selector"
], function( jQuery, stripAndCollapse ) {
], function( jQuery, stripAndCollapse, isFunction ) {
"use strict";
@@ -24,7 +25,7 @@ jQuery.fn.load = function( url, params, callback ) {
}
// If it's a function
if ( jQuery.isFunction( params ) ) {
if ( isFunction( params ) ) {
// We assume that it's the callback
callback = params;
@@ -1,10 +1,11 @@
define( [
"../core",
"../core/stripAndCollapse",
"../var/isFunction",
"../var/rnothtmlwhite",
"../data/var/dataPriv",
"../core/init"
], function( jQuery, stripAndCollapse, rnothtmlwhite, dataPriv ) {
], function( jQuery, stripAndCollapse, isFunction, rnothtmlwhite, dataPriv ) {
"use strict";
@@ -27,7 +28,7 @@ jQuery.fn.extend( {
var classes, elem, cur, curValue, clazz, j, finalValue,
i = 0;
if ( jQuery.isFunction( value ) ) {
if ( isFunction( value ) ) {
return this.each( function( j ) {
jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
} );
@@ -64,7 +65,7 @@ jQuery.fn.extend( {
var classes, elem, cur, curValue, clazz, j, finalValue,
i = 0;
if ( jQuery.isFunction( value ) ) {
if ( isFunction( value ) ) {
return this.each( function( j ) {
jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
} );
@@ -113,7 +114,7 @@ jQuery.fn.extend( {
return stateVal ? this.addClass( value ) : this.removeClass( value );
}
if ( jQuery.isFunction( value ) ) {
if ( isFunction( value ) ) {
return this.each( function( i ) {
jQuery( this ).toggleClass(
value.call( this, i, getClass( this ), stateVal ),
View
@@ -3,17 +3,18 @@ define( [
"../core/stripAndCollapse",
"./support",
"../core/nodeName",
"../var/isFunction",
"../core/init"
], function( jQuery, stripAndCollapse, support, nodeName ) {
], function( jQuery, stripAndCollapse, support, nodeName, isFunction ) {
"use strict";
var rreturn = /\r/g;
jQuery.fn.extend( {
val: function( value ) {
var hooks, ret, isFunction,
var hooks, ret, valueIsFunction,
elem = this[ 0 ];
if ( !arguments.length ) {
@@ -42,7 +43,7 @@ jQuery.fn.extend( {
return;
}
isFunction = jQuery.isFunction( value );
valueIsFunction = isFunction( value );
return this.each( function( i ) {
var val;
@@ -51,7 +52,7 @@ jQuery.fn.extend( {
return;
}
if ( isFunction ) {
if ( valueIsFunction ) {
val = value.call( this, i, jQuery( this ).val() );
} else {
val = value;
View
@@ -1,7 +1,8 @@
define( [
"./core",
"./var/isFunction",
"./var/rnothtmlwhite"
], function( jQuery, rnothtmlwhite ) {
], function( jQuery, isFunction, rnothtmlwhite ) {
"use strict";
@@ -125,7 +126,7 @@ jQuery.Callbacks = function( options ) {
( function add( args ) {
jQuery.each( args, function( _, arg ) {
if ( jQuery.isFunction( arg ) ) {
if ( isFunction( arg ) ) {
if ( !options.unique || !self.has( arg ) ) {
list.push( arg );
}
View
@@ -16,11 +16,12 @@ define( [
"./var/fnToString",
"./var/ObjectFunctionString",
"./var/support",
"./var/isFunction",
"./var/isWindow",
"./core/DOMEval"
], function( arr, document, getProto, slice, concat, push, indexOf,
class2type, toString, hasOwn, fnToString, ObjectFunctionString,
support, isWindow, DOMEval ) {
support, isFunction, isWindow, DOMEval ) {
"use strict";
@@ -137,7 +138,7 @@ jQuery.extend = jQuery.fn.extend = function() {
}
// Handle case when target is a string or something (possible in deep copy)
if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
if ( typeof target !== "object" && !isFunction( target ) ) {
target = {};
}
@@ -203,15 +204,6 @@ jQuery.extend( {
noop: function() {},
isFunction: function( obj ) {
// Support: Chrome <=57, Firefox <=52
// In some browsers, typeof returns "function" for HTML <object> elements
// (i.e., `typeof document.createElement( "object" ) === "function"`).
// We don't want to classify *any* DOM node as a function.
return typeof obj === "function" && typeof obj.nodeType !== "number";
},
isNumeric: function( obj ) {
// As of jQuery 3.0, isNumeric is limited to
@@ -419,7 +411,7 @@ function isArrayLike( obj ) {
var length = !!obj && "length" in obj && obj.length,
type = jQuery.type( obj );
if ( jQuery.isFunction( obj ) || isWindow( obj ) ) {
if ( isFunction( obj ) || isWindow( obj ) ) {
return false;
}
View
@@ -1,6 +1,7 @@
define( [
"../core"
], function( jQuery ) {
"../core",
"../var/isFunction"
], function( jQuery, isFunction ) {
"use strict";
@@ -22,7 +23,7 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
} else if ( value !== undefined ) {
chainable = true;
if ( !jQuery.isFunction( value ) ) {
if ( !isFunction( value ) ) {
raw = true;
}
View
@@ -2,10 +2,11 @@
define( [
"../core",
"../var/document",
"../var/isFunction",
"./var/rsingleTag",
"../traversing/findFilter"
], function( jQuery, document, rsingleTag ) {
], function( jQuery, document, isFunction, rsingleTag ) {
"use strict";
@@ -63,7 +64,7 @@ var rootjQuery,
for ( match in context ) {
// Properties of context are called as methods if possible
if ( jQuery.isFunction( this[ match ] ) ) {
if ( isFunction( this[ match ] ) ) {
this[ match ]( context[ match ] );
// ...and otherwise set as attributes
@@ -106,7 +107,7 @@ var rootjQuery,
// HANDLE: $(function)
// Shortcut for document ready
} else if ( jQuery.isFunction( selector ) ) {
} else if ( isFunction( selector ) ) {
return root.ready !== undefined ?
root.ready( selector ) :
@@ -1,7 +1,8 @@
define( [
"../core",
"../var/document"
], function( jQuery, document ) {
"../var/document",
"../var/isFunction"
], function( jQuery, document, isFunction ) {
"use strict";
@@ -52,7 +53,7 @@ jQuery.extend( {
while ( readyCallbacks.length ) {
fn = readyCallbacks.shift();
if ( jQuery.isFunction( fn ) ) {
if ( isFunction( fn ) ) {
executeReady( fn );
}
}
View
@@ -1,8 +1,9 @@
define( [
"./core",
"./var/isFunction",
"./var/slice",
"./callbacks"
], function( jQuery, slice ) {
], function( jQuery, isFunction, slice ) {
"use strict";
@@ -19,11 +20,11 @@ function adoptValue( value, resolve, reject, noValue ) {
try {
// Check for promise aspect first to privilege synchronous behavior
if ( value && jQuery.isFunction( ( method = value.promise ) ) ) {
if ( value && isFunction( ( method = value.promise ) ) ) {
method.call( value ).done( resolve ).fail( reject );
// Other thenables
} else if ( value && jQuery.isFunction( ( method = value.then ) ) ) {
} else if ( value && isFunction( ( method = value.then ) ) ) {
method.call( value, resolve, reject );
// Other non-thenables
@@ -81,14 +82,14 @@ jQuery.extend( {
jQuery.each( tuples, function( i, tuple ) {
// Map tuples (progress, done, fail) to arguments (done, fail, progress)
var fn = jQuery.isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
// deferred.progress(function() { bind to newDefer or newDefer.notify })
// deferred.done(function() { bind to newDefer or newDefer.resolve })
// deferred.fail(function() { bind to newDefer or newDefer.reject })
deferred[ tuple[ 1 ] ]( function() {
var returned = fn && fn.apply( this, arguments );
if ( returned && jQuery.isFunction( returned.promise ) ) {
if ( returned && isFunction( returned.promise ) ) {
returned.promise()
.progress( newDefer.notify )
.done( newDefer.resolve )
@@ -142,7 +143,7 @@ jQuery.extend( {
returned.then;
// Handle a returned thenable
if ( jQuery.isFunction( then ) ) {
if ( isFunction( then ) ) {
// Special processors (notify) just wait for resolution
if ( special ) {
@@ -238,7 +239,7 @@ jQuery.extend( {
resolve(
0,
newDefer,
jQuery.isFunction( onProgress ) ?
isFunction( onProgress ) ?
onProgress :
Identity,
newDefer.notifyWith
@@ -250,7 +251,7 @@ jQuery.extend( {
resolve(
0,
newDefer,
jQuery.isFunction( onFulfilled ) ?
isFunction( onFulfilled ) ?
onFulfilled :
Identity
)
@@ -261,7 +262,7 @@ jQuery.extend( {
resolve(
0,
newDefer,
jQuery.isFunction( onRejected ) ?
isFunction( onRejected ) ?
onRejected :
Thrower
)
@@ -379,7 +380,7 @@ jQuery.extend( {
// Use .then() to unwrap secondary thenables (cf. gh-3000)
if ( master.state() === "pending" ||
jQuery.isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
return master.then();
}
Oops, something went wrong.

0 comments on commit 3d732cc

Please sign in to comment.