From: Igor Sysoev Date: Tue, 18 Oct 2016 14:44:01 +0000 (+0300) Subject: Array.indexOf() and Array.lastIndexOf() have been fixed. X-Git-Tag: 0.1.4~6 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=f902d0a2af24c9a0e59cf8bf5a710b4057e5ec50;p=njs.git Array.indexOf() and Array.lastIndexOf() have been fixed. --- diff --git a/njs/njs_array.c b/njs/njs_array.c index 3b8fe885..149798d9 100644 --- a/njs/njs_array.c +++ b/njs/njs_array.c @@ -996,7 +996,7 @@ njs_array_index_of(njs_vm_t *vm, njs_value_t *args, nxt_uint_t nargs, index = -1; - if (nargs > 1) { + if (nargs > 1 && njs_is_array(&args[0])) { i = 0; array = args[0].data.u.array; length = array->length; diff --git a/njs/test/njs_unit_test.c b/njs/test/njs_unit_test.c index 5ffee20f..322a09dc 100644 --- a/njs/test/njs_unit_test.c +++ b/njs/test/njs_unit_test.c @@ -2359,6 +2359,9 @@ static njs_unit_test_t njs_test[] = { nxt_string("var a = [1,2,3,4,3,4]; a.indexOf(3, -10)"), nxt_string("2") }, + { nxt_string("[].indexOf.bind(0)(0, 0)"), + nxt_string("-1") }, + { nxt_string("var a = [1,2,3,4]; a.lastIndexOf()"), nxt_string("-1") },