File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -165,6 +165,17 @@ export default class RouteNode {
165165 return this . children . filter ( child => ! child . absolute )
166166 }
167167
168+ public sortChildren ( ) {
169+ if ( this . children . length ) {
170+ sortChildren ( this . children )
171+ }
172+ }
173+
174+ public sortDescendants ( ) {
175+ this . sortChildren ( )
176+ this . children . forEach ( child => child . sortDescendants ( ) )
177+ }
178+
168179 public buildPath (
169180 routeName : string ,
170181 params : object = { } ,
@@ -255,9 +266,7 @@ export default class RouteNode {
255266 this . children . push ( route )
256267 // Push greedy spats to the bottom of the pile
257268
258- const originalChildren = this . children . slice ( 0 )
259-
260- this . children . sort ( sortChildren ( originalChildren ) )
269+ this . sortChildren ( )
261270 } else {
262271 // Locate parent node
263272 const segments = this . getSegmentsByName (
Original file line number Diff line number Diff line change 11import RouteNode from './RouteNode'
22
3- export default ( originalChildren : RouteNode [ ] ) => (
3+ export default function sortChildren ( children : RouteNode [ ] ) {
4+ const originalChildren = children . slice ( 0 )
5+
6+ return children . sort ( sortPredicate ( originalChildren ) )
7+ }
8+
9+ const sortPredicate = ( originalChildren : RouteNode [ ] ) => (
410 left : RouteNode ,
511 right : RouteNode
612) : number => {
You can’t perform that action at this time.
0 commit comments