From 75fce14f0963e6ba121acac61efc8ded80ee9e71 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Mon, 7 Apr 2025 14:33:34 -0400 Subject: [PATCH] LibJS: Rename Intl.Locale's RelevantExtensionKeys to LocaleExtensionKeys This is an editorial change in the ECMA-402 spec. See: https://github.com/tc39/ecma402/commit/e2a5747 --- Libraries/LibJS/Runtime/Intl/Locale.h | 10 ++++---- .../LibJS/Runtime/Intl/LocaleConstructor.cpp | 24 +++++++++---------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Libraries/LibJS/Runtime/Intl/Locale.h b/Libraries/LibJS/Runtime/Intl/Locale.h index 9a04f795151..e7c8960b8e8 100644 --- a/Libraries/LibJS/Runtime/Intl/Locale.h +++ b/Libraries/LibJS/Runtime/Intl/Locale.h @@ -25,15 +25,13 @@ class Locale final : public Object { public: static GC::Ref create(Realm&, GC::Ref source_locale, String); - static constexpr auto relevant_extension_keys() + static constexpr auto locale_extension_keys() { // 15.2.2 Internal slots, https://tc39.es/ecma402/#sec-intl.locale-internal-slots // 1.3.2 Internal slots, https://tc39.es/proposal-intl-locale-info/#sec-intl.locale-internal-slots - // The value of the [[RelevantExtensionKeys]] internal slot is « "ca", "co", "fw", "hc", "kf", "kn", "nu" ». - // If %Collator%.[[RelevantExtensionKeys]] does not contain "kf", then remove "kf" from %Locale%.[[RelevantExtensionKeys]]. - // If %Collator%.[[RelevantExtensionKeys]] does not contain "kn", then remove "kn" from %Locale%.[[RelevantExtensionKeys]]. - - // FIXME: We do not yet have an Intl.Collator object. For now, we behave as if "kf" and "kn" exist, as test262 depends on it. + // The value of the [[LocaleExtensionKeys]] internal slot is « "ca", "co", "fw", "hc", "kf", "kn", "nu" ». + // If %Intl.Collator%.[[RelevantExtensionKeys]] does not contain "kf", then remove "kf" from %Intl.Locale%.[[LocaleExtensionKeys]]. + // If %Intl.Collator%.[[RelevantExtensionKeys]] does not contain "kn", then remove "kn" from %Intl.Locale%.[[LocaleExtensionKeys]]. return AK::Array { "ca"sv, "co"sv, "fw"sv, "hc"sv, "kf"sv, "kn"sv, "nu"sv }; } diff --git a/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp b/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp index 1e90cd919cd..eb84daabe53 100644 --- a/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp +++ b/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp @@ -251,14 +251,14 @@ ThrowCompletionOr> LocaleConstructor::construct(FunctionObject& auto tag_value = vm.argument(0); auto options_value = vm.argument(1); - // 2. Let relevantExtensionKeys be %Locale%.[[RelevantExtensionKeys]]. - auto relevant_extension_keys = Locale::relevant_extension_keys(); + // 2. Let localeExtensionKeys be %Intl.Locale%.[[LocaleExtensionKeys]]. + auto locale_extension_keys = Locale::locale_extension_keys(); // 3. Let internalSlotsList be « [[InitializedLocale]], [[Locale]], [[Calendar]], [[Collation]], [[FirstDayOfWeek]], [[HourCycle]], [[NumberingSystem]] ». - // 4. If relevantExtensionKeys contains "kf", then - // a. Append [[CaseFirst]] as the last element of internalSlotsList. - // 5. If relevantExtensionKeys contains "kn", then - // a. Append [[Numeric]] as the last element of internalSlotsList. + // 4. If localeExtensionKeys contains "kf", then + // a. Append [[CaseFirst]] to internalSlotsList. + // 5. If localeExtensionKeys contains "kn", then + // a. Append [[Numeric]] to internalSlotsList. // 6. Let locale be ? OrdinaryCreateFromConstructor(NewTarget, "%Intl.Locale.prototype%", internalSlotsList). auto locale = TRY(ordinary_create_from_constructor(vm, new_target, &Intrinsics::intl_locale_prototype)); @@ -340,8 +340,8 @@ ThrowCompletionOr> LocaleConstructor::construct(FunctionObject& // 31. Set opt.[[nu]] to numberingSystem. opt.nu = TRY(get_string_option(vm, *options, vm.names.numberingSystem, Unicode::is_type_identifier)); - // 32. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys). - auto result = apply_unicode_extension_to_tag(tag, move(opt), relevant_extension_keys); + // 32. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, localeExtensionKeys). + auto result = apply_unicode_extension_to_tag(tag, move(opt), locale_extension_keys); // 33. Set locale.[[Locale]] to r.[[locale]]. locale->set_locale(move(result.locale)); @@ -362,15 +362,15 @@ ThrowCompletionOr> LocaleConstructor::construct(FunctionObject& if (result.hc.has_value()) locale->set_hour_cycle(result.hc.release_value()); - // 38. If relevantExtensionKeys contains "kf", then - if (relevant_extension_keys.span().contains_slow("kf"sv)) { + // 38. If localeExtensionKeys contains "kf", then + if (locale_extension_keys.span().contains_slow("kf"sv)) { // a. Set locale.[[CaseFirst]] to r.[[kf]]. if (result.kf.has_value()) locale->set_case_first(result.kf.release_value()); } - // 39. If relevantExtensionKeys contains "kn", then - if (relevant_extension_keys.span().contains_slow("kn"sv)) { + // 39. If localeExtensionKeys contains "kn", then + if (locale_extension_keys.span().contains_slow("kn"sv)) { // a. If SameValue(r.[[kn]], "true") is true or r.[[kn]] is the empty String, then if (result.kn.has_value() && (result.kn == "true"sv || result.kn->is_empty())) { // i. Set locale.[[Numeric]] to true.