fix: custom instOfHandler result should be cast to boolean (#10197)
This commit is contained in:
parent
4eab157502
commit
e88a569e83
@ -587,7 +587,7 @@ helpers.wrapNativeSuper = helper("7.0.0-beta.0")`
|
||||
helpers.instanceof = helper("7.0.0-beta.0")`
|
||||
export default function _instanceof(left, right) {
|
||||
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
||||
return right[Symbol.hasInstance](left);
|
||||
return !!right[Symbol.hasInstance](left);
|
||||
} else {
|
||||
return left instanceof right;
|
||||
}
|
||||
|
||||
@ -4,6 +4,11 @@ foo[Symbol.hasInstance]= function () { return true; };
|
||||
var bar = {};
|
||||
|
||||
expect(bar instanceof foo).toBe(true);
|
||||
|
||||
var qux = {};
|
||||
qux[Symbol.hasInstance]= function () { return NaN };
|
||||
expect(bar instanceof qux).toBe(false);
|
||||
|
||||
expect(new String).toBeInstanceOf(String);
|
||||
|
||||
//
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user