File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -466,8 +466,10 @@ function computeHandlerProps(matches, query) {
466466 }
467467
468468 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 ) ) ;
471473 } . bind ( this , props ) ;
472474 } ) ;
473475
Original file line number Diff line number Diff line change @@ -112,6 +112,33 @@ describe('a Route with custom props', function() {
112112 } ) ;
113113} ) ;
114114
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+
115142describe ( 'a Route' , function ( ) {
116143 it ( 'requires a handler' ) ;
117144} ) ;
You can’t perform that action at this time.
0 commit comments