LibJS: Move number_format_relevant_extension_keys to Intl.NumberFormat

This method represents the Intl.NumberFormat's [[RelevantExtensionKeys]]
internal slot, so it makes more sense for this to be directly in the
class itself.
This commit is contained in:
Timothy Flynn 2021-09-11 11:11:02 -04:00 committed by Linus Groh
parent 94a5a0437c
commit 7769cd2cab
Notes: sideshowbarker 2024-07-18 04:09:57 +09:00
2 changed files with 11 additions and 9 deletions

View File

@ -12,6 +12,14 @@
namespace JS::Intl {
Vector<StringView> const& NumberFormat::relevant_extension_keys()
{
// 15.3.3 Internal slots, https://tc39.es/ecma402/#sec-intl.numberformat-internal-slots
// The value of the [[RelevantExtensionKeys]] internal slot is « "nu" ».
static Vector<StringView> relevant_extension_keys { "nu"sv };
return relevant_extension_keys;
}
// 15 NumberFormat Objects, https://tc39.es/ecma402/#numberformat-objects
NumberFormat::NumberFormat(Object& prototype)
: Object(prototype)
@ -230,14 +238,6 @@ StringView NumberFormat::sign_display_string() const
}
}
static Vector<StringView> const& number_format_relevant_extension_keys()
{
// 15.3.3 Internal slots, https://tc39.es/ecma402/#sec-intl.numberformat-internal-slots
// The value of the [[RelevantExtensionKeys]] internal slot is « "nu" ».
static Vector<StringView> relevant_extension_keys { "nu"sv };
return relevant_extension_keys;
}
// 15.1.1 SetNumberFormatDigitOptions ( intlObj, options, mnfdDefault, mxfdDefault, notation ), https://tc39.es/ecma402/#sec-setnfdigitoptions
void set_number_format_digit_options(GlobalObject& global_object, NumberFormat& intl_object, Object const& options, int default_min_fraction_digits, int default_max_fraction_digits, NumberFormat::Notation notation)
{
@ -396,7 +396,7 @@ NumberFormat* initialize_number_format(GlobalObject& global_object, NumberFormat
// 9. Let localeData be %NumberFormat%.[[LocaleData]].
// 10. Let r be ResolveLocale(%NumberFormat%.[[AvailableLocales]], requestedLocales, opt, %NumberFormat%.[[RelevantExtensionKeys]], localeData).
auto result = resolve_locale(requested_locales, opt, number_format_relevant_extension_keys());
auto result = resolve_locale(requested_locales, opt, NumberFormat::relevant_extension_keys());
// 11. Set numberFormat.[[Locale]] to r.[[locale]].
number_format.set_locale(move(result.locale));

View File

@ -70,6 +70,8 @@ public:
ExceptZero,
};
static Vector<StringView> const& relevant_extension_keys(); // [[RelevantExtensionKeys]]
NumberFormat(Object& prototype);
virtual ~NumberFormat() override = default;