@@ -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 ( {
@@ -466,7 +469,7 @@ function getEmptyFormatArray() {
466
469
function getConstructorName ( obj , ctx , recurseTimes , protoProps ) {
467
470
let firstProto ;
468
471
const tmp = obj ;
469
- while ( obj ) {
472
+ while ( obj || isUndetectableObject ( obj ) ) {
470
473
const descriptor = ObjectGetOwnPropertyDescriptor ( obj , 'constructor' ) ;
471
474
if ( descriptor !== undefined &&
472
475
typeof descriptor . value === 'function' &&
@@ -664,7 +667,9 @@ function findTypedConstructor(value) {
664
667
// value afterwards again.
665
668
function formatValue ( ctx , value , recurseTimes , typedArray ) {
666
669
// Primitive types cannot have properties.
667
- if ( typeof value !== 'object' && typeof value !== 'function' ) {
670
+ if ( typeof value !== 'object' &&
671
+ typeof value !== 'function' &&
672
+ ! isUndetectableObject ( value ) ) {
668
673
return formatPrimitive ( ctx . stylize , value , ctx ) ;
669
674
}
670
675
if ( value === null ) {
0 commit comments