@@ -134,6 +134,9 @@ const builtInObjects = new Set(
134
134
ObjectGetOwnPropertyNames ( global ) . filter ( ( e ) => / ^ [ A - Z ] [ a - z A - Z 0 - 9 ] + $ / . test ( e ) )
135
135
) ;
136
136
137
+ // https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
138
+ const isUndetectableObject = ( v ) => typeof v === 'undefined' && v !== undefined ;
139
+
137
140
// These options must stay in sync with `getUserOptions`. So if any option will
138
141
// be added or removed, `getUserOptions` must also be updated accordingly.
139
142
const inspectDefaultOptions = ObjectSeal ( {
@@ -477,7 +480,7 @@ function getEmptyFormatArray() {
477
480
function getConstructorName ( obj , ctx , recurseTimes , protoProps ) {
478
481
let firstProto ;
479
482
const tmp = obj ;
480
- while ( obj ) {
483
+ while ( obj || isUndetectableObject ( obj ) ) {
481
484
const descriptor = ObjectGetOwnPropertyDescriptor ( obj , 'constructor' ) ;
482
485
if ( descriptor !== undefined &&
483
486
typeof descriptor . value === 'function' &&
@@ -675,7 +678,9 @@ function findTypedConstructor(value) {
675
678
// value afterwards again.
676
679
function formatValue ( ctx , value , recurseTimes , typedArray ) {
677
680
// Primitive types cannot have properties.
678
- if ( typeof value !== 'object' && typeof value !== 'function' ) {
681
+ if ( typeof value !== 'object' &&
682
+ typeof value !== 'function' &&
683
+ ! isUndetectableObject ( value ) ) {
679
684
return formatPrimitive ( ctx . stylize , value , ctx ) ;
680
685
}
681
686
if ( value === null ) {
0 commit comments