File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change
1
+ const internalKeysRE = / ^ ( c o m p o n e n t | s u b R o u t e s ) $ /
2
+
1
3
/**
2
4
* Route Context Object
3
5
*
8
10
export default class Route {
9
11
10
12
constructor ( path , router ) {
11
- this . path = path
12
- this . router = router
13
-
14
13
let matched = router . _recognizer . recognize ( path )
15
14
15
+ // copy all custom fields from route configs
16
+ if ( matched ) {
17
+ [ ] . forEach . call ( matched , match => {
18
+ for ( let key in match . handler ) {
19
+ if ( ! internalKeysRE . test ( key ) ) {
20
+ this [ key ] = match . handler [ key ]
21
+ }
22
+ }
23
+ } )
24
+ }
25
+
26
+ this . path = path
27
+ this . router = router
16
28
this . query = matched
17
29
? matched . queryParams
18
30
: { }
19
-
20
31
this . params = matched
21
- ? [ ] . reduce . call ( matched , function ( prev , cur ) {
32
+ ? [ ] . reduce . call ( matched , ( prev , cur ) => {
22
33
if ( cur . params ) {
23
34
for ( let key in cur . params ) {
24
35
prev [ key ] = cur . params [ key ]
Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ export default function (Vue, Router) {
4
4
5
5
/**
6
6
* Register a map of top-level paths.
7
+ *
8
+ * @param {Object } map
7
9
*/
8
10
9
11
Router . prototype . map = function ( map ) {
You can’t perform that action at this time.
0 commit comments