3
3
4
4
// module React
5
5
6
- exports . getProps = function ( ctx ) {
7
- return function ( ) {
8
- return ctx . props ;
9
- } ;
10
- } ;
6
+ var React = require ( 'react' ) ;
11
7
12
- exports . getRefs = function ( ctx ) {
13
- return function ( ) {
14
- return ctx . refs ;
15
- } ;
16
- } ;
8
+ function getProps ( this_ ) {
9
+ return function ( ) {
10
+ return this_ . props ;
11
+ } ;
12
+ }
13
+ exports . getProps = getProps ;
14
+
15
+ function getRefs ( this_ ) {
16
+ return function ( ) {
17
+ return this_ . refs ;
18
+ } ;
19
+ }
20
+ exports . getRefs = getRefs ;
17
21
18
- exports . getChildren = function ( ctx ) {
19
- return function ( ) {
20
- var children = ctx . props . children ;
22
+ function getChildren ( this_ ) {
23
+ return function ( ) {
24
+ var children = this_ . props . children ;
21
25
22
26
var result = [ ] ;
23
27
@@ -27,103 +31,83 @@ exports.getChildren = function(ctx) {
27
31
28
32
return result ;
29
33
} ;
30
- } ;
34
+ }
35
+ exports . getChildren = getChildren ;
31
36
32
- exports . writeState = function ( ctx ) {
33
- return function ( state ) {
34
- return function ( ) {
35
- ctx . replaceState ( {
36
- state : state
37
- } ) ;
38
- return function ( ) {
39
- return state ;
40
- }
41
- } ;
37
+ function writeState ( this_ ) {
38
+ return function ( state ) {
39
+ return function ( ) {
40
+ this_ . replaceState ( {
41
+ state : state
42
+ } ) ;
43
+ return function ( ) {
44
+ return state ;
45
+ }
42
46
} ;
43
- } ;
47
+ } ;
48
+ }
49
+ exports . writeState = writeState ;
44
50
45
- exports . readState = function ( ctx ) {
46
- return function ( ) {
47
- return ctx . state . state ;
48
- } ;
49
- } ;
51
+ function readState ( this_ ) {
52
+ return function ( ) {
53
+ return this_ . state . state ;
54
+ } ;
55
+ }
56
+ exports . readState = readState ;
50
57
51
- exports . createClass = function ( ss ) {
52
- var result = { } ;
53
- for ( var s in ss ) {
54
- if ( ss . hasOwnProperty ( s ) ) {
55
- if ( s === "displayName" ) {
56
- result [ s ] = ss [ s ] ;
57
- }
58
- else if ( s === "componentWillReceiveProps" ) {
59
- result [ s ] = ( function ( impl ) {
60
- return function ( nextProps ) {
61
- return impl ( this ) ( nextProps ) ( ) ;
62
- }
63
- } ) ( ss [ s ] ) ;
64
- }
65
- else if ( s === "shouldComponentUpdate" ) {
66
- result [ s ] = ( function ( impl ) {
67
- return function ( nextProps , nextState ) {
68
- return impl ( this ) ( nextProps ) ( nextState . state ) ( ) ;
69
- }
70
- } ) ( ss [ s ] ) ;
71
- }
72
- else if ( s === "componentWillUpdate" ) {
73
- result [ s ] = ( function ( impl ) {
74
- return function ( nextProps , nextState ) {
75
- return impl ( this ) ( nextProps ) ( nextState . state ) ( ) ;
76
- }
77
- } ) ( ss [ s ] ) ;
78
- }
79
- else if ( s === "componentDidUpdate" ) {
80
- result [ s ] = ( function ( impl ) {
81
- return function ( prevProps , prevState ) {
82
- return impl ( this ) ( prevProps ) ( prevState . state ) ( ) ;
83
- }
84
- } ) ( ss [ s ] ) ;
85
- }
86
- else {
87
- result [ s ] = ( function ( impl ) {
88
- return function ( ) {
89
- return impl ( this ) ( ) ;
90
- }
91
- } ) ( ss [ s ] ) ;
92
- }
93
- }
58
+ function createClass ( spec ) {
59
+ var result = {
60
+ displayName : spec . displayName ,
61
+ render : function ( ) {
62
+ return spec . render ( this ) ( ) ;
63
+ } ,
64
+ getInitialState : function ( ) {
65
+ return spec . getInitialState ( this ) ( ) ;
66
+ } ,
67
+ componentWillMount : function ( ) {
68
+ return spec . componentWillMount ( this ) ( ) ;
69
+ } ,
70
+ componentDidMount : function ( ) {
71
+ return spec . componentDidMount ( this ) ( ) ;
72
+ } ,
73
+ componentWillReceiveProps : function ( nextProps ) {
74
+ return spec . componentWillReceiveProps ( this ) ( nextProps ) ( ) ;
75
+ } ,
76
+ shouldComponentUpdate : function ( nextProps , nextState ) {
77
+ return spec . shouldComponentUpdate ( this ) ( nextProps ) ( nextState . state ) ( ) ;
78
+ } ,
79
+ componentWillUpdate : function ( nextProps , nextState ) {
80
+ return spec . componentWillUpdate ( this ) ( nextProps ) ( nextState . state ) ( ) ;
81
+ } ,
82
+ componentDidUpdate : function ( prevProps , prevState ) {
83
+ return spec . componentDidUpdate ( this ) ( prevProps ) ( prevState . state ) ( ) ;
84
+ } ,
85
+ componentWillUnmount : function ( ) {
86
+ return spec . componentWillUnmount ( this ) ( ) ;
94
87
}
95
- result . getInitialState = function ( ) {
96
- return {
97
- state : ss . getInitialState ( this ) ( )
98
- } ;
99
- } ;
100
- return React . createClass ( result ) ;
101
- } ;
88
+ } ;
102
89
103
- exports . handle = function ( f ) {
104
- return function ( e ) {
105
- return f ( e ) ( ) ;
106
- } ;
107
- } ;
90
+ return React . createClass ( result ) ;
91
+ }
92
+ exports . createClass = createClass ;
108
93
109
- exports . createElement = function ( clazz ) {
110
- return function ( props ) {
111
- return function ( children ) {
112
- return React . createElement . apply ( React , [ clazz , props ] . concat ( children ) ) ;
113
- } ;
94
+ function handle ( f ) {
95
+ return function ( e ) {
96
+ return f ( e ) ( ) ;
114
97
} ;
115
98
} ;
99
+ exports . handle = handle ;
116
100
117
- exports . createFactory = function ( clazz ) {
118
- return React . createFactory ( clazz ) ;
119
- } ;
120
-
121
- exports . render = function ( element ) {
122
- return function ( container ) {
123
- return function ( ) {
124
- return React . render ( element , container ) ;
125
- }
101
+ function createElement ( class_ ) {
102
+ return function ( props ) {
103
+ return function ( children ) {
104
+ return React . createElement . apply ( React , [ class_ , props ] . concat ( children ) ) ;
105
+ } ;
126
106
} ;
127
- } ;
107
+ }
108
+ exports . createElement = createElement ;
128
109
129
- exports . renderToString = React . renderToString ;
110
+ function createFactory ( class_ ) {
111
+ return React . createFactory ( class_ ) ;
112
+ }
113
+ exports . createFactory = createFactory ;
0 commit comments