@@ -12,28 +12,25 @@ export function selectOptions(
12
12
this : UserEvent ,
13
13
select : Element ,
14
14
values : HTMLElement | HTMLElement [ ] | string [ ] | string ,
15
- init ?: MouseEventInit ,
16
15
options : PointerOptions = { } ,
17
16
) {
18
- return selectOptionsBase . call ( this , true , select , values , init , options )
17
+ return selectOptionsBase . call ( this , true , select , values , options )
19
18
}
20
19
21
20
export function deselectOptions (
22
21
this : UserEvent ,
23
22
select : Element ,
24
23
values : HTMLElement | HTMLElement [ ] | string [ ] | string ,
25
- init ?: MouseEventInit ,
26
24
options : PointerOptions = { } ,
27
25
) {
28
- return selectOptionsBase . call ( this , false , select , values , init , options )
26
+ return selectOptionsBase . call ( this , false , select , values , options )
29
27
}
30
28
31
29
function selectOptionsBase (
32
30
this : UserEvent ,
33
31
newValue : boolean ,
34
32
select : Element ,
35
33
values : HTMLElement | HTMLElement [ ] | string [ ] | string ,
36
- init : MouseEventInit | undefined ,
37
34
{ skipPointerEventsCheck} : PointerOptions ,
38
35
) {
39
36
if ( ! newValue && ! ( select as HTMLSelectElement ) . multiple ) {
@@ -79,27 +76,27 @@ function selectOptionsBase(
79
76
80
77
// events fired for multiple select are weird. Can't use hover...
81
78
if ( withPointerEvents ) {
82
- fireEvent . pointerOver ( option , init )
83
- fireEvent . pointerEnter ( select , init )
79
+ fireEvent . pointerOver ( option )
80
+ fireEvent . pointerEnter ( select )
84
81
fireEvent . mouseOver ( option )
85
82
fireEvent . mouseEnter ( select )
86
- fireEvent . pointerMove ( option , init )
87
- fireEvent . mouseMove ( option , init )
88
- fireEvent . pointerDown ( option , init )
89
- fireEvent . mouseDown ( option , init )
83
+ fireEvent . pointerMove ( option )
84
+ fireEvent . mouseMove ( option )
85
+ fireEvent . pointerDown ( option )
86
+ fireEvent . mouseDown ( option )
90
87
}
91
88
92
89
focus ( select )
93
90
94
91
if ( withPointerEvents ) {
95
- fireEvent . pointerUp ( option , init )
96
- fireEvent . mouseUp ( option , init )
92
+ fireEvent . pointerUp ( option )
93
+ fireEvent . mouseUp ( option )
97
94
}
98
95
99
96
selectOption ( option as HTMLOptionElement )
100
97
101
98
if ( withPointerEvents ) {
102
- fireEvent . click ( option , init )
99
+ fireEvent . click ( option )
103
100
}
104
101
}
105
102
} else if ( selectedOptions . length === 1 ) {
@@ -108,7 +105,7 @@ function selectOptionsBase(
108
105
: hasPointerEvents ( select )
109
106
// the click to open the select options
110
107
if ( withPointerEvents ) {
111
- this . click ( select , init , { skipPointerEventsCheck : true } )
108
+ this . click ( select , { skipPointerEventsCheck : true } )
112
109
} else {
113
110
focus ( select )
114
111
}
@@ -118,13 +115,13 @@ function selectOptionsBase(
118
115
if ( withPointerEvents ) {
119
116
// the browser triggers another click event on the select for the click on the option
120
117
// this second click has no 'down' phase
121
- fireEvent . pointerOver ( select , init )
122
- fireEvent . pointerEnter ( select , init )
118
+ fireEvent . pointerOver ( select )
119
+ fireEvent . pointerEnter ( select )
123
120
fireEvent . mouseOver ( select )
124
121
fireEvent . mouseEnter ( select )
125
- fireEvent . pointerUp ( select , init )
126
- fireEvent . mouseUp ( select , init )
127
- fireEvent . click ( select , init )
122
+ fireEvent . pointerUp ( select )
123
+ fireEvent . mouseUp ( select )
124
+ fireEvent . click ( select )
128
125
}
129
126
} else {
130
127
throw getConfig ( ) . getElementError (
@@ -134,9 +131,9 @@ function selectOptionsBase(
134
131
}
135
132
} else if ( select . getAttribute ( 'role' ) === 'listbox' ) {
136
133
selectedOptions . forEach ( option => {
137
- this . hover ( option , init , { skipPointerEventsCheck} )
138
- this . click ( option , init , { skipPointerEventsCheck} )
139
- this . unhover ( option , init , { skipPointerEventsCheck} )
134
+ this . hover ( option , { skipPointerEventsCheck} )
135
+ this . click ( option , { skipPointerEventsCheck} )
136
+ this . unhover ( option , { skipPointerEventsCheck} )
140
137
} )
141
138
} else {
142
139
throw getConfig ( ) . getElementError (
@@ -153,9 +150,8 @@ function selectOptionsBase(
153
150
bubbles : true ,
154
151
cancelable : false ,
155
152
composed : true ,
156
- ...init ,
157
153
} ) ,
158
154
)
159
- fireEvent . change ( select , init )
155
+ fireEvent . change ( select )
160
156
}
161
157
}
0 commit comments