@@ -65,6 +65,16 @@ export default () => {
6565 ReactDOM . unmountComponentAtNode ( node ) ;
6666 } ) ;
6767
68+ it ( "accepts array of appElement as a prop" , ( ) => {
69+ const el1 = document . createElement ( "div" ) ;
70+ const el2 = document . createElement ( "div" ) ;
71+ const node = document . createElement ( "div" ) ;
72+ ReactDOM . render ( < Modal isOpen = { true } appElement = { [ el1 , el2 ] } /> , node ) ;
73+ el1 . getAttribute ( "aria-hidden" ) . should . be . eql ( "true" ) ;
74+ el2 . getAttribute ( "aria-hidden" ) . should . be . eql ( "true" ) ;
75+ ReactDOM . unmountComponentAtNode ( node ) ;
76+ } ) ;
77+
6878 it ( "renders into the body, not in context" , ( ) => {
6979 const node = document . createElement ( "div" ) ;
7080 class App extends Component {
@@ -108,6 +118,36 @@ export default () => {
108118 ReactDOM . unmountComponentAtNode ( node ) ;
109119 } ) ;
110120
121+ // eslint-disable-next-line max-len
122+ it ( "allow setting appElement of type string matching multiple elements" , ( ) => {
123+ const el1 = document . createElement ( "div" ) ;
124+ el1 . id = "id1" ;
125+ document . body . appendChild ( el1 ) ;
126+ const el2 = document . createElement ( "div" ) ;
127+ el2 . id = "id2" ;
128+ document . body . appendChild ( el2 ) ;
129+ const node = document . createElement ( "div" ) ;
130+ class App extends Component {
131+ render ( ) {
132+ return (
133+ < div >
134+ < Modal isOpen >
135+ < span > hello</ span >
136+ </ Modal >
137+ </ div >
138+ ) ;
139+ }
140+ }
141+ const appElement = "#id1, #id2" ;
142+ Modal . setAppElement ( appElement ) ;
143+ ReactDOM . render ( < App /> , node ) ;
144+ el1 . getAttribute ( "aria-hidden" ) . should . be . eql ( "true" ) ;
145+ el2 . getAttribute ( "aria-hidden" ) . should . be . eql ( "true" ) ;
146+ ReactDOM . unmountComponentAtNode ( node ) ;
147+ document . body . removeChild ( el1 ) ;
148+ document . body . removeChild ( el2 ) ;
149+ } ) ;
150+
111151 it ( "default parentSelector should be document.body." , ( ) => {
112152 const modal = renderModal ( { isOpen : true } ) ;
113153 modal . props . parentSelector ( ) . should . be . eql ( document . body ) ;
0 commit comments