File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,10 @@ module.exports = function typeDetect(obj) {
92
92
* Post:
93
93
* array literal x 22,479,650 ops/sec ±0.96% (81 runs sampled)
94
94
*/
95
- if ( Array . isArray ( obj ) ) {
95
+ if (
96
+ Array . isArray ( obj ) &&
97
+ ( symbolToStringTagExists === false || typeof obj [ Symbol . toStringTag ] === 'undefined' )
98
+ ) {
96
99
return 'Array' ;
97
100
}
98
101
Original file line number Diff line number Diff line change @@ -259,7 +259,6 @@ describe('Generic', function () {
259
259
Object . prototype . toString = originalObjectToString ; // eslint-disable-line no-extend-native
260
260
} ) ;
261
261
262
-
263
262
it ( 'plain object' , function ( ) {
264
263
var obj = { } ;
265
264
obj [ Symbol . toStringTag ] = function ( ) {
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ var assert = require ( 'simple-assert' ) ;
4
+ var type = require ( '..' ) ;
5
+ var symbolExists = typeof Symbol === 'function' ;
6
+ var symbolToStringTagExists = symbolExists && typeof Symbol . toStringTag !== 'undefined' ;
7
+ function describeIf ( condition ) {
8
+ return condition ? describe : describe . skip ;
9
+ }
10
+
11
+ describeIf ( symbolToStringTagExists ) ( 'toStringTag extras' , function ( ) {
12
+
13
+ it ( 'supports toStringTag on arrays' , function ( ) {
14
+ assert ( type ( [ ] ) === 'Array' ) ;
15
+ var arr = [ ] ;
16
+ arr [ Symbol . toStringTag ] = 'foo' ;
17
+ assert ( type ( arr ) === 'foo' , 'type(arr) === "foo"' ) ;
18
+ } ) ;
19
+
20
+
21
+ } ) ;
You can’t perform that action at this time.
0 commit comments