GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — util: fix inspecting document.all · nodejs/node@eccd2a7

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/util
    • inspect.js
  • test/parallel
    • test-util-inspect.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/util/inspect.js‎

Copy file name to clipboardExpand all lines: lib/internal/util/inspect.js
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ const builtInObjects = new Set(
134134
ObjectGetOwnPropertyNames(global).filter((e) => /^[A-Z][a-zA-Z0-9]+$/.test(e))
135135
);
136136

137+
// https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
138+
const isUndetectableObject = (v) => typeof v === 'undefined' && v !== undefined;
139+
137140
// These options must stay in sync with `getUserOptions`. So if any option will
138141
// be added or removed, `getUserOptions` must also be updated accordingly.
139142
const inspectDefaultOptions = ObjectSeal({
@@ -466,7 +469,7 @@ function getEmptyFormatArray() {
466469
function getConstructorName(obj, ctx, recurseTimes, protoProps) {
467470
let firstProto;
468471
const tmp = obj;
469-
while (obj) {
472+
while (obj || isUndetectableObject(obj)) {
470473
const descriptor = ObjectGetOwnPropertyDescriptor(obj, 'constructor');
471474
if (descriptor !== undefined &&
472475
typeof descriptor.value === 'function' &&
@@ -664,7 +667,9 @@ function findTypedConstructor(value) {
664667
// value afterwards again.
665668
function formatValue(ctx, value, recurseTimes, typedArray) {
666669
// 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)) {
668673
return formatPrimitive(ctx.stylize, value, ctx);
669674
}
670675
if (value === null) {
Collapse file

‎test/parallel/test-util-inspect.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-util-inspect.js
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const { internalBinding } = require('internal/test/binding');
2626
const JSStream = internalBinding('js_stream').JSStream;
2727
const util = require('util');
2828
const vm = require('vm');
29+
const v8 = require('v8');
2930
const { previewEntries } = internalBinding('util');
3031
const { inspect } = util;
3132
const { MessageChannel } = require('worker_threads');
@@ -2727,3 +2728,11 @@ assert.strictEqual(
27272728
assert.deepStrictEqual(colors.gray, originalValue);
27282729
assert.strictEqual(colors.grey, colors.gray);
27292730
}
2731+
2732+
// https://github.com/nodejs/node/issues/31889
2733+
{
2734+
v8.setFlagsFromString('--allow-natives-syntax');
2735+
const undetectable = vm.runInThisContext('%GetUndetectable()');
2736+
v8.setFlagsFromString('--no-allow-natives-syntax');
2737+
assert.strictEqual(inspect(undetectable), '{}');
2738+
}

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.