@@ -154,6 +154,20 @@ function createRouter(options) {
154
154
nextState = { } ;
155
155
}
156
156
157
+ if ( typeof location === 'string' ) {
158
+ warning (
159
+ ! canUseDOM || process . env . NODE_ENV === 'test' ,
160
+ 'You should not use a static location in a DOM environment because ' +
161
+ 'the router will not be kept in sync with the current URL'
162
+ ) ;
163
+ } else {
164
+ invariant (
165
+ canUseDOM ,
166
+ 'You cannot use %s without a DOM' ,
167
+ location
168
+ ) ;
169
+ }
170
+
157
171
// Automatically fall back to full page refreshes in
158
172
// browsers that don't support the HTML history API.
159
173
if ( location === HistoryLocation && ! supportsHistory ( ) )
@@ -388,21 +402,8 @@ function createRouter(options) {
388
402
} ;
389
403
390
404
if ( typeof location === 'string' ) {
391
- warning (
392
- ! canUseDOM || process . env . NODE_ENV === 'test' ,
393
- 'You should not use a static location in a DOM environment because ' +
394
- 'the router will not be kept in sync with the current URL'
395
- ) ;
396
-
397
- // Dispatch the location.
398
405
router . dispatch ( location , null , dispatchHandler ) ;
399
406
} else {
400
- invariant (
401
- canUseDOM ,
402
- 'You cannot use %s in a non-DOM environment' ,
403
- location
404
- ) ;
405
-
406
407
// Listen for changes to the location.
407
408
var changeListener = function ( change ) {
408
409
router . dispatch ( change . path , change . type , dispatchHandler ) ;
0 commit comments