mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
fix(inspector): Deno.inspect should inspect the object the proxy represents rather than the target of the proxy (#10977)
This commit is contained in:
parent
0c0058f118
commit
984b8bf0c8
2 changed files with 28 additions and 6 deletions
|
@ -1737,16 +1737,40 @@ unitTest(function inspectIterableLimit(): void {
|
|||
unitTest(function inspectProxy(): void {
|
||||
assertEquals(
|
||||
stripColor(Deno.inspect(
|
||||
new Proxy([1, 2, 3], { get(): void {} }),
|
||||
new Proxy([1, 2, 3], {}),
|
||||
)),
|
||||
"[ 1, 2, 3 ]",
|
||||
);
|
||||
assertEquals(
|
||||
stripColor(Deno.inspect(
|
||||
new Proxy({ key: "value" }, { get(): void {} }),
|
||||
new Proxy({ key: "value" }, {}),
|
||||
)),
|
||||
`{ key: "value" }`,
|
||||
);
|
||||
assertEquals(
|
||||
stripColor(Deno.inspect(
|
||||
new Proxy({}, {
|
||||
get(_target, key) {
|
||||
if (key === Symbol.toStringTag) {
|
||||
return "MyProxy";
|
||||
} else {
|
||||
return 5;
|
||||
}
|
||||
},
|
||||
getOwnPropertyDescriptor() {
|
||||
return {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
value: 5,
|
||||
};
|
||||
},
|
||||
ownKeys() {
|
||||
return ["prop1", "prop2"];
|
||||
},
|
||||
}),
|
||||
)),
|
||||
`MyProxy { prop1: 5, prop2: 5 }`,
|
||||
);
|
||||
assertEquals(
|
||||
stripColor(Deno.inspect(
|
||||
new Proxy([1, 2, 3], { get(): void {} }),
|
||||
|
|
|
@ -429,10 +429,8 @@
|
|||
inspectOptions,
|
||||
) {
|
||||
const proxyDetails = core.getProxyDetails(value);
|
||||
if (proxyDetails != null) {
|
||||
return inspectOptions.showProxy
|
||||
? inspectProxy(proxyDetails, level, inspectOptions)
|
||||
: inspectValue(proxyDetails[0], level, inspectOptions);
|
||||
if (proxyDetails != null && inspectOptions.showProxy) {
|
||||
return inspectProxy(proxyDetails, level, inspectOptions);
|
||||
}
|
||||
|
||||
const green = maybeColor(colors.green, inspectOptions);
|
||||
|
|
Loading…
Add table
Reference in a new issue