Skip to content

Commit 67f1316

Browse files
committed
Make active routes/params/query read-only
1 parent ba65269 commit 67f1316

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

modules/mixins/ActiveContext.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var React = require('react');
2+
var copyProperties = require('react/lib/copyProperties');
23

34
function routeIsActive(activeRoutes, routeName) {
45
return activeRoutes.some(function (route) {
@@ -49,24 +50,24 @@ var ActiveContext = {
4950
},
5051

5152
/**
52-
* Returns an array of the currently active routes.
53+
* Returns a read-only array of the currently active routes.
5354
*/
5455
getActiveRoutes: function () {
55-
return this.state.activeRoutes;
56+
return this.state.activeRoutes.slice(0);
5657
},
5758

5859
/**
59-
* Returns an object of the currently active URL parameters.
60+
* Returns a read-only object of the currently active URL parameters.
6061
*/
6162
getActiveParams: function () {
62-
return this.state.activeParams;
63+
return copyProperties({}, this.state.activeParams);
6364
},
6465

6566
/**
66-
* Returns an object of the currently active query parameters.
67+
* Returns a read-only object of the currently active query parameters.
6768
*/
6869
getActiveQuery: function () {
69-
return this.state.activeQuery;
70+
return copyProperties({}, this.state.activeQuery);
7071
},
7172

7273
/**

0 commit comments

Comments
 (0)