1
1
'use strict' ;
2
2
3
- var _createClass = ( function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ) ( ) ;
3
+ var _typeof = typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ? function ( obj ) { return typeof obj ; } : function ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol ? "symbol" : typeof obj ; } ;
4
+
5
+ var _createClass = function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ( ) ;
4
6
5
7
Object . defineProperty ( exports , "__esModule" , {
6
8
value : true
7
9
} ) ;
8
- exports . RenderInBody = undefined ;
9
10
10
11
var _react = require ( 'react' ) ;
11
12
@@ -23,30 +24,73 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
23
24
24
25
function _inherits ( subClass , superClass ) { if ( typeof superClass !== "function" && superClass !== null ) { throw new TypeError ( "Super expression must either be null or a function, not " + typeof superClass ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , enumerable : false , writable : true , configurable : true } } ) ; if ( superClass ) Object . setPrototypeOf ? Object . setPrototypeOf ( subClass , superClass ) : subClass . __proto__ = superClass ; }
25
26
26
- var RenderInBody = exports . RenderInBody = function RenderInBody ( ComposedComponent ) {
27
+ var RenderInBody = function ( _Component ) {
28
+ _inherits ( RenderInBody , _Component ) ;
29
+
30
+ function RenderInBody ( ) {
31
+ _classCallCheck ( this , RenderInBody ) ;
32
+
33
+ return _possibleConstructorReturn ( this , Object . getPrototypeOf ( RenderInBody ) . apply ( this , arguments ) ) ;
34
+ }
35
+
36
+ _createClass ( RenderInBody , [ {
37
+ key : 'componentDidMount' ,
38
+ value : function componentDidMount ( ) {
39
+ this . child = document . createElement ( "div" ) ;
40
+ document . body . appendChild ( this . child ) ;
41
+ this . _renderLayer ( ) ;
42
+ }
43
+ } , {
44
+ key : 'componentDidUpdate' ,
45
+ value : function componentDidUpdate ( ) {
46
+ this . _renderLayer ( ) ;
47
+ }
48
+ } , {
49
+ key : 'componentWillUnmount' ,
50
+ value : function componentWillUnmount ( ) {
51
+ _react2 . default . unmountComponentAtNode ( this . child ) ;
52
+ document . body . removeChild ( this . child ) ;
53
+ }
54
+ } , {
55
+ key : '_renderLayer' ,
56
+ value : function _renderLayer ( ) {
57
+ _reactDom2 . default . render ( this . props . children , this . child ) ;
58
+ }
59
+ } , {
60
+ key : 'render' ,
61
+ value : function render ( ) {
62
+ // Render a placeholder
63
+ return _react2 . default . DOM . div ( ) ;
64
+ }
65
+ } ] ) ;
66
+
67
+ return RenderInBody ;
68
+ } ( _react . Component ) ;
69
+
70
+ var decorateRenderInBody = function decorateRenderInBody ( ComposedComponent ) {
27
71
var options = arguments . length <= 1 || arguments [ 1 ] === undefined ? { } : arguments [ 1 ] ;
28
72
29
- return ( function ( _Component ) {
30
- _inherits ( _class2 , _Component ) ;
73
+ return function ( _Component2 ) {
74
+ _inherits ( _class2 , _Component2 ) ;
31
75
32
76
function _class2 ( ) {
33
77
var _Object$getPrototypeO ;
34
78
35
- var _temp , _this , _ret ;
79
+ var _temp , _this2 , _ret ;
36
80
37
81
_classCallCheck ( this , _class2 ) ;
38
82
39
83
for ( var _len = arguments . length , args = Array ( _len ) , _key = 0 ; _key < _len ; _key ++ ) {
40
84
args [ _key ] = arguments [ _key ] ;
41
85
}
42
86
43
- return _ret = ( _temp = ( _this = _possibleConstructorReturn ( this , ( _Object$getPrototypeO = Object . getPrototypeOf ( _class2 ) ) . call . apply ( _Object$getPrototypeO , [ this ] . concat ( args ) ) ) , _this ) , _this . child = null , _temp ) , _possibleConstructorReturn ( _this , _ret ) ;
87
+ return _ret = ( _temp = ( _this2 = _possibleConstructorReturn ( this , ( _Object$getPrototypeO = Object . getPrototypeOf ( _class2 ) ) . call . apply ( _Object$getPrototypeO , [ this ] . concat ( args ) ) ) , _this2 ) , _this2 . child = null , _temp ) , _possibleConstructorReturn ( _this2 , _ret ) ;
44
88
}
45
89
46
90
_createClass ( _class2 , [ {
47
91
key : 'componentDidMount' ,
48
92
value : function componentDidMount ( ) {
49
- this . child = document . createElement ( " div" ) ;
93
+ this . child = document . createElement ( ' div' ) ;
50
94
document . body . appendChild ( this . child ) ;
51
95
this . _renderLayer ( ) ;
52
96
}
@@ -75,7 +119,24 @@ var RenderInBody = exports.RenderInBody = function RenderInBody(ComposedComponen
75
119
} ] ) ;
76
120
77
121
return _class2 ;
78
- } ) ( _react . Component ) ;
122
+ } ( _react . Component ) ;
123
+ } ;
124
+
125
+ var _RenderInBody = function _RenderInBody ( element ) {
126
+ var options = arguments . length <= 1 || arguments [ 1 ] === undefined ? { } : arguments [ 1 ] ;
127
+
128
+ switch ( typeof element === 'undefined' ? 'undefined' : _typeof ( element ) ) {
129
+ case 'object' :
130
+ return _react2 . default . createElement (
131
+ RenderInBody ,
132
+ null ,
133
+ element . children
134
+ ) ;
135
+ case 'function' :
136
+ return decorateRenderInBody ( element ) ;
137
+ default :
138
+ return ;
139
+ }
79
140
} ;
80
141
81
- exports . default = RenderInBody ;
142
+ exports . default = _RenderInBody ;
0 commit comments