mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-07 00:29:47 +00:00
LibJS: Ensure relevant extension keys are included in ICU locale data
This is a normative change in the ECMA-402 spec. See:
7508197
In our implementation, we don't have the affected AOs directly, as we
delegate to ICU. So instead, we must ensure we provide ICU a locale with
the relevant extension keys present.
This commit is contained in:
parent
37b8ba96f1
commit
00d00b84d3
Notes:
github-actions[bot]
2025-03-18 15:48:22 +00:00
Author: https://github.com/trflynn89
Commit: 00d00b84d3
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3980
17 changed files with 82 additions and 67 deletions
|
@ -500,6 +500,8 @@ ResolvedLocale resolve_locale(ReadonlySpan<String> requested_locales, LocaleOpti
|
|||
// 12. Let supportedKeywords be a new empty List.
|
||||
Vector<Unicode::Keyword> supported_keywords;
|
||||
|
||||
Vector<Unicode::Keyword> icu_keywords;
|
||||
|
||||
// 13. For each element key of relevantExtensionKeys, do
|
||||
for (auto const& key : relevant_extension_keys) {
|
||||
// a. Let keyLocaleData be foundLocaleData.[[<key>]].
|
||||
|
@ -574,10 +576,23 @@ ResolvedLocale resolve_locale(ReadonlySpan<String> requested_locales, LocaleOpti
|
|||
if (supported_keyword.has_value())
|
||||
supported_keywords.append(supported_keyword.release_value());
|
||||
|
||||
if (auto* value_string = value.get_pointer<String>())
|
||||
icu_keywords.empend(MUST(String::from_utf8(key)), *value_string);
|
||||
|
||||
// m. Set result.[[<key>]] to value.
|
||||
find_key_in_value(result, key) = move(value);
|
||||
}
|
||||
|
||||
// AD-HOC: For ICU, we need to form a locale with all relevant extension keys present.
|
||||
if (icu_keywords.is_empty()) {
|
||||
result.icu_locale = found_locale;
|
||||
} else {
|
||||
auto locale_id = Unicode::parse_unicode_locale_id(found_locale);
|
||||
VERIFY(locale_id.has_value());
|
||||
|
||||
result.icu_locale = insert_unicode_extension_and_canonicalize(locale_id.release_value(), {}, move(icu_keywords));
|
||||
}
|
||||
|
||||
// 14. If supportedKeywords is not empty, then
|
||||
if (!supported_keywords.is_empty()) {
|
||||
auto locale_id = Unicode::parse_unicode_locale_id(found_locale);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue