1
1
'use strict' ;
2
2
3
- var _classCallCheck = function ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( 'Cannot call a class as a function' ) ; } } ;
4
-
5
3
var _createClass = ( function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( 'value' in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ) ( ) ;
6
4
5
+ function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( 'Cannot call a class as a function' ) ; } }
6
+
7
7
var assign = require ( 'react/lib/Object.assign' ) ;
8
8
var invariant = require ( 'react/lib/invariant' ) ;
9
9
var warning = require ( 'react/lib/warning' ) ;
@@ -12,45 +12,7 @@ var PathUtils = require('./PathUtils');
12
12
var _currentRoute ;
13
13
14
14
var Route = ( function ( ) {
15
- function Route ( name , path , ignoreScrollBehavior , isDefault , isNotFound , onEnter , onLeave , handler ) {
16
- _classCallCheck ( this , Route ) ;
17
-
18
- this . name = name ;
19
- this . path = path ;
20
- this . paramNames = PathUtils . extractParamNames ( this . path ) ;
21
- this . ignoreScrollBehavior = ! ! ignoreScrollBehavior ;
22
- this . isDefault = ! ! isDefault ;
23
- this . isNotFound = ! ! isNotFound ;
24
- this . onEnter = onEnter ;
25
- this . onLeave = onLeave ;
26
- this . handler = handler ;
27
- }
28
-
29
- _createClass ( Route , [ {
30
- key : 'appendChild' ,
31
-
32
- /**
33
- * Appends the given route to this route's child routes.
34
- */
35
- value : function appendChild ( route ) {
36
- invariant ( route instanceof Route , 'route.appendChild must use a valid Route' ) ;
37
-
38
- if ( ! this . childRoutes ) this . childRoutes = [ ] ;
39
-
40
- this . childRoutes . push ( route ) ;
41
- }
42
- } , {
43
- key : 'toString' ,
44
- value : function toString ( ) {
45
- var string = '<Route' ;
46
-
47
- if ( this . name ) string += ' name="' + this . name + '"' ;
48
-
49
- string += ' path="' + this . path + '">' ;
50
-
51
- return string ;
52
- }
53
- } ] , [ {
15
+ _createClass ( Route , null , [ {
54
16
key : 'createRoute' ,
55
17
56
18
/**
@@ -149,28 +111,26 @@ var Route = (function () {
149
111
150
112
return route ;
151
113
}
152
- } , {
153
- key : 'createDefaultRoute' ,
154
114
155
115
/**
156
116
* Creates and returns a route that is rendered when its parent matches
157
117
* the current URL.
158
118
*/
119
+ } , {
120
+ key : 'createDefaultRoute' ,
159
121
value : function createDefaultRoute ( options ) {
160
122
return Route . createRoute ( assign ( { } , options , { isDefault : true } ) ) ;
161
123
}
162
- } , {
163
- key : 'createNotFoundRoute' ,
164
124
165
125
/**
166
126
* Creates and returns a route that is rendered when its parent matches
167
127
* the current URL but none of its siblings do.
168
128
*/
129
+ } , {
130
+ key : 'createNotFoundRoute' ,
169
131
value : function createNotFoundRoute ( options ) {
170
132
return Route . createRoute ( assign ( { } , options , { isNotFound : true } ) ) ;
171
133
}
172
- } , {
173
- key : 'createRedirect' ,
174
134
175
135
/**
176
136
* Creates and returns a route that automatically redirects the transition
@@ -184,6 +144,8 @@ var Route = (function () {
184
144
* - query The query to use in the redirect URL. Defaults
185
145
* to using the current query
186
146
*/
147
+ } , {
148
+ key : 'createRedirect' ,
187
149
value : function createRedirect ( options ) {
188
150
return Route . createRoute ( assign ( { } , options , {
189
151
path : options . path || options . from || '*' ,
@@ -194,6 +156,46 @@ var Route = (function () {
194
156
}
195
157
} ] ) ;
196
158
159
+ function Route ( name , path , ignoreScrollBehavior , isDefault , isNotFound , onEnter , onLeave , handler ) {
160
+ _classCallCheck ( this , Route ) ;
161
+
162
+ this . name = name ;
163
+ this . path = path ;
164
+ this . paramNames = PathUtils . extractParamNames ( this . path ) ;
165
+ this . ignoreScrollBehavior = ! ! ignoreScrollBehavior ;
166
+ this . isDefault = ! ! isDefault ;
167
+ this . isNotFound = ! ! isNotFound ;
168
+ this . onEnter = onEnter ;
169
+ this . onLeave = onLeave ;
170
+ this . handler = handler ;
171
+ }
172
+
173
+ /**
174
+ * Appends the given route to this route's child routes.
175
+ */
176
+
177
+ _createClass ( Route , [ {
178
+ key : 'appendChild' ,
179
+ value : function appendChild ( route ) {
180
+ invariant ( route instanceof Route , 'route.appendChild must use a valid Route' ) ;
181
+
182
+ if ( ! this . childRoutes ) this . childRoutes = [ ] ;
183
+
184
+ this . childRoutes . push ( route ) ;
185
+ }
186
+ } , {
187
+ key : 'toString' ,
188
+ value : function toString ( ) {
189
+ var string = '<Route' ;
190
+
191
+ if ( this . name ) string += ' name="' + this . name + '"' ;
192
+
193
+ string += ' path="' + this . path + '">' ;
194
+
195
+ return string ;
196
+ }
197
+ } ] ) ;
198
+
197
199
return Route ;
198
200
} ) ( ) ;
199
201
0 commit comments