mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +00:00
LibJS: Do not trim whitespace from property names when they're numbers
Fixes #7803.
This commit is contained in:
parent
3abcfcc178
commit
c5073cb287
2 changed files with 8 additions and 1 deletions
|
@ -111,7 +111,7 @@ public:
|
||||||
bool try_coerce_into_number()
|
bool try_coerce_into_number()
|
||||||
{
|
{
|
||||||
VERIFY(m_string_may_be_number);
|
VERIFY(m_string_may_be_number);
|
||||||
i32 property_index = m_string.to_int().value_or(-1);
|
i32 property_index = m_string.to_int(TrimWhitespace::No).value_or(-1);
|
||||||
if (property_index < 0) {
|
if (property_index < 0) {
|
||||||
m_string_may_be_number = false;
|
m_string_may_be_number = false;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
test("indexing the array doesn't strip whitespace if it's a number", () => {
|
||||||
|
var a = [];
|
||||||
|
a[1] = 1;
|
||||||
|
|
||||||
|
expect(a["1"]).toBe(1);
|
||||||
|
expect(a[" 1 "]).toBeUndefined();
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue