mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:57:45 +00:00
LibJS: Populate roundingPriority in Intl.PluralRules.resolvedOptions
This is inherited from Intl.NumberFormat.
This commit is contained in:
parent
33698b9615
commit
cd4ee46b70
3 changed files with 47 additions and 1 deletions
|
@ -76,6 +76,7 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::select_range)
|
|||
}
|
||||
|
||||
// 16.3.4 Intl.PluralRules.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.resolvedoptions
|
||||
// 1.4.5 Intl.PluralRules.prototype.resolvedOptions ( ), https://tc39.es/proposal-intl-numberformat-v3/out/pluralrules/proposed.html#sec-intl.pluralrules.prototype.resolvedoptions
|
||||
JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::resolved_options)
|
||||
{
|
||||
// 1. Let pr be the this value.
|
||||
|
@ -112,7 +113,25 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::resolved_options)
|
|||
// 6. Perform ! CreateDataProperty(options, "pluralCategories", CreateArrayFromList(pluralCategories)).
|
||||
MUST(options->create_data_property_or_throw(vm.names.pluralCategories, plural_categories));
|
||||
|
||||
// 7. Return options.
|
||||
switch (plural_rules->rounding_type()) {
|
||||
// 7. If pr.[[RoundingType]] is morePrecision, then
|
||||
case NumberFormatBase::RoundingType::MorePrecision:
|
||||
// a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "morePrecision").
|
||||
MUST(options->create_data_property_or_throw(vm.names.roundingPriority, js_string(vm, "morePrecision"sv)));
|
||||
break;
|
||||
// 8. Else if pr.[[RoundingType]] is lessPrecision, then
|
||||
case NumberFormatBase::RoundingType::LessPrecision:
|
||||
// a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "lessPrecision").
|
||||
MUST(options->create_data_property_or_throw(vm.names.roundingPriority, js_string(vm, "lessPrecision"sv)));
|
||||
break;
|
||||
// 9. Else,
|
||||
default:
|
||||
// a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "auto").
|
||||
MUST(options->create_data_property_or_throw(vm.names.roundingPriority, js_string(vm, "auto"sv)));
|
||||
break;
|
||||
}
|
||||
|
||||
// 10. Return options.
|
||||
return options;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue