-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
util.inspect
shouldn’t format objects with the [[IsHTMLDDA]]
internal slot as undefined
#31889
Comments
I suppose this would matter when using electron, since you could actually do We could also hack this in as |
One solution would be to add
That would take care of that check, as C++ code doesn’t care whether an object is undetectable, since you can pass A polyfilled version is: function isObject(target) {
if (target === null || target === undefied) return false;
switch (typeof target) {
case "object":
case "function":
return true;
case "undefined":
try {
return Object.prototype.valueOf.call(target) === target;
} catch {}
}
return false;
} |
Fixes: #31889 PR-URL: #31938 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Fixes: #31889 PR-URL: #31938 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
util
What steps will reproduce the bug?
Run
node --allow-natives-syntax -p 'util.inspect(%GetUndetectable())'
What is the expected behavior?
What do you see instead?
Additional information
This is because the type check in
util.inspect
doesn’t account for objects with the[[IsHTMLDDA]]
internal slot:node/lib/internal/util/inspect.js
Lines 681 to 688 in cdac185
The text was updated successfully, but these errors were encountered: