mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:27:35 +00:00
LibJS: Update syntax for invoking the GetOption AO from Intl objects
This is an editorial change in the ECMA-402 spec. See:
0ac2e10
This commit is contained in:
parent
2cca5d6676
commit
95cef87a9c
12 changed files with 73 additions and 72 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021-2022, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2021-2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -94,13 +94,13 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(VM& vm, DateTimeF
|
|||
// 3. Let opt be a new Record.
|
||||
LocaleOptions opt {};
|
||||
|
||||
// 4. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
|
||||
// 4. Let matcher be ? GetOption(options, "localeMatcher", string, « "lookup", "best fit" », "best fit").
|
||||
auto matcher = TRY(get_option(vm, *options, vm.names.localeMatcher, OptionType::String, AK::Array { "lookup"sv, "best fit"sv }, "best fit"sv));
|
||||
|
||||
// 5. Set opt.[[localeMatcher]] to matcher.
|
||||
opt.locale_matcher = matcher;
|
||||
|
||||
// 6. Let calendar be ? GetOption(options, "calendar", "string", undefined, undefined).
|
||||
// 6. Let calendar be ? GetOption(options, "calendar", string, empty, undefined).
|
||||
auto calendar = TRY(get_option(vm, *options, vm.names.calendar, OptionType::String, {}, Empty {}));
|
||||
|
||||
// 7. If calendar is not undefined, then
|
||||
|
@ -113,7 +113,7 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(VM& vm, DateTimeF
|
|||
opt.ca = TRY(calendar.as_string().deprecated_string());
|
||||
}
|
||||
|
||||
// 9. Let numberingSystem be ? GetOption(options, "numberingSystem", "string", undefined, undefined).
|
||||
// 9. Let numberingSystem be ? GetOption(options, "numberingSystem", string, empty, undefined).
|
||||
auto numbering_system = TRY(get_option(vm, *options, vm.names.numberingSystem, OptionType::String, {}, Empty {}));
|
||||
|
||||
// 10. If numberingSystem is not undefined, then
|
||||
|
@ -126,10 +126,10 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(VM& vm, DateTimeF
|
|||
opt.nu = TRY(numbering_system.as_string().deprecated_string());
|
||||
}
|
||||
|
||||
// 12. Let hour12 be ? GetOption(options, "hour12", "boolean", undefined, undefined).
|
||||
// 12. Let hour12 be ? GetOption(options, "hour12", boolean, empty, undefined).
|
||||
auto hour12 = TRY(get_option(vm, *options, vm.names.hour12, OptionType::Boolean, {}, Empty {}));
|
||||
|
||||
// 13. Let hourCycle be ? GetOption(options, "hourCycle", "string", « "h11", "h12", "h23", "h24" », undefined).
|
||||
// 13. Let hourCycle be ? GetOption(options, "hourCycle", string, « "h11", "h12", "h23", "h24" », undefined).
|
||||
auto hour_cycle = TRY(get_option(vm, *options, vm.names.hourCycle, OptionType::String, AK::Array { "h11"sv, "h12"sv, "h23"sv, "h24"sv }, Empty {}));
|
||||
|
||||
// 14. If hour12 is not undefined, then
|
||||
|
@ -272,7 +272,7 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(VM& vm, DateTimeF
|
|||
// c. Else,
|
||||
else {
|
||||
// i. Let values be a List whose elements are the strings given in the Values column of the row.
|
||||
// ii. Let value be ? GetOption(options, prop, "string", values, undefined).
|
||||
// ii. Let value be ? GetOption(options, prop, string, values, undefined).
|
||||
auto value = TRY(get_option(vm, *options, property, OptionType::String, values, Empty {}));
|
||||
|
||||
// d. Set formatOptions.[[<prop>]] to value.
|
||||
|
@ -288,17 +288,17 @@ ThrowCompletionOr<DateTimeFormat*> initialize_date_time_format(VM& vm, DateTimeF
|
|||
return {};
|
||||
}));
|
||||
|
||||
// 37. Let matcher be ? GetOption(options, "formatMatcher", "string", « "basic", "best fit" », "best fit").
|
||||
// 37. Let matcher be ? GetOption(options, "formatMatcher", string, « "basic", "best fit" », "best fit").
|
||||
matcher = TRY(get_option(vm, *options, vm.names.formatMatcher, OptionType::String, AK::Array { "basic"sv, "best fit"sv }, "best fit"sv));
|
||||
|
||||
// 38. Let dateStyle be ? GetOption(options, "dateStyle", "string", « "full", "long", "medium", "short" », undefined).
|
||||
// 38. Let dateStyle be ? GetOption(options, "dateStyle", string, « "full", "long", "medium", "short" », undefined).
|
||||
auto date_style = TRY(get_option(vm, *options, vm.names.dateStyle, OptionType::String, AK::Array { "full"sv, "long"sv, "medium"sv, "short"sv }, Empty {}));
|
||||
|
||||
// 39. Set dateTimeFormat.[[DateStyle]] to dateStyle.
|
||||
if (!date_style.is_undefined())
|
||||
date_time_format.set_date_style(TRY(date_style.as_string().deprecated_string()));
|
||||
|
||||
// 40. Let timeStyle be ? GetOption(options, "timeStyle", "string", « "full", "long", "medium", "short" », undefined).
|
||||
// 40. Let timeStyle be ? GetOption(options, "timeStyle", string, « "full", "long", "medium", "short" », undefined).
|
||||
auto time_style = TRY(get_option(vm, *options, vm.names.timeStyle, OptionType::String, AK::Array { "full"sv, "long"sv, "medium"sv, "short"sv }, Empty {}));
|
||||
|
||||
// 41. Set dateTimeFormat.[[TimeStyle]] to timeStyle.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue