mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-04 00:27:47 +00:00
LibJS: Allow out-of-order plural ranges to be formatted
This is a normative change to the Intl NumberFormat V3 spec:
0c3d849
This commit is contained in:
parent
fd7d97fba5
commit
417a385db1
Notes:
sideshowbarker
2024-07-17 08:33:26 +09:00
Author: https://github.com/trflynn89
Commit: 417a385db1
Pull-request: https://github.com/SerenityOS/serenity/pull/14698
Reviewed-by: https://github.com/linusg ✅
3 changed files with 17 additions and 14 deletions
|
@ -152,23 +152,19 @@ ThrowCompletionOr<Unicode::PluralCategory> resolve_plural_range(GlobalObject& gl
|
|||
if (end.is_nan())
|
||||
return vm.throw_completion<RangeError>(global_object, ErrorType::IntlNumberIsNaN, "end"sv);
|
||||
|
||||
// 6. If x > y, throw a RangeError exception.
|
||||
if (start.as_double() > end.as_double())
|
||||
return vm.throw_completion<RangeError>(global_object, ErrorType::IntlStartRangeAfterEndRange, start, end);
|
||||
|
||||
// 7. Let xp be ! ResolvePlural(pluralRules, x).
|
||||
// 6. Let xp be ! ResolvePlural(pluralRules, x).
|
||||
auto start_plurality = resolve_plural(plural_rules, start);
|
||||
|
||||
// 8. Let yp be ! ResolvePlural(pluralRules, y).
|
||||
// 7. Let yp be ! ResolvePlural(pluralRules, y).
|
||||
auto end_plurality = resolve_plural(plural_rules, end);
|
||||
|
||||
// 9. Let locale be pluralRules.[[Locale]].
|
||||
// 8. Let locale be pluralRules.[[Locale]].
|
||||
auto const& locale = plural_rules.locale();
|
||||
|
||||
// 10. Let type be pluralRules.[[Type]].
|
||||
// 9. Let type be pluralRules.[[Type]].
|
||||
auto type = plural_rules.type();
|
||||
|
||||
// 11. Return ! PluralRuleSelectRange(locale, type, xp, yp).
|
||||
// 10. Return ! PluralRuleSelectRange(locale, type, xp, yp).
|
||||
return plural_rule_select_range(locale, type, start_plurality, end_plurality);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue