| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 13d6597 commit cc544db
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -527,6 +527,14 @@ function getEmptyFormatArray() { | |||
| 527 | 527 | return []; | |
| 528 | 528 | } | |
| 529 | 529 | ||
| 530 | + function isInstanceof(object, proto) { | ||
| 531 | + try { | ||
| 532 | + return object instanceof proto; | ||
| 533 | + } catch { | ||
| 534 | + return false; | ||
| 535 | + } | ||
| 536 | + } | ||
| 537 | + | ||
| 530 | 538 | function getConstructorName(obj, ctx, recurseTimes, protoProps) { | |
| 531 | 539 | let firstProto; | |
| 532 | 540 | const tmp = obj; | |
@@ -535,7 +543,7 @@ function getConstructorName(obj, ctx, recurseTimes, protoProps) { | |||
| 535 | 543 | if (descriptor !== undefined && | |
| 536 | 544 | typeof descriptor.value === 'function' && | |
| 537 | 545 | descriptor.value.name !== '' && | |
| 538 | - tmp instanceof descriptor.value) { | ||
| 546 | + isInstanceof(tmp, descriptor.value)) { | ||
| 539 | 547 | if (protoProps !== undefined && | |
| 540 | 548 | (firstProto !== obj || | |
| 541 | 549 | !builtInObjects.has(descriptor.value.name))) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2866,6 +2866,17 @@ assert.strictEqual( | |||
| 2866 | 2866 | ); | |
| 2867 | 2867 | } | |
| 2868 | 2868 | ||
| 2869 | + // Check that prototypes with a null prototype are inspectable. | ||
| 2870 | + // Regression test for https://github.com/nodejs/node/issues/35730 | ||
| 2871 | + { | ||
| 2872 | + function Func() {} | ||
| 2873 | + Func.prototype = null; | ||
| 2874 | + const object = {}; | ||
| 2875 | + object.constructor = Func; | ||
| 2876 | + | ||
| 2877 | + assert.strictEqual(util.inspect(object), '{ constructor: [Function: Func] }'); | ||
| 2878 | + } | ||
| 2879 | + | ||
| 2869 | 2880 | // Test changing util.inspect.colors colors and aliases. | |
| 2870 | 2881 | { | |
| 2871 | 2882 | const colors = util.inspect.colors; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments