File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 1
1
var React = require ( 'react' ) ;
2
2
var ActiveState = require ( '../mixins/ActiveState' ) ;
3
+ var ActiveStore = require ( '../helpers/ActiveStore' ) ;
4
+ var mergeProperties = require ( '../helpers/mergeProperties' ) ;
3
5
var withoutProperties = require ( '../helpers/withoutProperties' ) ;
4
6
var transitionTo = require ( '../helpers/transitionTo' ) ;
5
7
var makeHref = require ( '../helpers/makeHref' ) ;
@@ -66,7 +68,8 @@ var Link = React.createClass({
66
68
* Returns a hash of URL parameters to use in this <Link>'s path.
67
69
*/
68
70
getParams : function ( ) {
69
- return Link . getUnreservedProps ( this . props ) ;
71
+ // Links may omit active params. See #89
72
+ return mergeProperties ( ActiveStore . getActiveParams ( ) , Link . getUnreservedProps ( this . props ) ) ;
70
73
} ,
71
74
72
75
/**
Original file line number Diff line number Diff line change @@ -68,6 +68,27 @@ var ActiveStore = {
68
68
notifyChange ( ) ;
69
69
} ,
70
70
71
+ /**
72
+ * Returns an array of the currently active routes.
73
+ */
74
+ getActiveRoutes : function ( ) {
75
+ return _activeRoutes ;
76
+ } ,
77
+
78
+ /**
79
+ * Returns a hash of the currently active params.
80
+ */
81
+ getActiveParams : function ( ) {
82
+ return _activeParams ;
83
+ } ,
84
+
85
+ /**
86
+ * Returns a hash of the currently active query parameters.
87
+ */
88
+ getActiveQuery : function ( ) {
89
+ return _activeQuery ;
90
+ } ,
91
+
71
92
/**
72
93
* Returns true if the route with the given name, URL parameters, and query
73
94
* are all currently active.
Original file line number Diff line number Diff line change
1
+ require ( './helper' ) ;
2
+ var Link = require ( '../modules/components/Link' ) ;
3
+
4
+ describe ( 'a Link that is present in an active route' , function ( ) {
5
+ it ( 'automatically gets the active params' ) ;
6
+ } ) ;
You can’t perform that action at this time.
0 commit comments