Skip to content

Commit b8aef40

Browse files
committed
Version 0.13.4
1 parent 5875831 commit b8aef40

27 files changed

+2739
-2750
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
v0.13.4 - Tue, 06 Oct 2015 13:13:20 GMT
2+
---------------------------------------
3+
4+
- [b237238](../../commit/b237238) [fixed] Removed getter for IE8 compat
5+
- [53ce7f1](../../commit/53ce7f1) [fixed] #1148 regex for detecting trailing slashes
6+
7+
18
v0.13.3 - Wed, 29 Apr 2015 01:47:08 GMT
29
---------------------------------------
310

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-router",
3-
"version": "0.13.3",
3+
"version": "0.13.4",
44
"description": "A complete routing library for React.js",
55
"main": "build/umd/ReactRouter.js",
66
"homepage": "https://github.com/rackt/react-router",

build/README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1+
[![build status](https://img.shields.io/travis/rackt/react-router/0.13.x.svg?style=flat-square)](https://travis-ci.org/rackt/react-router)
12
[![npm package](https://img.shields.io/npm/v/react-router.svg?style=flat-square)](https://www.npmjs.org/package/react-router)
2-
[![build status](https://img.shields.io/travis/rackt/react-router/master.svg?style=flat-square)](https://travis-ci.org/rackt/react-router)
3-
[![dependency status](https://img.shields.io/david/rackt/react-router.svg?style=flat-square)](https://david-dm.org/rackt/react-router)
4-
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/rackt/react-router?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
3+
[![react-router channel on slack](https://img.shields.io/badge/[email protected]?style=flat-square)](http://www.reactiflux.com)
54

65
React Router
76
============
87

98
A complete routing library for React.
109

11-
Docs
12-
----
13-
14-
- [Guide: Overview](/docs/guides/overview.md)
15-
- [API](/docs/api/)
10+
* [Guides](/docs/guides)
11+
* [Docs](/doc)
1612

1713
Important Notes
1814
---------------
@@ -124,7 +120,7 @@ Related Modules
124120

125121
- [rnr-constrained-route](https://github.com/bjyoungblood/rnr-constrained-route) - validate paths
126122
and parameters on route handlers.
127-
- [react-router-bootstrap](https://github.com/mtscout6/react-router-bootstrap) - Integration with [react-bootstrap](https://github.com/react-bootstrap/react-bootstrap) components.
123+
- [react-router-bootstrap](https://github.com/react-bootstrap/react-router-bootstrap) - Integration with [react-bootstrap](https://github.com/react-bootstrap/react-bootstrap) components.
128124
- [react-router-proxy-loader](https://github.com/odysseyscience/react-router-proxy-loader) - A Webpack loader to dynamically load react-router components on-demand
129125

130126
Contributing

build/lib/Match.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
/* jshint -W084 */
12
'use strict';
23

3-
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
4-
54
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
65

7-
/* jshint -W084 */
6+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
7+
88
var PathUtils = require('./PathUtils');
99

1010
function deepSearch(route, pathname, query) {
@@ -27,29 +27,20 @@ function deepSearch(route, pathname, query) {
2727

2828
// No child routes matched; try the default route.
2929
var defaultRoute = route.defaultRoute;
30-
if (defaultRoute && (params = PathUtils.extractParams(defaultRoute.path, pathname))) {
31-
return new Match(pathname, params, query, [route, defaultRoute]);
32-
} // Does the "not found" route match?
30+
if (defaultRoute && (params = PathUtils.extractParams(defaultRoute.path, pathname))) return new Match(pathname, params, query, [route, defaultRoute]);
31+
32+
// Does the "not found" route match?
3333
var notFoundRoute = route.notFoundRoute;
34-
if (notFoundRoute && (params = PathUtils.extractParams(notFoundRoute.path, pathname))) {
35-
return new Match(pathname, params, query, [route, notFoundRoute]);
36-
} // Last attempt: check this route.
34+
if (notFoundRoute && (params = PathUtils.extractParams(notFoundRoute.path, pathname))) return new Match(pathname, params, query, [route, notFoundRoute]);
35+
36+
// Last attempt: check this route.
3737
var params = PathUtils.extractParams(route.path, pathname);
38-
if (params) {
39-
return new Match(pathname, params, query, [route]);
40-
}return null;
38+
if (params) return new Match(pathname, params, query, [route]);
39+
40+
return null;
4141
}
4242

4343
var Match = (function () {
44-
function Match(pathname, params, query, routes) {
45-
_classCallCheck(this, Match);
46-
47-
this.pathname = pathname;
48-
this.params = params;
49-
this.query = query;
50-
this.routes = routes;
51-
}
52-
5344
_createClass(Match, null, [{
5445
key: 'findMatch',
5546

@@ -69,6 +60,15 @@ var Match = (function () {
6960
}
7061
}]);
7162

63+
function Match(pathname, params, query, routes) {
64+
_classCallCheck(this, Match);
65+
66+
this.pathname = pathname;
67+
this.params = params;
68+
this.query = query;
69+
this.routes = routes;
70+
}
71+
7272
return Match;
7373
})();
7474

build/lib/PathUtils.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var qs = require('qs');
66

77
var paramCompileMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$]*)|[*.()\[\]\\+|{}^$]/g;
88
var paramInjectMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$?]*[?]?)|[*]/g;
9-
var paramInjectTrailingSlashMatcher = /\/\/\?|\/\?\/|\/\?/g;
9+
var paramInjectTrailingSlashMatcher = /\/\/\?|\/\?\/|\/\?(?![^\/=]+=.*$)/g;
1010
var queryMatcher = /\?(.*)$/;
1111

1212
var _compiledPatterns = {};
@@ -71,9 +71,9 @@ var PathUtils = {
7171

7272
var match = path.match(matcher);
7373

74-
if (!match) {
75-
return null;
76-
}var params = {};
74+
if (!match) return null;
75+
76+
var params = {};
7777

7878
paramNames.forEach(function (paramName, index) {
7979
params[paramName] = match[index + 1];
@@ -143,9 +143,9 @@ var PathUtils = {
143143

144144
var queryString = qs.stringify(query, { arrayFormat: 'brackets' });
145145

146-
if (queryString) {
147-
return PathUtils.withoutQuery(path) + '?' + queryString;
148-
}return PathUtils.withoutQuery(path);
146+
if (queryString) return PathUtils.withoutQuery(path) + '?' + queryString;
147+
148+
return PathUtils.withoutQuery(path);
149149
}
150150

151151
};

build/lib/PropTypes.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ var PropTypes = assign({}, ReactPropTypes, {
1010
* Indicates that a prop should be falsy.
1111
*/
1212
falsy: function falsy(props, propName, componentName) {
13-
if (props[propName]) {
14-
return new Error('<' + componentName + '> should not have a "' + propName + '" prop');
15-
}
13+
if (props[propName]) return new Error('<' + componentName + '> should not have a "' + propName + '" prop');
1614
},
1715

1816
/**

build/lib/Route.js

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22

3-
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
4-
53
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
64

5+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
6+
77
var assign = require('react/lib/Object.assign');
88
var invariant = require('react/lib/invariant');
99
var warning = require('react/lib/warning');
@@ -12,45 +12,7 @@ var PathUtils = require('./PathUtils');
1212
var _currentRoute;
1313

1414
var Route = (function () {
15-
function Route(name, path, ignoreScrollBehavior, isDefault, isNotFound, onEnter, onLeave, handler) {
16-
_classCallCheck(this, Route);
17-
18-
this.name = name;
19-
this.path = path;
20-
this.paramNames = PathUtils.extractParamNames(this.path);
21-
this.ignoreScrollBehavior = !!ignoreScrollBehavior;
22-
this.isDefault = !!isDefault;
23-
this.isNotFound = !!isNotFound;
24-
this.onEnter = onEnter;
25-
this.onLeave = onLeave;
26-
this.handler = handler;
27-
}
28-
29-
_createClass(Route, [{
30-
key: 'appendChild',
31-
32-
/**
33-
* Appends the given route to this route's child routes.
34-
*/
35-
value: function appendChild(route) {
36-
invariant(route instanceof Route, 'route.appendChild must use a valid Route');
37-
38-
if (!this.childRoutes) this.childRoutes = [];
39-
40-
this.childRoutes.push(route);
41-
}
42-
}, {
43-
key: 'toString',
44-
value: function toString() {
45-
var string = '<Route';
46-
47-
if (this.name) string += ' name="' + this.name + '"';
48-
49-
string += ' path="' + this.path + '">';
50-
51-
return string;
52-
}
53-
}], [{
15+
_createClass(Route, null, [{
5416
key: 'createRoute',
5517

5618
/**
@@ -149,28 +111,26 @@ var Route = (function () {
149111

150112
return route;
151113
}
152-
}, {
153-
key: 'createDefaultRoute',
154114

155115
/**
156116
* Creates and returns a route that is rendered when its parent matches
157117
* the current URL.
158118
*/
119+
}, {
120+
key: 'createDefaultRoute',
159121
value: function createDefaultRoute(options) {
160122
return Route.createRoute(assign({}, options, { isDefault: true }));
161123
}
162-
}, {
163-
key: 'createNotFoundRoute',
164124

165125
/**
166126
* Creates and returns a route that is rendered when its parent matches
167127
* the current URL but none of its siblings do.
168128
*/
129+
}, {
130+
key: 'createNotFoundRoute',
169131
value: function createNotFoundRoute(options) {
170132
return Route.createRoute(assign({}, options, { isNotFound: true }));
171133
}
172-
}, {
173-
key: 'createRedirect',
174134

175135
/**
176136
* Creates and returns a route that automatically redirects the transition
@@ -184,6 +144,8 @@ var Route = (function () {
184144
* - query The query to use in the redirect URL. Defaults
185145
* to using the current query
186146
*/
147+
}, {
148+
key: 'createRedirect',
187149
value: function createRedirect(options) {
188150
return Route.createRoute(assign({}, options, {
189151
path: options.path || options.from || '*',
@@ -194,6 +156,46 @@ var Route = (function () {
194156
}
195157
}]);
196158

159+
function Route(name, path, ignoreScrollBehavior, isDefault, isNotFound, onEnter, onLeave, handler) {
160+
_classCallCheck(this, Route);
161+
162+
this.name = name;
163+
this.path = path;
164+
this.paramNames = PathUtils.extractParamNames(this.path);
165+
this.ignoreScrollBehavior = !!ignoreScrollBehavior;
166+
this.isDefault = !!isDefault;
167+
this.isNotFound = !!isNotFound;
168+
this.onEnter = onEnter;
169+
this.onLeave = onLeave;
170+
this.handler = handler;
171+
}
172+
173+
/**
174+
* Appends the given route to this route's child routes.
175+
*/
176+
177+
_createClass(Route, [{
178+
key: 'appendChild',
179+
value: function appendChild(route) {
180+
invariant(route instanceof Route, 'route.appendChild must use a valid Route');
181+
182+
if (!this.childRoutes) this.childRoutes = [];
183+
184+
this.childRoutes.push(route);
185+
}
186+
}, {
187+
key: 'toString',
188+
value: function toString() {
189+
var string = '<Route';
190+
191+
if (this.name) string += ' name="' + this.name + '"';
192+
193+
string += ' path="' + this.path + '">';
194+
195+
return string;
196+
}
197+
}]);
198+
197199
return Route;
198200
})();
199201

build/lib/ScrollHistory.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ var canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM;
55
var getWindowScrollPosition = require('./getWindowScrollPosition');
66

77
function shouldUpdateScroll(state, prevState) {
8-
if (!prevState) {
9-
return true;
10-
} // Don't update scroll position when only the query has changed.
11-
if (state.pathname === prevState.pathname) {
12-
return false;
13-
}var routes = state.routes;
8+
if (!prevState) return true;
9+
10+
// Don't update scroll position when only the query has changed.
11+
if (state.pathname === prevState.pathname) return false;
12+
13+
var routes = state.routes;
1414
var prevRoutes = prevState.routes;
1515

1616
var sharedAncestorRoutes = routes.filter(function (route) {
@@ -63,9 +63,9 @@ var ScrollHistory = {
6363
},
6464

6565
_updateScroll: function _updateScroll(prevState) {
66-
if (!shouldUpdateScroll(this.state, prevState)) {
67-
return;
68-
}var scrollBehavior = this.constructor.getScrollBehavior();
66+
if (!shouldUpdateScroll(this.state, prevState)) return;
67+
68+
var scrollBehavior = this.constructor.getScrollBehavior();
6969

7070
if (scrollBehavior) scrollBehavior.updateScrollPosition(this.constructor.getScrollPosition(this.state.path), this.state.action);
7171
}

0 commit comments

Comments
 (0)