Deferred: behavior different from ECMAScript Promise for objects with [[Call]] #3596
Comments
Confirmed, but I would classify this as a bug in |
lodash says:
However, the standard requires the callbacks are functions (objects implementing |
It can be rather difficult to perfectly determine if an object has a [[Call]] internal method, and there are some tough edge cases (none of which we properly detect now):
The intent of |
I was not aware of these cases. By the way, I tested the second case.
A test suggests it is different from ECMAScript IsCallable. obj = document.createElement( "object" );
// Firefox says this is a function
assert.ok( !jQuery.isFunction( obj ), "Object Element" ); Line 442 in ac9e301 It is callable. We may need to clarify the expected behavior of |
Opened #3601. |
If we pursue a fix for #3600 (which I'd like to do), then the only requirement to resolve this issue will be new unit tests. |
Description
jQuery's
Deferred
is expected to be a close approximation toPromise
of ECMAScript 2016 Language Specification.Promise
defined in ECMAScript 2016 testsonFulfilled
, onRejected and then are objects with[[Call]]
.However,
isFunction
, used in theDeferred
, teststoStringTag
, which is irrelevant from the definition. As the result,Deferred
shows different behaviors for some objects such asGeneratorFunction
.Link to test case
https://jsbin.com/civabuxabe/1/edit?js,console
Expected
[object Generator] { ... }
, but results in0
.The text was updated successfully, but these errors were encountered: