File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,5 +24,5 @@ module.exports = function isBoolean(value) {
2424 if ( value === null || typeof value !== 'object' ) {
2525 return false ;
2626 }
27- return hasToStringTag && Symbol . toStringTag in value ? tryBooleanObject ( value ) : $toString ( value ) === boolClass ;
27+ return hasToStringTag ? tryBooleanObject ( value ) : $toString ( value ) === boolClass ;
2828} ;
Original file line number Diff line number Diff line change 4747 "@ljharb/eslint-config" : " ^21.1.1" ,
4848 "@ljharb/tsconfig" : " ^0.2.3" ,
4949 "@types/core-js" : " ^2.5.8" ,
50+ "@types/object-inspect" : " ^1.13.0" ,
5051 "@types/tape" : " ^5.8.1" ,
5152 "auto-changelog" : " ^2.5.0" ,
5253 "core-js" : " ^3.40.0" ,
5657 "in-publish" : " ^2.0.1" ,
5758 "npmignore" : " ^0.3.1" ,
5859 "nyc" : " ^10.3.2" ,
60+ "object-inspect" : " ^1.13.4" ,
5961 "safe-publish-latest" : " ^2.0.0" ,
6062 "tape" : " ^5.9.0" ,
6163 "typescript" : " next"
Original file line number Diff line number Diff line change 11'use strict' ;
22
33var test = require ( 'tape' ) ;
4- var isBoolean = require ( '../' ) ;
54var hasToStringTag = require ( 'has-tostringtag/shams' ) ( ) ;
5+ var inspect = require ( 'object-inspect' ) ;
6+
7+ var isBoolean = require ( '../' ) ;
68
79test ( 'not Booleans' , function ( t ) {
810 t . test ( 'primitives' , function ( st ) {
@@ -48,3 +50,24 @@ test('Booleans', function (t) {
4850 t . ok ( isBoolean ( Object ( false ) ) , 'Object(false) is Boolean' ) ;
4951 t . end ( ) ;
5052} ) ;
53+
54+ test ( 'Proxy' , { skip : typeof Proxy !== 'function' || ! hasToStringTag } , function ( t ) {
55+ /** @type {Record<PropertyKey, unknown> } */
56+ var target = { } ;
57+ target [ Symbol . toStringTag ] = 'Boolean' ;
58+ var fake = new Proxy ( target , { has : function ( ) { return false ; } } ) ;
59+
60+ t . equal (
61+ isBoolean ( target ) ,
62+ false ,
63+ inspect ( target ) + ' is not a Boolean'
64+ ) ;
65+
66+ t . equal (
67+ isBoolean ( fake ) ,
68+ false ,
69+ inspect ( fake ) + ' is not a Boolean'
70+ ) ;
71+
72+ t . end ( ) ;
73+ } ) ;
You can’t perform that action at this time.
0 commit comments