@@ -8,8 +8,7 @@ exports.createComponent_ = function(
88 buildStateUpdate ,
99 handler ,
1010 composeCancelEventFn ,
11- identityEventFn ,
12- displayName
11+ identityEventFn
1312) {
1413 var defaultInitialState = null ;
1514 var defaultShouldUpdate = function ( ) {
@@ -106,71 +105,73 @@ exports.createComponent_ = function(
106105 return self ;
107106 }
108107
109- var Component = function constructor ( props ) {
110- this . $$mounted = true ;
111- this . $$spec = props . $$spec ;
112- this . state =
113- // React may optimize components with no state,
114- // so we leave state null if it was left as
115- // the default value.
116- this . $$spec . initialState === defaultInitialState
117- ? null
118- : { $$state : this . $$spec . initialState } ;
119- return this ;
120- } ;
108+ return function ( displayName ) {
109+ var Component = function constructor ( props ) {
110+ this . $$mounted = true ;
111+ this . $$spec = props . $$spec ;
112+ this . state =
113+ // React may optimize components with no state,
114+ // so we leave state null if it was left as
115+ // the default value.
116+ this . $$spec . initialState === defaultInitialState
117+ ? null
118+ : { $$state : this . $$spec . initialState } ;
119+ return this ;
120+ } ;
121121
122- Component . prototype = Object . create ( React . Component . prototype ) ;
122+ Component . prototype = Object . create ( React . Component . prototype ) ;
123123
124- Component . displayName = displayName ;
124+ Component . displayName = displayName ;
125125
126- Component . prototype . shouldComponentUpdate = function ( nextProps , nextState ) {
127- var shouldUpdate = this . $$spec . shouldUpdate ;
128- return shouldUpdate === defaultShouldUpdate
129- ? true
130- : shouldUpdate ( {
131- props : this . props . $$props ,
132- state : this . state === null ? null : this . state . $$state
133- } ) ( nextProps . $$props ) ( nextState === null ? null : nextState . $$state ) ;
134- } ;
126+ Component . prototype . shouldComponentUpdate = function ( nextProps , nextState ) {
127+ var shouldUpdate = this . $$spec . shouldUpdate ;
128+ return shouldUpdate === defaultShouldUpdate
129+ ? true
130+ : shouldUpdate ( {
131+ props : this . props . $$props ,
132+ state : this . state === null ? null : this . state . $$state
133+ } ) ( nextProps . $$props ) ( nextState === null ? null : nextState . $$state ) ;
134+ } ;
135135
136- Component . prototype . componentDidMount = function ( ) {
137- var didMount = this . $$spec . didMount ;
138- if ( didMount !== defaultDidMount ) {
139- this . $$spec . didMount ( contextToSelf ( this ) ) ( ) ;
140- }
141- } ;
136+ Component . prototype . componentDidMount = function ( ) {
137+ var didMount = this . $$spec . didMount ;
138+ if ( didMount !== defaultDidMount ) {
139+ this . $$spec . didMount ( contextToSelf ( this ) ) ( ) ;
140+ }
141+ } ;
142142
143- Component . prototype . componentDidUpdate = function ( ) {
144- var didUpdate = this . $$spec . didUpdate ;
145- if ( didUpdate !== defaultDidUpdate ) {
146- didUpdate ( contextToSelf ( this ) ) ( ) ;
147- }
148- } ;
143+ Component . prototype . componentDidUpdate = function ( ) {
144+ var didUpdate = this . $$spec . didUpdate ;
145+ if ( didUpdate !== defaultDidUpdate ) {
146+ didUpdate ( contextToSelf ( this ) ) ( ) ;
147+ }
148+ } ;
149149
150- Component . prototype . componentWillUnmount = function ( ) {
151- this . $$mounted = false ;
152- var willUnmount = this . $$spec . willUnmount ;
153- if ( willUnmount !== defaultWillUnmount ) {
154- willUnmount ( {
155- props : this . props . $$props ,
156- state : this . state === null ? null : this . state . $$state
157- } ) ( ) ;
158- }
159- } ;
150+ Component . prototype . componentWillUnmount = function ( ) {
151+ this . $$mounted = false ;
152+ var willUnmount = this . $$spec . willUnmount ;
153+ if ( willUnmount !== defaultWillUnmount ) {
154+ willUnmount ( {
155+ props : this . props . $$props ,
156+ state : this . state === null ? null : this . state . $$state
157+ } ) ( ) ;
158+ }
159+ } ;
160160
161- Component . prototype . render = function ( ) {
162- return this . $$spec . render ( contextToSelf ( this ) ) ;
163- } ;
161+ Component . prototype . render = function ( ) {
162+ return this . $$spec . render ( contextToSelf ( this ) ) ;
163+ } ;
164164
165- return {
166- $$type : Component ,
167- initialState : defaultInitialState ,
168- shouldUpdate : defaultShouldUpdate ,
169- didMount : defaultDidMount ,
170- didUpdate : defaultDidUpdate ,
171- willUnmount : defaultWillUnmount ,
172- update : defaultUpdate ,
173- render : defaultRender
165+ return {
166+ $$type : Component ,
167+ initialState : defaultInitialState ,
168+ shouldUpdate : defaultShouldUpdate ,
169+ didMount : defaultDidMount ,
170+ didUpdate : defaultDidUpdate ,
171+ willUnmount : defaultWillUnmount ,
172+ update : defaultUpdate ,
173+ render : defaultRender
174+ } ;
174175 } ;
175176} ;
176177
0 commit comments