File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ var setExists = typeof Set !== 'undefined';
16
16
var weakMapExists = typeof WeakMap !== 'undefined' ;
17
17
var weakSetExists = typeof WeakSet !== 'undefined' ;
18
18
var dataViewExists = typeof DataView !== 'undefined' ;
19
- var symbolIteratorExists = symbolExists && Symbol . iterator ;
19
+ var symbolIteratorExists = symbolExists && typeof Symbol . iterator !== 'undefined' ;
20
+ var symbolToStringTagExists = symbolExists && typeof Symbol . toStringTag !== 'undefined' ;
20
21
var setEntriesExists = setExists && typeof Set . prototype . entries === 'function' ;
21
22
var mapEntriesExists = mapExists && typeof Map . prototype . entries === 'function' ;
22
23
var setIteratorPrototype = getPrototypeOfExists && setEntriesExists && Object . getPrototypeOf ( new Set ( ) . entries ( ) ) ;
@@ -195,7 +196,7 @@ module.exports = function typeDetect(obj) {
195
196
}
196
197
}
197
198
198
- if ( getPrototypeOfExists && ( symbolExists === false || typeof obj [ Symbol . toStringTag ] === 'undefined' ) ) {
199
+ if ( getPrototypeOfExists && ( symbolToStringTagExists === false || typeof obj [ Symbol . toStringTag ] === 'undefined' ) ) {
199
200
var objPrototype = Object . getPrototypeOf ( obj ) ;
200
201
/* ! Speed optimisation
201
202
* Pre:
Original file line number Diff line number Diff line change @@ -60,6 +60,17 @@ describe('Generic', function () {
60
60
assert ( type ( Object . create ( Object . prototype ) ) === 'object' ) ;
61
61
} ) ;
62
62
63
+ // See: https://github.com/chaijs/type-detect/pull/25
64
+ it ( 'object with .undefined property getter' , function ( ) {
65
+ var foo = { } ;
66
+ Object . defineProperty ( foo , 'undefined' , {
67
+ get : function ( ) {
68
+ throw Error ( 'Should never happen' ) ;
69
+ } ,
70
+ } ) ;
71
+ assert ( type ( foo ) === 'object' ) ;
72
+ } ) ;
73
+
63
74
it ( 'boolean' , function ( ) {
64
75
assert ( type ( true ) === 'boolean' ) ;
65
76
assert ( type ( false ) === 'boolean' ) ;
You can’t perform that action at this time.
0 commit comments