1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:07:45 +00:00

LibJS: Allow undefined for calendar in MaybeFormatCalendarAnnotation

This is an editorial change in the Temporal spec.

Now that this is spec'd as either an Object or undefined, we can change
the parameter type from arbitrary JS::Value to JS::Object*.

See: cdfcffd
This commit is contained in:
Linus Groh 2022-08-25 22:34:18 +01:00
parent 741cc08221
commit 36225c0ae7
5 changed files with 11 additions and 8 deletions

View file

@ -503,16 +503,19 @@ ThrowCompletionOr<PlainMonthDay*> calendar_month_day_from_fields(VM& vm, Object&
}
// 12.2.26 MaybeFormatCalendarAnnotation ( calendarObject, showCalendar ), https://tc39.es/proposal-temporal/#sec-temporal-maybeformatcalendarannotation
ThrowCompletionOr<String> maybe_format_calendar_annotation(VM& vm, Value calendar_object, StringView show_calendar)
ThrowCompletionOr<String> maybe_format_calendar_annotation(VM& vm, Object const* calendar_object, StringView show_calendar)
{
// 1. If showCalendar is "never", return the empty String.
if (show_calendar == "never"sv)
return String::empty();
// 2. Let calendarID be ? ToString(calendarObject).
auto calendar_id = TRY(calendar_object.to_string(vm));
// 2. Assert: Type(calendarObject) is Object.
VERIFY(calendar_object);
// 3. Return FormatCalendarAnnotation(calendarID, showCalendar).
// 3. Let calendarID be ? ToString(calendarObject).
auto calendar_id = TRY(Value(calendar_object).to_string(vm));
// 4. Return FormatCalendarAnnotation(calendarID, showCalendar).
return format_calendar_annotation(calendar_id, show_calendar);
}