Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Core: jQuery.isFunction returns false for Function objects with custom @@toStringTag #3600
Comments
akihikodaki
changed the title from
Core: jQuery.isFunction returns false for objects inheriting Function objects.
to
Core: jQuery.isFunction returns false for Function objects with custom @@toStringTag
Apr 1, 2017
akihikodaki
referenced this issue
in jquery/api.jquery.com
Apr 1, 2017
Closed
jQuery.isFunction: ambiguous criteria #1034
|
@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
|
akihikodaki
commented
Apr 2, 2017
|
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 |
This was referenced Apr 2, 2017
|
I'd rather deprecate |
gibson042
added
the
Core
label
Apr 2, 2017
|
@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 |
akihikodaki
commented
Apr 3, 2017
•
|
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 |
akihikodaki
commented
Apr 4, 2017
Closing this issue. |
akihikodaki commentedApr 1, 2017
•
Edited 1 time
-
akihikodaki
Apr 1, 2017
Description
jQuery.isFunctionreturns 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