From 822e32eb117b92609d5727c3226a441deaf71d7e Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 12 Jan 2023 10:53:04 -0500 Subject: [PATCH] LibJS: Reword and reorder some steps of the Intl ResolveLocale AO This is an editorial change in the ECMA-402 spec. See: https://github.com/tc39/ecma402/commit/4c55823 --- .../LibJS/Runtime/Intl/AbstractOperations.cpp | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp index 3bf7d278b0..2248532467 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/AbstractOperations.cpp @@ -489,32 +489,29 @@ ThrowCompletionOr resolve_locale(Vector const& r } } - // iv. If keyLocaleData contains optionsValue, then - if (options_value.has_value() && key_locale_data.contains_slow(*options_value)) { - // 1. If SameValue(optionsValue, value) is false, then - if (options_value != value) { - // a. Let value be optionsValue. - value = move(options_value); + // iv. If SameValue(optionsValue, value) is false and keyLocaleData contains optionsValue, then + if (options_value.has_value() && (options_value != value) && key_locale_data.contains_slow(*options_value)) { + // 1. Let value be optionsValue. + value = move(options_value); - // b. Let supportedExtensionAddition be "". - supported_extension_addition.clear(); - } + // 2. Let supportedExtensionAddition be "". + supported_extension_addition.clear(); } // j. Set result.[[]] to value. find_key_in_value(result, key) = move(value); - // k. Append supportedExtensionAddition to supportedExtension. + // k. Set supportedExtension to the string-concatenation of supportedExtension and supportedExtensionAddition. if (supported_extension_addition.has_value()) supported_extension.keywords.append(supported_extension_addition.release_value()); } - // 10. If the number of elements in supportedExtension is greater than 2, then + // 10. If supportedExtension is not "-u", then if (!supported_extension.keywords.is_empty()) { auto locale_id = ::Locale::parse_unicode_locale_id(found_locale); VERIFY(locale_id.has_value()); - // a. Let foundLocale be InsertUnicodeExtensionAndCanonicalize(foundLocale, supportedExtension). + // a. Set foundLocale to InsertUnicodeExtensionAndCanonicalize(foundLocale, supportedExtension). found_locale = insert_unicode_extension_and_canonicalize(locale_id.release_value(), move(supported_extension)); }