@@ -80,7 +80,7 @@ module.exports = function($window, mountRedraw) {
80
80
81
81
function reject ( e ) {
82
82
console . error ( e )
83
- setPath ( fallbackRoute , null , { replace : true } )
83
+ route . set ( fallbackRoute , null , { replace : true } )
84
84
}
85
85
86
86
loop ( 0 )
@@ -124,7 +124,7 @@ module.exports = function($window, mountRedraw) {
124
124
if ( path === fallbackRoute ) {
125
125
throw new Error ( "Could not resolve default route " + fallbackRoute + "." )
126
126
}
127
- setPath ( fallbackRoute , null , { replace : true } )
127
+ route . set ( fallbackRoute , null , { replace : true } )
128
128
}
129
129
}
130
130
@@ -138,26 +138,6 @@ module.exports = function($window, mountRedraw) {
138
138
}
139
139
}
140
140
141
- function setPath ( path , data , options ) {
142
- if ( lastUpdate != null ) {
143
- options = options || { }
144
- options . replace = true
145
- }
146
- lastUpdate = null
147
-
148
- path = buildPathname ( path , data )
149
- if ( ready ) {
150
- fireAsync ( )
151
- var state = options ? options . state : null
152
- var title = options ? options . title : null
153
- if ( options && options . replace ) $window . history . replaceState ( state , title , route . prefix + path )
154
- else $window . history . pushState ( state , title , route . prefix + path )
155
- }
156
- else {
157
- $window . location . href = route . prefix + path
158
- }
159
- }
160
-
161
141
function route ( root , defaultRoute , routes ) {
162
142
if ( ! root ) throw new TypeError ( "DOM element being rendered to does not exist." )
163
143
@@ -187,7 +167,25 @@ module.exports = function($window, mountRedraw) {
187
167
mountRedraw . mount ( root , RouterRoot )
188
168
resolveRoute ( )
189
169
}
190
- route . set = setPath
170
+ route . set = function ( path , data , options ) {
171
+ if ( lastUpdate != null ) {
172
+ options = options || { }
173
+ options . replace = true
174
+ }
175
+ lastUpdate = null
176
+
177
+ path = buildPathname ( path , data )
178
+ if ( ready ) {
179
+ fireAsync ( )
180
+ var state = options ? options . state : null
181
+ var title = options ? options . title : null
182
+ if ( options && options . replace ) $window . history . replaceState ( state , title , route . prefix + path )
183
+ else $window . history . pushState ( state , title , route . prefix + path )
184
+ }
185
+ else {
186
+ $window . location . href = route . prefix + path
187
+ }
188
+ }
191
189
route . get = function ( ) { return currentPath }
192
190
route . prefix = "#!"
193
191
route . Link = {
0 commit comments