File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
packages/browser/src/client/tester/expect Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -66,13 +66,16 @@ export default function toHaveFormValues(
6666// Returns the combined value of several elements that have the same name
6767// e.g. radio buttons or groups of checkboxes
6868function getMultiElementValue ( elements : HTMLInputElement [ ] ) {
69- const types = [ ...new Set ( elements . map ( element => element . type ) ) ]
70- if ( types . length !== 1 ) {
71- throw new Error (
72- 'Multiple form elements with the same name must be of the same type' ,
73- )
69+ let type = ''
70+ for ( const element of elements ) {
71+ if ( type && type !== element . type ) {
72+ throw new Error (
73+ 'Multiple form elements with the same name must be of the same type' ,
74+ )
75+ }
76+ type = element . type
7477 }
75- switch ( types [ 0 ] ) {
78+ switch ( type ) {
7679 case 'radio' : {
7780 const selected = elements . find ( radio => radio . checked )
7881 return selected ? selected . value : undefined
You can’t perform that action at this time.
0 commit comments