@@ -7,13 +7,13 @@ exports.createComponent_ = function(noUpdate, buildStateUpdate, displayName) {
77 function contextToSelf ( instance ) {
88 var self = {
99 props : instance . props . $$props ,
10- state : instance . state === undefined ? undefined : instance . state . $$state ,
10+ state : instance . state === null ? null : instance . state . $$state ,
1111 readProps : function ( ) {
1212 return self . instance_ . props . $$props ;
1313 } ,
1414 readState : function ( ) {
1515 var state = self . instance_ . state ;
16- return state === undefined ? undefined : state . $$state ;
16+ return state === null ? null : state . $$state ;
1717 } ,
1818 send : function ( action ) {
1919 return function ( ) {
@@ -39,7 +39,7 @@ exports.createComponent_ = function(noUpdate, buildStateUpdate, displayName) {
3939 return self ;
4040 }
4141
42- var defaultInitialState = { } ;
42+ var defaultInitialState = null ;
4343 var defaultShouldUpdate = function ( ) {
4444 return function ( ) {
4545 return function ( ) {
@@ -69,10 +69,10 @@ exports.createComponent_ = function(noUpdate, buildStateUpdate, displayName) {
6969 this . $$spec = props . $$spec ;
7070 this . state =
7171 // React may optimize components with no state,
72- // so we leave state undefined if it was left as
72+ // so we leave state null if it was left as
7373 // the default value.
7474 this . $$spec . initialState === defaultInitialState
75- ? undefined
75+ ? null
7676 : { $$state : this . $$spec . initialState } ;
7777 return this ;
7878 } ;
@@ -117,12 +117,12 @@ exports.createStatelessComponent = function(displayName) {
117117 function contextToSelf ( instance ) {
118118 var self = {
119119 props : instance . props . $$props ,
120- state : undefined ,
120+ state : null ,
121121 readProps : function ( ) {
122122 return self . instance_ . props . $$props ;
123123 } ,
124124 readState : function ( ) {
125- return undefined ;
125+ return null ;
126126 } ,
127127 send : function ( ) {
128128 return function ( ) { } ;
@@ -132,7 +132,7 @@ exports.createStatelessComponent = function(displayName) {
132132 return self ;
133133 }
134134
135- var defaultInitialState = { } ;
135+ var defaultInitialState = null ;
136136 var defaultShouldUpdate = function ( ) {
137137 return function ( ) {
138138 return function ( ) {
@@ -183,16 +183,36 @@ exports.createStatelessComponent = function(displayName) {
183183 } ;
184184} ;
185185
186- exports . make = function ( component ) {
186+ exports . make = function ( $$spec ) {
187187 return function ( $$props ) {
188188 var props = {
189189 $$props : $$props ,
190- $$spec : component
190+ $$spec : $$spec
191191 } ;
192- return React . createElement ( component . $$type , props ) ;
192+ return React . createElement ( $$spec . $$type , props ) ;
193193 } ;
194194} ;
195195
196+ exports . toReactComponent = function ( $$spec ) {
197+ var Component = function constructor ( ) {
198+ return this ;
199+ } ;
200+
201+ Component . prototype = Object . create ( React . Component . prototype ) ;
202+
203+ Component . displayName = $$spec . $$type . displayName + " (Wrapper)" ;
204+
205+ Component . prototype . render = function ( ) {
206+ var props = {
207+ $$props : this . props ,
208+ $$spec : $$spec
209+ } ;
210+ return React . createElement ( $$spec . $$type , props ) ;
211+ } ;
212+
213+ return Component ;
214+ } ;
215+
196216exports . keyed_ = function ( key , child ) {
197217 return React . createElement ( Fragment , { key : key } , child ) ;
198218} ;
@@ -204,9 +224,7 @@ exports.element_ = function(component, props) {
204224 ) ;
205225} ;
206226
207- exports . elementKeyed_ = function ( key , child ) {
208- return React . createElement . call ( null , Fragment , { key : key } , child ) ;
209- } ;
227+ exports . elementKeyed_ = exports . element_ ;
210228
211229exports . fragment = function ( children ) {
212230 return React . createElement . apply ( null , [ Fragment , { } ] . concat ( children ) ) ;
0 commit comments