fix(ext/console): render properties of Intl.Locale (#24827)

Fixes #21271

---------

Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
This commit is contained in:
Leo Kettmeir 2024-08-01 09:45:05 -07:00 committed by GitHub
parent 4eda9e64e9
commit 6db5f1bb6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 36 additions and 0 deletions

View File

@ -790,6 +790,24 @@ function formatRaw(ctx, value, recurseTimes, typedArray, proxyDetails) {
return ctx.stylize(base, "date");
}
}
} else if (
proxyDetails === null &&
ObjectPrototypeIsPrototypeOf(globalThis.Intl.Locale.prototype, value)
) {
braces[0] = `${getPrefix(constructor, tag, "Intl.Locale")}{`;
ArrayPrototypeUnshift(
keys,
"baseName",
"calendar",
"caseFirst",
"collation",
"hourCycle",
"language",
"numberingSystem",
"numeric",
"region",
"script",
);
} else if (
proxyDetails === null &&
typeof globalThis.Temporal !== "undefined" &&

View File

@ -1066,6 +1066,24 @@ Deno.test(async function consoleTestStringifyPromises() {
assertEquals(strLines[1], " <rejected> Error: Whoops");
});
Deno.test(function consoleTestStringifyIntlLocale() {
assertEquals(
stringify(new Intl.Locale("zh-Hant-TW", { hourCycle: "h12" })),
`Locale [Intl.Locale] {
baseName: "zh-Hant-TW",
calendar: undefined,
caseFirst: undefined,
collation: undefined,
hourCycle: "h12",
language: "zh",
numberingSystem: undefined,
numeric: false,
region: "TW",
script: "Hant"
}`,
);
});
Deno.test(function consoleTestWithCustomInspector() {
class A {
[customInspect](