mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 08:09:08 -05:00
fix(ext/console): fix error when logging a proxied Date (#16018)
This commit is contained in:
parent
b73cb7bf9c
commit
a2262c11d7
2 changed files with 19 additions and 7 deletions
|
@ -1678,6 +1678,15 @@ Deno.test(function consoleLogShouldNotThrowErrorWhenInputIsProxiedMap() {
|
|||
});
|
||||
});
|
||||
|
||||
// console.log(new Proxy(new Date(), {}))
|
||||
Deno.test(function consoleLogShouldNotThrowErrorWhenInputIsProxiedDate() {
|
||||
mockConsole((console, out) => {
|
||||
const proxiedDate = new Proxy(new Date("2022-09-24T15:59:39.529Z"), {});
|
||||
console.log(proxiedDate);
|
||||
assertEquals(stripColor(out.toString()), "2022-09-24T15:59:39.529Z\n");
|
||||
});
|
||||
});
|
||||
|
||||
// console.dir test
|
||||
Deno.test(function consoleDir() {
|
||||
mockConsole((console, out) => {
|
||||
|
|
|
@ -701,7 +701,11 @@
|
|||
return handleCircular(value, cyan);
|
||||
}
|
||||
|
||||
return inspectObject(value, inspectOptions, proxyDetails);
|
||||
return inspectObject(
|
||||
value,
|
||||
inspectOptions,
|
||||
proxyDetails,
|
||||
);
|
||||
default:
|
||||
// Not implemented is red
|
||||
return red("[Not Implemented]");
|
||||
|
@ -1283,11 +1287,7 @@
|
|||
return [baseString, refIndex];
|
||||
}
|
||||
|
||||
function inspectObject(
|
||||
value,
|
||||
inspectOptions,
|
||||
proxyDetails,
|
||||
) {
|
||||
function inspectObject(value, inspectOptions, proxyDetails) {
|
||||
if (
|
||||
ReflectHas(value, customInspect) &&
|
||||
typeof value[customInspect] === "function"
|
||||
|
@ -1330,7 +1330,10 @@
|
|||
} else if (ObjectPrototypeIsPrototypeOf(RegExpPrototype, value)) {
|
||||
return inspectRegExp(value, inspectOptions);
|
||||
} else if (ObjectPrototypeIsPrototypeOf(DatePrototype, value)) {
|
||||
return inspectDate(value, inspectOptions);
|
||||
return inspectDate(
|
||||
proxyDetails ? proxyDetails[0] : value,
|
||||
inspectOptions,
|
||||
);
|
||||
} else if (ObjectPrototypeIsPrototypeOf(SetPrototype, value)) {
|
||||
return inspectSet(
|
||||
proxyDetails ? proxyDetails[0] : value,
|
||||
|
|
Loading…
Reference in a new issue