-
Notifications
You must be signed in to change notification settings - Fork 20.6k
-
Notifications
You must be signed in to change notification settings - Fork 20.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core: jQuery.isFunction returns false for Function objects with custom @@toStringTag #3600
Comments
@gibson042 From a quick check seems like patching As of 3.2, we already do this for most cases. We now only use If we remove Although we may need to find another way to support Android 2.3's RegExp values in that case. type: function( obj ) {
if ( obj == null ) {
return obj + "";
}
// Support: Android <=2.3 only (functionish RegExp)
return typeof obj === "object" || typeof obj === "function" ?
class2type[ toString.call( obj ) ] || "object" :
typeof obj;
},
isFunction: function( obj ) {
return jQuery.type( obj ) === "function";
}, |
We don't support Android 2.3 anymore, 4.0 is our minimum.
--
Michał Gołębiowski
|
That breaks for some cases such as obj = document.createElement( "object" );
// Firefox says this is a function
assert.ok( !jQuery.isFunction( obj ), "Object Element" ); Line 442 in ac9e301
On the other hand, the documentation says:
Though We need to make clear what we expect for |
I'd rather deprecate |
@gibson042 if all |
I'm fine with deprecating it, but unfortunately it's a little more than just |
Not just in Firefox, in Chrome it's What's funny is in Chrome it used be |
It's a DOM specific problem, so why not check if it is an element in the functions which deals with DOM? It is not reasonable to do that in |
I'm with @gibson042 that we should discourage the use of these utility functions and not set the expectation they'll be updated for bizarre usage. If someone passes a generator function to jQuery they're doing something mighty strange. DO NOT TAUNT HAPPY FUN JQUERY! |
If we plan to deprecate these methods, that means people will eventually need to migrate use to |
Closing this issue. |
Description
jQuery.isFunction
returns false for Function objects with custom@@toStringTag
. That is undesirable in some case such asGeneratorFunction
.This flaw was pointed out at #3597 (comment).
Link to test case
https://jsbin.com/xocanozuye/1/edit?html,js,console
The text was updated successfully, but these errors were encountered: