diff options
author | Luke Wilde <lukew@serenityos.org> | 2021-12-08 18:59:13 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-12-08 19:11:50 +0000 |
commit | 4f3c283f24145d70a0c92d6f5c34638e9bbcf943 (patch) | |
tree | 7d30b24b103ebb707906cbea649a7dc8ba5ac2ae | |
parent | 80dcddaceab01582ceb033ec4a649842b100d9bd (diff) | |
download | serenity-4f3c283f24145d70a0c92d6f5c34638e9bbcf943.zip |
LibJS: Move calendar validation out of parse_temporal_calendar_string
This is an editorial change in the Temporal spec.
See: https://github.com/tc39/proposal-temporal/commit/7207a1c
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp | 6 |
2 files changed, 6 insertions, 8 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp index 5f20ab2ab6..2f67c61146 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp @@ -1262,13 +1262,7 @@ ThrowCompletionOr<String> parse_temporal_calendar_string(GlobalObject& global_ob return "iso8601"sv; } - // 5. If ! IsBuiltinCalendar(id) is false, then - if (!is_builtin_calendar(*id_part)) { - // a. Throw a RangeError exception. - return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarIdentifier, *id_part); - } - - // 6. Return id. + // 5. Return id. return id_part.value(); } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp index 6d61d702a6..0745f86a00 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp @@ -407,8 +407,12 @@ ThrowCompletionOr<Object*> to_temporal_calendar(GlobalObject& global_object, Val // 3. If ! IsBuiltinCalendar(identifier) is false, then if (!is_builtin_calendar(identifier)) { - // a. Let identifier be ? ParseTemporalCalendarString(identifier). + // a. Set identifier to ? ParseTemporalCalendarString(identifier). identifier = TRY(parse_temporal_calendar_string(global_object, identifier)); + + // b. If ! IsBuiltinCalendar(identifier) is false, throw a RangeError exception. + if (!is_builtin_calendar(identifier)) + return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarIdentifier, identifier); } // 4. Return ! CreateTemporalCalendar(identifier). |