mirror of
https://github.com/denoland/deno.git
synced 2025-01-11 16:42:21 -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
|
// console.dir test
|
||||||
Deno.test(function consoleDir() {
|
Deno.test(function consoleDir() {
|
||||||
mockConsole((console, out) => {
|
mockConsole((console, out) => {
|
||||||
|
|
|
@ -701,7 +701,11 @@
|
||||||
return handleCircular(value, cyan);
|
return handleCircular(value, cyan);
|
||||||
}
|
}
|
||||||
|
|
||||||
return inspectObject(value, inspectOptions, proxyDetails);
|
return inspectObject(
|
||||||
|
value,
|
||||||
|
inspectOptions,
|
||||||
|
proxyDetails,
|
||||||
|
);
|
||||||
default:
|
default:
|
||||||
// Not implemented is red
|
// Not implemented is red
|
||||||
return red("[Not Implemented]");
|
return red("[Not Implemented]");
|
||||||
|
@ -1283,11 +1287,7 @@
|
||||||
return [baseString, refIndex];
|
return [baseString, refIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
function inspectObject(
|
function inspectObject(value, inspectOptions, proxyDetails) {
|
||||||
value,
|
|
||||||
inspectOptions,
|
|
||||||
proxyDetails,
|
|
||||||
) {
|
|
||||||
if (
|
if (
|
||||||
ReflectHas(value, customInspect) &&
|
ReflectHas(value, customInspect) &&
|
||||||
typeof value[customInspect] === "function"
|
typeof value[customInspect] === "function"
|
||||||
|
@ -1330,7 +1330,10 @@
|
||||||
} else if (ObjectPrototypeIsPrototypeOf(RegExpPrototype, value)) {
|
} else if (ObjectPrototypeIsPrototypeOf(RegExpPrototype, value)) {
|
||||||
return inspectRegExp(value, inspectOptions);
|
return inspectRegExp(value, inspectOptions);
|
||||||
} else if (ObjectPrototypeIsPrototypeOf(DatePrototype, value)) {
|
} else if (ObjectPrototypeIsPrototypeOf(DatePrototype, value)) {
|
||||||
return inspectDate(value, inspectOptions);
|
return inspectDate(
|
||||||
|
proxyDetails ? proxyDetails[0] : value,
|
||||||
|
inspectOptions,
|
||||||
|
);
|
||||||
} else if (ObjectPrototypeIsPrototypeOf(SetPrototype, value)) {
|
} else if (ObjectPrototypeIsPrototypeOf(SetPrototype, value)) {
|
||||||
return inspectSet(
|
return inspectSet(
|
||||||
proxyDetails ? proxyDetails[0] : value,
|
proxyDetails ? proxyDetails[0] : value,
|
||||||
|
|
Loading…
Reference in a new issue