mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:28:11 +00:00
LibJS: Convert CanonicalNumericIndexString to use NumberToString
This commit is contained in:
parent
9a5a4302d9
commit
36d72a7f4c
5 changed files with 14 additions and 13 deletions
|
@ -1169,7 +1169,7 @@ Object* create_mapped_arguments_object(VM& vm, FunctionObject& function, Vector<
|
|||
}
|
||||
|
||||
// 7.1.21 CanonicalNumericIndexString ( argument ), https://tc39.es/ecma262/#sec-canonicalnumericindexstring
|
||||
CanonicalIndex canonical_numeric_index_string(PropertyKey const& property_key, CanonicalIndexMode mode)
|
||||
ThrowCompletionOr<CanonicalIndex> canonical_numeric_index_string(VM& vm, PropertyKey const& property_key, CanonicalIndexMode mode)
|
||||
{
|
||||
// NOTE: If the property name is a number type (An implementation-defined optimized
|
||||
// property key type), it can be treated as a string property that has already been
|
||||
|
@ -1219,11 +1219,10 @@ CanonicalIndex canonical_numeric_index_string(PropertyKey const& property_key, C
|
|||
auto maybe_double = argument.to_double(AK::TrimWhitespace::No);
|
||||
if (!maybe_double.has_value())
|
||||
return CanonicalIndex(CanonicalIndex::Type::Undefined, 0);
|
||||
auto double_value = Value(maybe_double.value());
|
||||
|
||||
// FIXME: We return 0 instead of n but it might not observable?
|
||||
// 3. If SameValue(! ToString(n), argument) is true, return n.
|
||||
if (double_value.to_deprecated_string_without_side_effects() == argument)
|
||||
if (TRY_OR_THROW_OOM(vm, number_to_string(*maybe_double)) == argument.view())
|
||||
return CanonicalIndex(CanonicalIndex::Type::Numeric, 0);
|
||||
|
||||
// 4. Return undefined.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue