Skip to content

Commit f92dd20

Browse files
committed
Move code back into modules dir
1 parent 1cfb11e commit f92dd20

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+237
-245
lines changed

utils/Cancellation.js renamed to modules/Cancellation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
* Represents a cancellation caused by navigating away
33
* before the previous transition has fully resolved.
44
*/
5-
function Cancellation() { }
5+
function Cancellation() {}
66

77
module.exports = Cancellation;

utils/History.js renamed to modules/History.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ var canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM;
33

44
var History = {
55

6+
/**
7+
* The current number of entries in the history.
8+
*
9+
* Note: This property is read-only.
10+
*/
11+
length: 1,
12+
613
/**
714
* Sends the browser back one entry in the history.
815
*/
@@ -17,12 +24,7 @@ var History = {
1724
History.length -= 1;
1825

1926
window.history.back();
20-
},
21-
22-
/**
23-
* The current number of entries in the history.
24-
*/
25-
length: 1
27+
}
2628

2729
};
2830

mixins/Navigation.js renamed to modules/Navigation.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var React = require('react');
1+
var PropTypes = require('./PropTypes');
22

33
/**
44
* A mixin for components that modify the URL.
@@ -21,11 +21,11 @@ var React = require('react');
2121
var Navigation = {
2222

2323
contextTypes: {
24-
makePath: React.PropTypes.func.isRequired,
25-
makeHref: React.PropTypes.func.isRequired,
26-
transitionTo: React.PropTypes.func.isRequired,
27-
replaceWith: React.PropTypes.func.isRequired,
28-
goBack: React.PropTypes.func.isRequired
24+
makePath: PropTypes.func.isRequired,
25+
makeHref: PropTypes.func.isRequired,
26+
transitionTo: PropTypes.func.isRequired,
27+
replaceWith: PropTypes.func.isRequired,
28+
goBack: PropTypes.func.isRequired
2929
},
3030

3131
/**

mixins/NavigationContext.js renamed to modules/NavigationContext.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
var React = require('react');
1+
var PropTypes = require('./PropTypes');
22

33
/**
44
* Provides the router with context for Router.Navigation.
55
*/
66
var NavigationContext = {
77

88
childContextTypes: {
9-
makePath: React.PropTypes.func.isRequired,
10-
makeHref: React.PropTypes.func.isRequired,
11-
transitionTo: React.PropTypes.func.isRequired,
12-
replaceWith: React.PropTypes.func.isRequired,
13-
goBack: React.PropTypes.func.isRequired
9+
makePath: PropTypes.func.isRequired,
10+
makeHref: PropTypes.func.isRequired,
11+
transitionTo: PropTypes.func.isRequired,
12+
replaceWith: PropTypes.func.isRequired,
13+
goBack: PropTypes.func.isRequired
1414
},
1515

1616
getChildContext: function () {

mixins/FakeNode.js renamed to modules/NonRenderable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var invariant = require('react/lib/invariant');
22

3-
var FakeNode = {
3+
var NonRenderable = {
44

55
render: function () {
66
invariant(
@@ -12,4 +12,4 @@ var FakeNode = {
1212

1313
};
1414

15-
module.exports = FakeNode;
15+
module.exports = NonRenderable;
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
var PropTypes = {
1+
var assign = require('react/lib/Object.assign');
2+
var ReactPropTypes = require('react').PropTypes;
3+
4+
var PropTypes = assign({
25

36
/**
47
* Requires that the value of a prop be falsy.
@@ -8,6 +11,6 @@ var PropTypes = {
811
return new Error('<' + componentName + '> may not have a "' + propName + '" prop');
912
}
1013

11-
};
14+
}, ReactPropTypes);
1215

1316
module.exports = PropTypes;
File renamed without changes.
Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
var React = require('react');
2+
var PropTypes = require('./PropTypes');
3+
4+
var RouteHandlerMixin = {
25

3-
module.exports = {
46
contextTypes: {
5-
getRouteAtDepth: React.PropTypes.func.isRequired,
6-
getRouteComponents: React.PropTypes.func.isRequired,
7-
routeHandlers: React.PropTypes.array.isRequired
7+
getRouteAtDepth: PropTypes.func.isRequired,
8+
setRouteComponentAtDepth: PropTypes.func.isRequired,
9+
routeHandlers: PropTypes.array.isRequired
810
},
911

1012
childContextTypes: {
11-
routeHandlers: React.PropTypes.array.isRequired
13+
routeHandlers: PropTypes.array.isRequired
1214
},
1315

1416
getChildContext: function () {
@@ -17,8 +19,10 @@ module.exports = {
1719
};
1820
},
1921

20-
getRouteDepth: function () {
21-
return this.context.routeHandlers.length - 1;
22+
getDefaultProps: function () {
23+
return {
24+
ref: '__routeHandler__'
25+
};
2226
},
2327

2428
componentDidMount: function () {
@@ -30,13 +34,18 @@ module.exports = {
3034
},
3135

3236
_updateRouteComponent: function () {
33-
var depth = this.getRouteDepth();
34-
var components = this.context.getRouteComponents();
35-
components[depth] = this.refs[this.props.ref || '__routeHandler__'];
37+
this.context.setRouteComponentAtDepth(this.getRouteDepth(), this.refs[this.props.ref]);
3638
},
3739

38-
getRouteHandler: function (props) {
40+
getRouteDepth: function () {
41+
return this.context.routeHandlers.length;
42+
},
43+
44+
createChildRouteHandler: function (props) {
3945
var route = this.context.getRouteAtDepth(this.getRouteDepth());
4046
return route ? React.createElement(route.handler, props || this.props) : null;
4147
}
42-
};
48+
49+
};
50+
51+
module.exports = RouteHandlerMixin;

mixins/Scrolling.js renamed to modules/Scrolling.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var invariant = require('react/lib/invariant');
22
var canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM;
3-
var getWindowScrollPosition = require('../utils/getWindowScrollPosition');
3+
var getWindowScrollPosition = require('./utils/getWindowScrollPosition');
44

55
function shouldUpdateScroll(state, prevState) {
66
if (!prevState)

mixins/State.js renamed to modules/State.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var React = require('react');
1+
var PropTypes = require('./PropTypes');
22

33
/**
44
* A mixin for components that need to know the path, routes, URL
@@ -21,12 +21,12 @@ var React = require('react');
2121
var State = {
2222

2323
contextTypes: {
24-
getCurrentPath: React.PropTypes.func.isRequired,
25-
getCurrentRoutes: React.PropTypes.func.isRequired,
26-
getCurrentPathname: React.PropTypes.func.isRequired,
27-
getCurrentParams: React.PropTypes.func.isRequired,
28-
getCurrentQuery: React.PropTypes.func.isRequired,
29-
isActive: React.PropTypes.func.isRequired
24+
getCurrentPath: PropTypes.func.isRequired,
25+
getCurrentRoutes: PropTypes.func.isRequired,
26+
getCurrentPathname: PropTypes.func.isRequired,
27+
getCurrentParams: PropTypes.func.isRequired,
28+
getCurrentQuery: PropTypes.func.isRequired,
29+
isActive: PropTypes.func.isRequired
3030
},
3131

3232
/**

0 commit comments

Comments
 (0)