@@ -3,67 +3,56 @@ import { get_proxied_value } from '../proxy.js';
3
3
4
4
export function init_array_prototype_warnings ( ) {
5
5
const array_prototype = Array . prototype ;
6
+ const { indexOf, lastIndexOf, includes } = array_prototype ;
6
7
7
- const original_index_of = array_prototype . indexOf ;
8
+ array_prototype . indexOf = function ( item , from_index ) {
9
+ const index = indexOf . call ( this , item , from_index ) ;
8
10
9
- array_prototype . indexOf = function ( search_element , from_index ) {
10
- const index = original_index_of . call ( this , search_element , from_index ) ;
11
11
if ( index === - 1 ) {
12
- if (
13
- original_index_of . call (
14
- get_proxied_value ( this ) ,
15
- get_proxied_value ( search_element ) ,
16
- from_index
17
- ) !== - 1
18
- ) {
12
+ const test = indexOf . call ( get_proxied_value ( this ) , get_proxied_value ( item ) , from_index ) ;
13
+
14
+ if ( test !== - 1 ) {
19
15
w . state_proxy_equality_mismatch ( 'Array.indexOf' ) ;
20
16
21
17
// eslint-disable-next-line no-console
22
18
console . trace ( ) ;
23
19
}
24
20
}
21
+
25
22
return index ;
26
23
} ;
27
24
28
- const original_last_index_of = array_prototype . lastIndexOf ;
25
+ array_prototype . lastIndexOf = function ( item , from_index ) {
26
+ const index = lastIndexOf . call ( this , item , from_index ) ;
29
27
30
- array_prototype . lastIndexOf = function ( search_element , from_index ) {
31
- const index = original_last_index_of . call ( this , search_element , from_index ) ;
32
28
if ( index === - 1 ) {
33
- if (
34
- original_last_index_of . call (
35
- get_proxied_value ( this ) ,
36
- get_proxied_value ( search_element ) ,
37
- from_index
38
- ) !== - 1
39
- ) {
29
+ const test = lastIndexOf . call ( get_proxied_value ( this ) , get_proxied_value ( item ) , from_index ) ;
30
+
31
+ if ( test !== - 1 ) {
40
32
w . state_proxy_equality_mismatch ( 'Array.lastIndexOf' ) ;
41
33
42
34
// eslint-disable-next-line no-console
43
35
console . trace ( ) ;
44
36
}
45
37
}
38
+
46
39
return index ;
47
40
} ;
48
41
49
- const original_includes = array_prototype . includes ;
42
+ array_prototype . includes = function ( item , from_index ) {
43
+ const has = includes . call ( this , item , from_index ) ;
50
44
51
- array_prototype . includes = function ( search_element , from_index ) {
52
- const has = original_includes . call ( this , search_element , from_index ) ;
53
45
if ( ! has ) {
54
- if (
55
- original_includes . call (
56
- get_proxied_value ( this ) ,
57
- get_proxied_value ( search_element ) ,
58
- from_index
59
- )
60
- ) {
46
+ const test = includes . call ( get_proxied_value ( this ) , get_proxied_value ( item ) , from_index ) ;
47
+
48
+ if ( test ) {
61
49
w . state_proxy_equality_mismatch ( 'Array.includes' ) ;
62
50
63
51
// eslint-disable-next-line no-console
64
52
console . trace ( ) ;
65
53
}
66
54
}
55
+
67
56
return has ;
68
57
} ;
69
58
}
0 commit comments