1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:18:12 +00:00

LibJS: Bring ArrayCreate and ArrayConstructor closer to spec

Specifically, this now explicitly takes the length, adds missing
exceptions checks to calls with user-supplied lengths, takes and uses
the prototype argument, and fixes some spec non-conformance in
ArrayConstructor and its native functions around the use of ArrayCreate
This commit is contained in:
Idan Horowitz 2021-07-04 01:36:44 +03:00 committed by Linus Groh
parent 5ee1ae37b2
commit e480d69130
17 changed files with 172 additions and 96 deletions

View file

@ -297,7 +297,7 @@ MarkedValueList Object::get_own_properties(PropertyKind kind, bool only_enumerab
} else if (kind == PropertyKind::Value) {
properties.append(js_string(vm(), String::formatted("{:c}", str[i])));
} else {
auto* entry_array = Array::create(global_object());
auto* entry_array = Array::create(global_object(), 0);
entry_array->define_property(0, js_string(vm(), String::number(i)));
entry_array->define_property(1, js_string(vm(), String::formatted("{:c}", str[i])));
properties.append(entry_array);
@ -318,7 +318,7 @@ MarkedValueList Object::get_own_properties(PropertyKind kind, bool only_enumerab
} else if (kind == PropertyKind::Value) {
properties.append(value_and_attributes.value);
} else {
auto* entry_array = Array::create(global_object());
auto* entry_array = Array::create(global_object(), 0);
entry_array->define_property(0, js_string(vm(), String::number(entry.index())));
entry_array->define_property(1, value_and_attributes.value);
properties.append(entry_array);
@ -341,7 +341,7 @@ MarkedValueList Object::get_own_properties(PropertyKind kind, bool only_enumerab
if (val.is_empty())
return;
auto* entry_array = Array::create(global_object());
auto* entry_array = Array::create(global_object(), 0);
entry_array->define_property(0, property.key.to_value(vm()));
entry_array->define_property(1, val);
properties.append(entry_array);