1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

fix(console): missing cause property on non-error objects (#26061)

Fixes https://github.com/denoland/deno/issues/26047
This commit is contained in:
Marvin Hagemeister 2024-10-08 12:10:19 +02:00 committed by GitHub
parent 053894b9e0
commit 2d488e4bfb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 1 deletions

View file

@ -1301,7 +1301,9 @@ function getKeys(value, showHidden) {
ArrayPrototypePushApply(keys, ArrayPrototypeFilter(symbols, filter));
}
}
keys = ArrayPrototypeFilter(keys, (key) => key !== "cause");
if (ObjectPrototypeIsPrototypeOf(ErrorPrototype, value)) {
keys = ArrayPrototypeFilter(keys, (key) => key !== "cause");
}
return keys;
}

View file

@ -1913,6 +1913,21 @@ Deno.test(function consoleLogWhenCauseIsAssignedShouldNotPrintCauseTwice() {
});
});
Deno.test(function consoleLogCauseNotFilteredOnNonError() {
mockConsole((console, out) => {
const foo = {
a: 1,
b: 2,
cause: 3,
};
console.log(foo);
const result = stripAnsiCode(out.toString());
const expected = "{ a: 1, b: 2, cause: 3 }\n";
assertEquals(result.trim(), expected.trim());
});
});
// console.log(new Proxy(new RegExp(), {}))
Deno.test(function consoleLogShouldNotThrowErrorWhenInputIsProxiedRegExp() {
mockConsole((console, out) => {