mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:27:35 +00:00
LibJS: Handle NumberFormat's [[UseGrouping]] option for "true" / "false"
This is a normative change to the Intl NumberFormat V3 spec. See:
4751da5
This commit is contained in:
parent
9743849ddb
commit
887dac0929
3 changed files with 24 additions and 7 deletions
|
@ -633,12 +633,17 @@ ThrowCompletionOr<StringOrBoolean> get_string_or_boolean_option(VM& vm, Object c
|
|||
// 6. Let value be ? ToString(value).
|
||||
auto value_string = TRY(value.to_string(vm));
|
||||
|
||||
// 7. If values does not contain an element equal to value, return fallback.
|
||||
auto it = find(values.begin(), values.end(), value_string);
|
||||
if (it == values.end())
|
||||
// 7. NOTE: For historical reasons, the strings "true" and "false" are treated the same as the boolean value true.
|
||||
// 8. If value is "true" or "false", return fallback.
|
||||
if (value_string.is_one_of("true"sv, "false"sv))
|
||||
return fallback;
|
||||
|
||||
// 8. Return value.
|
||||
// 9. If values does not contain an element equal to value, throw a RangeError exception.
|
||||
auto it = find(values.begin(), values.end(), value_string);
|
||||
if (it == values.end())
|
||||
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, value_string, property.as_string());
|
||||
|
||||
// 10. Return value.
|
||||
return StringOrBoolean { *it };
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue