mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-10 10:09:14 +00:00
LibJS: Rename Intl.Locale's RelevantExtensionKeys to LocaleExtensionKeys
This is an editorial change in the ECMA-402 spec. See:
e2a5747
This commit is contained in:
parent
680f028bb8
commit
75fce14f09
Notes:
github-actions[bot]
2025-04-08 10:53:36 +00:00
Author: https://github.com/trflynn89
Commit: 75fce14f09
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4275
2 changed files with 16 additions and 18 deletions
|
@ -25,15 +25,13 @@ class Locale final : public Object {
|
||||||
public:
|
public:
|
||||||
static GC::Ref<Locale> create(Realm&, GC::Ref<Locale> source_locale, String);
|
static GC::Ref<Locale> create(Realm&, GC::Ref<Locale> 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
|
// 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
|
// 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" ».
|
// The value of the [[LocaleExtensionKeys]] internal slot is « "ca", "co", "fw", "hc", "kf", "kn", "nu" ».
|
||||||
// If %Collator%.[[RelevantExtensionKeys]] does not contain "kf", then remove "kf" from %Locale%.[[RelevantExtensionKeys]].
|
// If %Intl.Collator%.[[RelevantExtensionKeys]] does not contain "kf", then remove "kf" from %Intl.Locale%.[[LocaleExtensionKeys]].
|
||||||
// If %Collator%.[[RelevantExtensionKeys]] does not contain "kn", then remove "kn" from %Locale%.[[RelevantExtensionKeys]].
|
// If %Intl.Collator%.[[RelevantExtensionKeys]] does not contain "kn", then remove "kn" from %Intl.Locale%.[[LocaleExtensionKeys]].
|
||||||
|
|
||||||
// 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.
|
|
||||||
return AK::Array { "ca"sv, "co"sv, "fw"sv, "hc"sv, "kf"sv, "kn"sv, "nu"sv };
|
return AK::Array { "ca"sv, "co"sv, "fw"sv, "hc"sv, "kf"sv, "kn"sv, "nu"sv };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -251,14 +251,14 @@ ThrowCompletionOr<GC::Ref<Object>> LocaleConstructor::construct(FunctionObject&
|
||||||
auto tag_value = vm.argument(0);
|
auto tag_value = vm.argument(0);
|
||||||
auto options_value = vm.argument(1);
|
auto options_value = vm.argument(1);
|
||||||
|
|
||||||
// 2. Let relevantExtensionKeys be %Locale%.[[RelevantExtensionKeys]].
|
// 2. Let localeExtensionKeys be %Intl.Locale%.[[LocaleExtensionKeys]].
|
||||||
auto relevant_extension_keys = Locale::relevant_extension_keys();
|
auto locale_extension_keys = Locale::locale_extension_keys();
|
||||||
|
|
||||||
// 3. Let internalSlotsList be « [[InitializedLocale]], [[Locale]], [[Calendar]], [[Collation]], [[FirstDayOfWeek]], [[HourCycle]], [[NumberingSystem]] ».
|
// 3. Let internalSlotsList be « [[InitializedLocale]], [[Locale]], [[Calendar]], [[Collation]], [[FirstDayOfWeek]], [[HourCycle]], [[NumberingSystem]] ».
|
||||||
// 4. If relevantExtensionKeys contains "kf", then
|
// 4. If localeExtensionKeys contains "kf", then
|
||||||
// a. Append [[CaseFirst]] as the last element of internalSlotsList.
|
// a. Append [[CaseFirst]] to internalSlotsList.
|
||||||
// 5. If relevantExtensionKeys contains "kn", then
|
// 5. If localeExtensionKeys contains "kn", then
|
||||||
// a. Append [[Numeric]] as the last element of internalSlotsList.
|
// a. Append [[Numeric]] to internalSlotsList.
|
||||||
|
|
||||||
// 6. Let locale be ? OrdinaryCreateFromConstructor(NewTarget, "%Intl.Locale.prototype%", internalSlotsList).
|
// 6. Let locale be ? OrdinaryCreateFromConstructor(NewTarget, "%Intl.Locale.prototype%", internalSlotsList).
|
||||||
auto locale = TRY(ordinary_create_from_constructor<Locale>(vm, new_target, &Intrinsics::intl_locale_prototype));
|
auto locale = TRY(ordinary_create_from_constructor<Locale>(vm, new_target, &Intrinsics::intl_locale_prototype));
|
||||||
|
@ -340,8 +340,8 @@ ThrowCompletionOr<GC::Ref<Object>> LocaleConstructor::construct(FunctionObject&
|
||||||
// 31. Set opt.[[nu]] to numberingSystem.
|
// 31. Set opt.[[nu]] to numberingSystem.
|
||||||
opt.nu = TRY(get_string_option(vm, *options, vm.names.numberingSystem, Unicode::is_type_identifier));
|
opt.nu = TRY(get_string_option(vm, *options, vm.names.numberingSystem, Unicode::is_type_identifier));
|
||||||
|
|
||||||
// 32. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, relevantExtensionKeys).
|
// 32. Let r be ! ApplyUnicodeExtensionToTag(tag, opt, localeExtensionKeys).
|
||||||
auto result = apply_unicode_extension_to_tag(tag, move(opt), relevant_extension_keys);
|
auto result = apply_unicode_extension_to_tag(tag, move(opt), locale_extension_keys);
|
||||||
|
|
||||||
// 33. Set locale.[[Locale]] to r.[[locale]].
|
// 33. Set locale.[[Locale]] to r.[[locale]].
|
||||||
locale->set_locale(move(result.locale));
|
locale->set_locale(move(result.locale));
|
||||||
|
@ -362,15 +362,15 @@ ThrowCompletionOr<GC::Ref<Object>> LocaleConstructor::construct(FunctionObject&
|
||||||
if (result.hc.has_value())
|
if (result.hc.has_value())
|
||||||
locale->set_hour_cycle(result.hc.release_value());
|
locale->set_hour_cycle(result.hc.release_value());
|
||||||
|
|
||||||
// 38. If relevantExtensionKeys contains "kf", then
|
// 38. If localeExtensionKeys contains "kf", then
|
||||||
if (relevant_extension_keys.span().contains_slow("kf"sv)) {
|
if (locale_extension_keys.span().contains_slow("kf"sv)) {
|
||||||
// a. Set locale.[[CaseFirst]] to r.[[kf]].
|
// a. Set locale.[[CaseFirst]] to r.[[kf]].
|
||||||
if (result.kf.has_value())
|
if (result.kf.has_value())
|
||||||
locale->set_case_first(result.kf.release_value());
|
locale->set_case_first(result.kf.release_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 39. If relevantExtensionKeys contains "kn", then
|
// 39. If localeExtensionKeys contains "kn", then
|
||||||
if (relevant_extension_keys.span().contains_slow("kn"sv)) {
|
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
|
// 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())) {
|
if (result.kn.has_value() && (result.kn == "true"sv || result.kn->is_empty())) {
|
||||||
// i. Set locale.[[Numeric]] to true.
|
// i. Set locale.[[Numeric]] to true.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue