This repository was archived by the owner on Jan 10, 2025. It is now read-only.
File tree 2 files changed +12
-4
lines changed
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -5,13 +5,16 @@ var ariaAppHider = require('../helpers/ariaAppHider');
5
5
var injectCSS = require ( '../helpers/injectCSS' ) ;
6
6
7
7
var SafeHTMLElement = ExecutionEnvironment . canUseDOM ? window . HTMLElement : { } ;
8
+ var AppElement = ExecutionEnvironment . canUseDOM ? document . body : { appendChild : function ( ) { } } ;
8
9
9
10
var Modal = module . exports = React . createClass ( {
10
11
11
12
displayName : 'Modal' ,
12
13
13
14
statics : {
14
- setAppElement : ariaAppHider . setElement ,
15
+ setAppElement : function ( element ) {
16
+ AppElement = ariaAppHider . setElement ( element ) ;
17
+ } ,
15
18
injectCSS : injectCSS
16
19
} ,
17
20
@@ -46,7 +49,7 @@ var Modal = module.exports = React.createClass({
46
49
componentDidMount : function ( ) {
47
50
this . node = document . createElement ( 'div' ) ;
48
51
this . node . className = 'ReactModalPortal' ;
49
- document . body . appendChild ( this . node ) ;
52
+ AppElement . appendChild ( this . node ) ;
50
53
this . renderPortal ( this . props ) ;
51
54
} ,
52
55
@@ -56,7 +59,7 @@ var Modal = module.exports = React.createClass({
56
59
57
60
componentWillUnmount : function ( ) {
58
61
React . unmountComponentAtNode ( this . node ) ;
59
- document . body . removeChild ( this . node ) ;
62
+ AppElement . removeChild ( this . node ) ;
60
63
} ,
61
64
62
65
renderPortal : function ( props ) {
Original file line number Diff line number Diff line change 1
1
var _element = null ;
2
2
3
3
function setElement ( element ) {
4
- _element = element ;
4
+ if ( typeof element === 'string' ) {
5
+ var el = document . querySelectorAll ( element ) ;
6
+ element = 'length' in el ? el [ 0 ] : el ;
7
+ }
8
+ _element = element || _element ;
9
+ return _element ;
5
10
}
6
11
7
12
function hide ( appElement ) {
You can’t perform that action at this time.
0 commit comments