🌐 AI搜索 & 代理 主页
Skip to content

Commit 32e3301

Browse files
committed
Core: deprecate jQuery.isFunction
Fixes gh-3609
1 parent 50b94f4 commit 32e3301

29 files changed

+268
-237
lines changed

src/ajax.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
define( [
22
"./core",
33
"./var/document",
4+
"./var/isFunction",
45
"./var/rnothtmlwhite",
56
"./ajax/var/location",
67
"./ajax/var/nonce",
@@ -11,7 +12,7 @@ define( [
1112
"./event/trigger",
1213
"./deferred",
1314
"./serialize" // jQuery.param
14-
], function( jQuery, document, rnothtmlwhite, location, nonce, rquery ) {
15+
], function( jQuery, document, isFunction, rnothtmlwhite, location, nonce, rquery ) {
1516

1617
"use strict";
1718

@@ -66,7 +67,7 @@ function addToPrefiltersOrTransports( structure ) {
6667
i = 0,
6768
dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
6869

69-
if ( jQuery.isFunction( func ) ) {
70+
if ( isFunction( func ) ) {
7071

7172
// For each dataType in the dataTypeExpression
7273
while ( ( dataType = dataTypes[ i++ ] ) ) {
@@ -834,7 +835,7 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
834835
jQuery[ method ] = function( url, data, callback, type ) {
835836

836837
// Shift arguments if data argument was omitted
837-
if ( jQuery.isFunction( data ) ) {
838+
if ( isFunction( data ) ) {
838839
type = type || callback;
839840
callback = data;
840841
data = undefined;

src/ajax/jsonp.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
define( [
22
"../core",
3+
"../var/isFunction",
34
"./var/nonce",
45
"./var/rquery",
56
"../ajax"
6-
], function( jQuery, nonce, rquery ) {
7+
], function( jQuery, isFunction, nonce, rquery ) {
78

89
"use strict";
910

@@ -36,7 +37,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
3637
if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
3738

3839
// Get callback name, remembering preexisting value associated with it
39-
callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
40+
callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
4041
s.jsonpCallback() :
4142
s.jsonpCallback;
4243

@@ -87,7 +88,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
8788
}
8889

8990
// Call if it was a function and we have a response
90-
if ( responseContainer && jQuery.isFunction( overwritten ) ) {
91+
if ( responseContainer && isFunction( overwritten ) ) {
9192
overwritten( responseContainer[ 0 ] );
9293
}
9394

src/ajax/load.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
define( [
22
"../core",
33
"../core/stripAndCollapse",
4+
"../var/isFunction",
45
"../core/parseHTML",
56
"../ajax",
67
"../traversing",
78
"../manipulation",
89
"../selector"
9-
], function( jQuery, stripAndCollapse ) {
10+
], function( jQuery, stripAndCollapse, isFunction ) {
1011

1112
"use strict";
1213

@@ -24,7 +25,7 @@ jQuery.fn.load = function( url, params, callback ) {
2425
}
2526

2627
// If it's a function
27-
if ( jQuery.isFunction( params ) ) {
28+
if ( isFunction( params ) ) {
2829

2930
// We assume that it's the callback
3031
callback = params;

src/attributes/classes.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
define( [
22
"../core",
33
"../core/stripAndCollapse",
4+
"../var/isFunction",
45
"../var/rnothtmlwhite",
56
"../data/var/dataPriv",
67
"../core/init"
7-
], function( jQuery, stripAndCollapse, rnothtmlwhite, dataPriv ) {
8+
], function( jQuery, stripAndCollapse, isFunction, rnothtmlwhite, dataPriv ) {
89

910
"use strict";
1011

@@ -27,7 +28,7 @@ jQuery.fn.extend( {
2728
var classes, elem, cur, curValue, clazz, j, finalValue,
2829
i = 0;
2930

30-
if ( jQuery.isFunction( value ) ) {
31+
if ( isFunction( value ) ) {
3132
return this.each( function( j ) {
3233
jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
3334
} );
@@ -64,7 +65,7 @@ jQuery.fn.extend( {
6465
var classes, elem, cur, curValue, clazz, j, finalValue,
6566
i = 0;
6667

67-
if ( jQuery.isFunction( value ) ) {
68+
if ( isFunction( value ) ) {
6869
return this.each( function( j ) {
6970
jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
7071
} );
@@ -113,7 +114,7 @@ jQuery.fn.extend( {
113114
return stateVal ? this.addClass( value ) : this.removeClass( value );
114115
}
115116

116-
if ( jQuery.isFunction( value ) ) {
117+
if ( isFunction( value ) ) {
117118
return this.each( function( i ) {
118119
jQuery( this ).toggleClass(
119120
value.call( this, i, getClass( this ), stateVal ),

src/attributes/val.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ define( [
33
"../core/stripAndCollapse",
44
"./support",
55
"../core/nodeName",
6+
"../var/isFunction",
67

78
"../core/init"
8-
], function( jQuery, stripAndCollapse, support, nodeName ) {
9+
], function( jQuery, stripAndCollapse, support, nodeName, isFunction ) {
910

1011
"use strict";
1112

1213
var rreturn = /\r/g;
1314

1415
jQuery.fn.extend( {
1516
val: function( value ) {
16-
var hooks, ret, isFunction,
17+
var hooks, ret, valueIsFunction,
1718
elem = this[ 0 ];
1819

1920
if ( !arguments.length ) {
@@ -42,7 +43,7 @@ jQuery.fn.extend( {
4243
return;
4344
}
4445

45-
isFunction = jQuery.isFunction( value );
46+
valueIsFunction = isFunction( value );
4647

4748
return this.each( function( i ) {
4849
var val;
@@ -51,7 +52,7 @@ jQuery.fn.extend( {
5152
return;
5253
}
5354

54-
if ( isFunction ) {
55+
if ( valueIsFunction ) {
5556
val = value.call( this, i, jQuery( this ).val() );
5657
} else {
5758
val = value;

src/callbacks.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
define( [
22
"./core",
3+
"./var/isFunction",
34
"./var/rnothtmlwhite"
4-
], function( jQuery, rnothtmlwhite ) {
5+
], function( jQuery, isFunction, rnothtmlwhite ) {
56

67
"use strict";
78

@@ -125,7 +126,7 @@ jQuery.Callbacks = function( options ) {
125126

126127
( function add( args ) {
127128
jQuery.each( args, function( _, arg ) {
128-
if ( jQuery.isFunction( arg ) ) {
129+
if ( isFunction( arg ) ) {
129130
if ( !options.unique || !self.has( arg ) ) {
130131
list.push( arg );
131132
}

src/core.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ define( [
1616
"./var/fnToString",
1717
"./var/ObjectFunctionString",
1818
"./var/support",
19+
"./var/isFunction",
1920
"./var/isWindow",
2021
"./core/DOMEval"
2122
], function( arr, document, getProto, slice, concat, push, indexOf,
2223
class2type, toString, hasOwn, fnToString, ObjectFunctionString,
23-
support, isWindow, DOMEval ) {
24+
support, isFunction, isWindow, DOMEval ) {
2425

2526
"use strict";
2627

@@ -137,7 +138,7 @@ jQuery.extend = jQuery.fn.extend = function() {
137138
}
138139

139140
// Handle case when target is a string or something (possible in deep copy)
140-
if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
141+
if ( typeof target !== "object" && !isFunction( target ) ) {
141142
target = {};
142143
}
143144

@@ -203,15 +204,6 @@ jQuery.extend( {
203204

204205
noop: function() {},
205206

206-
isFunction: function( obj ) {
207-
208-
// Support: Chrome <=57, Firefox <=52
209-
// In some browsers, typeof returns "function" for HTML <object> elements
210-
// (i.e., `typeof document.createElement( "object" ) === "function"`).
211-
// We don't want to classify *any* DOM node as a function.
212-
return typeof obj === "function" && typeof obj.nodeType !== "number";
213-
},
214-
215207
isNumeric: function( obj ) {
216208

217209
// As of jQuery 3.0, isNumeric is limited to
@@ -419,7 +411,7 @@ function isArrayLike( obj ) {
419411
var length = !!obj && "length" in obj && obj.length,
420412
type = jQuery.type( obj );
421413

422-
if ( jQuery.isFunction( obj ) || isWindow( obj ) ) {
414+
if ( isFunction( obj ) || isWindow( obj ) ) {
423415
return false;
424416
}
425417

src/core/access.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
define( [
2-
"../core"
3-
], function( jQuery ) {
2+
"../core",
3+
"../var/isFunction"
4+
], function( jQuery, isFunction ) {
45

56
"use strict";
67

@@ -22,7 +23,7 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
2223
} else if ( value !== undefined ) {
2324
chainable = true;
2425

25-
if ( !jQuery.isFunction( value ) ) {
26+
if ( !isFunction( value ) ) {
2627
raw = true;
2728
}
2829

src/core/init.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
define( [
33
"../core",
44
"../var/document",
5+
"../var/isFunction",
56
"./var/rsingleTag",
67

78
"../traversing/findFilter"
8-
], function( jQuery, document, rsingleTag ) {
9+
], function( jQuery, document, isFunction, rsingleTag ) {
910

1011
"use strict";
1112

@@ -63,7 +64,7 @@ var rootjQuery,
6364
for ( match in context ) {
6465

6566
// Properties of context are called as methods if possible
66-
if ( jQuery.isFunction( this[ match ] ) ) {
67+
if ( isFunction( this[ match ] ) ) {
6768
this[ match ]( context[ match ] );
6869

6970
// ...and otherwise set as attributes
@@ -106,7 +107,7 @@ var rootjQuery,
106107

107108
// HANDLE: $(function)
108109
// Shortcut for document ready
109-
} else if ( jQuery.isFunction( selector ) ) {
110+
} else if ( isFunction( selector ) ) {
110111
return root.ready !== undefined ?
111112
root.ready( selector ) :
112113

src/core/ready-no-deferred.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
define( [
22
"../core",
3-
"../var/document"
4-
], function( jQuery, document ) {
3+
"../var/document",
4+
"../var/isFunction"
5+
], function( jQuery, document, isFunction ) {
56

67
"use strict";
78

@@ -52,7 +53,7 @@ jQuery.extend( {
5253

5354
while ( readyCallbacks.length ) {
5455
fn = readyCallbacks.shift();
55-
if ( jQuery.isFunction( fn ) ) {
56+
if ( isFunction( fn ) ) {
5657
executeReady( fn );
5758
}
5859
}

0 commit comments

Comments
 (0)