diff options
author | Yedaya Katsman <yedaya.ka@gmail.com> | 2022-10-24 23:20:44 +0300 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-10-24 23:00:19 +0100 |
commit | dcad8494d6e42bf5d2e70cdd5eedbfa2a9fc300d (patch) | |
tree | 414c5f8028f4ac40698f033b041efe395241a9dd /Userland | |
parent | b00d49bbf0354d1788f83ecaad01d52ab1184aff (diff) | |
download | serenity-dcad8494d6e42bf5d2e70cdd5eedbfa2a9fc300d.zip |
LibJS: Accept calendar names case-insensitively
This is a normative change in the Temporal spec
See tc39/proposal-temporal@03101c6
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp index 8730316d8b..3ffedb7eb8 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp @@ -37,9 +37,11 @@ bool is_builtin_calendar(String const& identifier) // 1. Let calendars be AvailableCalendars(). auto calendars = available_calendars(); - // 2. If calendars contains id, return true. - if (calendars.contains_slow(identifier)) - return true; + // 2. If calendars contains the ASCII-lowercase of id, return true. + for (auto calendar : calendars) { + if (calendar.equals_ignoring_case(identifier)) + return true; + } // 3. Return false. return false; @@ -73,8 +75,8 @@ ThrowCompletionOr<Calendar*> create_temporal_calendar(VM& vm, String const& iden new_target = realm.intrinsics().temporal_calendar_constructor(); // 3. Let object be ? OrdinaryCreateFromConstructor(newTarget, "%Temporal.Calendar.prototype%", ยซ [[InitializedTemporalCalendar]], [[Identifier]] ยป). - // 4. Set object.[[Identifier]] to identifier. - auto* object = TRY(ordinary_create_from_constructor<Calendar>(vm, *new_target, &Intrinsics::temporal_calendar_prototype, identifier)); + // 4. Set object.[[Identifier]] to the ASCII-lowercase of identifier. + auto* object = TRY(ordinary_create_from_constructor<Calendar>(vm, *new_target, &Intrinsics::temporal_calendar_prototype, identifier.to_lowercase())); // 5. Return object. return object; |