mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 08:10:02 +00:00
LibJS: Throw a RangeError when when formatting strings in DurationFormat
This is a normative change in the Intl.DurationFormat proposal. See:
2546080
This commit is contained in:
parent
010888acec
commit
a2cf026b30
Notes:
sideshowbarker
2024-07-17 21:11:12 +09:00
Author: https://github.com/trflynn89
Commit: a2cf026b30
Pull-request: https://github.com/SerenityOS/serenity/pull/16501
Reviewed-by: https://github.com/davidot ✅
3 changed files with 19 additions and 4 deletions
|
@ -134,9 +134,16 @@ StringView DurationFormat::display_to_string(Display display)
|
|||
// 1.1.3 ToDurationRecord ( input ), https://tc39.es/proposal-intl-duration-format/#sec-todurationrecord
|
||||
ThrowCompletionOr<Temporal::DurationRecord> to_duration_record(VM& vm, Value input)
|
||||
{
|
||||
// 1. If Type(input) is not Object, throw a TypeError exception.
|
||||
if (!input.is_object())
|
||||
// 1. If Type(input) is not Object, then
|
||||
if (!input.is_object()) {
|
||||
// a. If Type(input) is String, throw a RangeError exception.
|
||||
if (input.is_string())
|
||||
return vm.throw_completion<RangeError>(ErrorType::NotAnObject, input);
|
||||
|
||||
// b. Throw a TypeError exception.
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObject, input);
|
||||
}
|
||||
|
||||
auto& input_object = input.as_object();
|
||||
|
||||
// 2. Let result be a new Duration Record with each field set to 0.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue