1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 21:47:46 +00:00

LibJS: Fix Array.prototype.indexOf fromIndex negative

If negative fromIndex considers displacement from the end of the array
without decreasing 1 of de size.
This commit is contained in:
Kesse Jones 2020-04-22 08:45:26 -03:00 committed by Andreas Kling
parent edd8abc4cf
commit 6d308113b8
2 changed files with 4 additions and 1 deletions

View file

@ -321,7 +321,7 @@ Value ArrayPrototype::index_of(Interpreter& interpreter)
if (from_index < negative_min_index)
from_index = 0;
else if (from_index < 0)
from_index = (array_size - 1) + from_index;
from_index = array_size + from_index;
}
auto search_element = interpreter.argument(0);