mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibJS: Make Array.prototype.lastIndexOf slightly more spec compliant
This commit is contained in:
parent
44174a44bd
commit
c7aaf40a35
Notes:
sideshowbarker
2024-07-18 11:28:52 +09:00
Author: https://github.com/davidot Commit: https://github.com/SerenityOS/serenity/commit/c7aaf40a359 Pull-request: https://github.com/SerenityOS/serenity/pull/8245
|
@ -1047,13 +1047,16 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::last_index_of)
|
|||
return Value(-1);
|
||||
i32 from_index = length - 1;
|
||||
if (vm.argument_count() >= 2) {
|
||||
from_index = vm.argument(1).to_i32(global_object);
|
||||
double from_argument = vm.argument(1).to_integer_or_infinity(global_object);
|
||||
if (vm.exception())
|
||||
return {};
|
||||
if (from_index >= 0)
|
||||
from_index = min(from_index, length - 1);
|
||||
if (vm.argument(1).is_negative_infinity()) {
|
||||
return Value(-1);
|
||||
}
|
||||
if (from_argument >= 0)
|
||||
from_index = min(from_argument, length - 1.);
|
||||
else
|
||||
from_index = length + from_index;
|
||||
from_index = length + from_argument;
|
||||
}
|
||||
auto search_element = vm.argument(0);
|
||||
for (i32 i = from_index; i >= 0; --i) {
|
||||
|
|
Loading…
Reference in a new issue