@@ -51,6 +51,7 @@ export default class ModalPortal extends Component {
5151 role : PropTypes . string ,
5252 contentLabel : PropTypes . string ,
5353 aria : PropTypes . object ,
54+ data : PropTypes . object ,
5455 children : PropTypes . node ,
5556 shouldCloseOnEsc : PropTypes . bool ,
5657 overlayRef : PropTypes . func ,
@@ -315,9 +316,9 @@ export default class ModalPortal extends Component {
315316 : className ;
316317 } ;
317318
318- ariaAttributes = items =>
319+ attributesFromObject = ( prefix , items ) =>
319320 Object . keys ( items ) . reduce ( ( acc , name ) => {
320- acc [ `aria -${ name } ` ] = items [ name ] ;
321+ acc [ `${ prefix } -${ name } ` ] = items [ name ] ;
321322 return acc ;
322323 } , { } ) ;
323324
@@ -346,8 +347,8 @@ export default class ModalPortal extends Component {
346347 onClick = { this . handleContentOnClick }
347348 role = { this . props . role }
348349 aria-label = { this . props . contentLabel }
349- { ...this . ariaAttributes ( this . props . aria || { } ) }
350- data-testid = { this . props . testId }
350+ { ...this . attributesFromObject ( "aria" , this . props . aria || { } ) }
351+ { ... this . attributesFromObject ( "data" , this . props . data || { } ) }
351352 >
352353 { this . props . children }
353354 </ div >
0 commit comments