File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -466,8 +466,10 @@ function computeHandlerProps(matches, query) {
466
466
}
467
467
468
468
childHandler = function ( props , addedProps ) {
469
- var children = Array . prototype . slice . call ( arguments , 2 ) ;
470
- return route . props . handler . apply ( null , [ mergeProperties ( props , addedProps ) ] . concat ( children ) ) ;
469
+ if ( arguments . length > 2 && typeof arguments [ 2 ] !== 'undefined' )
470
+ throw new Error ( 'Passing children to a route handler is not supported' ) ;
471
+
472
+ return route . props . handler . apply ( null , mergeProperties ( props , addedProps ) ) ;
471
473
} . bind ( this , props ) ;
472
474
} ) ;
473
475
Original file line number Diff line number Diff line change @@ -112,6 +112,33 @@ describe('a Route with custom props', function() {
112
112
} ) ;
113
113
} ) ;
114
114
115
+ describe ( 'a route handler' , function ( ) {
116
+ it ( 'may not receive children' , function ( done ) {
117
+ var InvalidHandler = React . createClass ( {
118
+ displayName : 'InvalidHandler' ,
119
+ render : function ( ) {
120
+ try {
121
+ var result = this . props . activeRouteHandler ( { } , React . DOM . div ( ) ) ;
122
+ assert ( false , 'activeRouteHandler rendered with children' ) ;
123
+ return result ;
124
+ } catch ( error ) {
125
+ assert ( error ) ;
126
+ }
127
+
128
+ done ( ) ;
129
+ }
130
+ } ) ;
131
+
132
+ var route = TestUtils . renderIntoDocument (
133
+ Route ( { handler : InvalidHandler } ,
134
+ Route ( { path : '/home' , handler : App } )
135
+ )
136
+ ) ;
137
+
138
+ route . dispatch ( '/home' ) ;
139
+ } ) ;
140
+ } ) ;
141
+
115
142
describe ( 'a Route' , function ( ) {
116
143
it ( 'requires a handler' ) ;
117
144
} ) ;
You can’t perform that action at this time.
0 commit comments