const isRadio = ( node ) : node is HTMLInputElement => node . tagName === 'INPUT' && node . type === 'radio' ; const findSelectedRadio = ( node , nodes ) => nodes . filter ( isRadio ) . filter ( ( el ) => el . name === node . name ) . filter ( ( el ) => el . checked ) [ 0 ] || node ; export const correctNode = ( node , nodes ) => { if ( isRadio ( node ) && node . name ) { return findSelectedRadio ( node , nodes ) ; } return node ; } ; param nodes export const correctNodes = ( nodes ) => { const resultSet = new Set ( ) ; nodes . forEach ( ( node ) => resultSet . add ( correctNode ( node , nodes ) ) ) ; return nodes . filter ( ( node ) => resultSet . has ( node ) ) ; } ;