diff options
author | Timothy Flynn <trflynn89@pm.me> | 2023-01-12 08:03:13 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-01-14 19:12:48 +0000 |
commit | d1881da2bed284ef5a7f9b9ac0d2ef8e3ffa3e65 (patch) | |
tree | 40c371e4599b2e6770fa9613042fb899d19ef920 /Userland/Libraries/LibJS/Runtime/Intl | |
parent | 9b6fcd85913a7049041de6206aaa4cfcd535591c (diff) | |
download | serenity-d1881da2bed284ef5a7f9b9ac0d2ef8e3ffa3e65.zip |
LibJS: Set approximate number range format result's "source" to "shared"
This is a normative change in the Intl.NumberFormat v3 spec. See:
https://github.com/tc39/proposal-intl-numberformat-v3/commit/7510e7f
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Intl')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp index f7879d8491..d955a6fcfd 100644 --- a/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp +++ b/Userland/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, Tim Flynn <trflynn89@serenityos.org> + * Copyright (c) 2021-2023, Tim Flynn <trflynn89@serenityos.org> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -1744,9 +1744,20 @@ ThrowCompletionOr<Vector<PatternPartitionWithSource>> partition_number_range_pat auto raw_end_result = partition_number_pattern(vm, number_format, move(end)); auto end_result = PatternPartitionWithSource::create_from_parent_list(move(raw_end_result)); - // 5. If xResult is equal to yResult, return FormatApproximately(numberFormat, xResult). - if (start_result == end_result) - return format_approximately(number_format, move(start_result)); + // 5. If xResult is equal to yResult, then + if (start_result == end_result) { + // a. Let appxResult be ? FormatApproximately(numberFormat, xResult). + auto approximate_result = format_approximately(number_format, move(start_result)); + + // b. For each r in appxResult, do + for (auto& result : approximate_result) { + // i. Set r.[[Source]] to "shared". + result.source = "shared"sv; + } + + // c. Return appxResult. + return approximate_result; + } // 6. For each r in xResult, do for (auto& part : start_result) { |