mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 08:08:43 +00:00
LibJS: Make removed elements in Array.prototype.splice spec compliant
It wasn't using has_property, was directly appending to indexed properties and wasn't setting the length.
This commit is contained in:
parent
bc540de0af
commit
00a83a2957
Notes:
sideshowbarker
2024-07-18 12:30:15 +09:00
Author: https://github.com/Lubrsi
Commit: 00a83a2957
Pull-request: https://github.com/SerenityOS/serenity/pull/7963
Reviewed-by: https://github.com/linusg
1 changed files with 15 additions and 2 deletions
|
@ -905,13 +905,26 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::splice)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
for (size_t i = 0; i < actual_delete_count; ++i) {
|
for (size_t i = 0; i < actual_delete_count; ++i) {
|
||||||
auto value = this_object->get(actual_start + i);
|
auto from = actual_start + i;
|
||||||
|
bool from_present = this_object->has_property(from);
|
||||||
if (vm.exception())
|
if (vm.exception())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
removed_elements->indexed_properties().append(value);
|
if (from_present) {
|
||||||
|
auto from_value = this_object->get(actual_start + i);
|
||||||
|
if (vm.exception())
|
||||||
|
return {};
|
||||||
|
|
||||||
|
removed_elements->define_property(i, from_value);
|
||||||
|
if (vm.exception())
|
||||||
|
return {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removed_elements->put(vm.names.length, Value(actual_delete_count));
|
||||||
|
if (vm.exception())
|
||||||
|
return {};
|
||||||
|
|
||||||
if (insert_count < actual_delete_count) {
|
if (insert_count < actual_delete_count) {
|
||||||
for (size_t i = actual_start; i < initial_length - actual_delete_count; ++i) {
|
for (size_t i = actual_start; i < initial_length - actual_delete_count; ++i) {
|
||||||
auto from = this_object->get(i + actual_delete_count);
|
auto from = this_object->get(i + actual_delete_count);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue