mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:17:35 +00:00
LibJS+LibUnicode: Convert Intl.ListFormat to use Unicode::Style
Remove ListFormat's own definition of the Style enum, which was further duplicated by a generated ListPatternStyle enum with the same values.
This commit is contained in:
parent
e261132e8b
commit
bced4e9324
5 changed files with 14 additions and 59 deletions
|
@ -9,7 +9,6 @@
|
|||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Intl/ListFormat.h>
|
||||
#include <LibJS/Runtime/IteratorOperations.h>
|
||||
#include <LibUnicode/Locale.h>
|
||||
|
||||
namespace JS::Intl {
|
||||
|
||||
|
@ -46,33 +45,6 @@ StringView ListFormat::type_string() const
|
|||
}
|
||||
}
|
||||
|
||||
void ListFormat::set_style(StringView style)
|
||||
{
|
||||
if (style == "narrow"sv) {
|
||||
m_style = Style::Narrow;
|
||||
} else if (style == "short"sv) {
|
||||
m_style = Style::Short;
|
||||
} else if (style == "long"sv) {
|
||||
m_style = Style::Long;
|
||||
} else {
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
StringView ListFormat::style_string() const
|
||||
{
|
||||
switch (m_style) {
|
||||
case Style::Narrow:
|
||||
return "narrow"sv;
|
||||
case Style::Short:
|
||||
return "short"sv;
|
||||
case Style::Long:
|
||||
return "long"sv;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
// 13.1.1 DeconstructPattern ( pattern, placeables ), https://tc39.es/ecma402/#sec-deconstructpattern
|
||||
Vector<PatternPartition> deconstruct_pattern(StringView pattern, Placeables placeables)
|
||||
{
|
||||
|
@ -123,7 +95,7 @@ Vector<PatternPartition> deconstruct_pattern(StringView pattern, Placeables plac
|
|||
// 13.1.2 CreatePartsFromList ( listFormat, list ), https://tc39.es/ecma402/#sec-createpartsfromlist
|
||||
Vector<PatternPartition> create_parts_from_list(ListFormat const& list_format, Vector<String> const& list)
|
||||
{
|
||||
auto list_patterns = Unicode::get_locale_list_patterns(list_format.locale(), list_format.type_string(), list_format.style_string());
|
||||
auto list_patterns = Unicode::get_locale_list_patterns(list_format.locale(), list_format.type_string(), list_format.style());
|
||||
if (!list_patterns.has_value())
|
||||
return {};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue