react-router
Advanced tools
Comparing version 0.13.2 to 0.13.3
@@ -1,6 +0,6 @@ | ||
"use strict"; | ||
/** | ||
* Actions that modify the URL. | ||
*/ | ||
'use strict'; | ||
var LocationActions = { | ||
@@ -11,3 +11,3 @@ | ||
*/ | ||
PUSH: "push", | ||
PUSH: 'push', | ||
@@ -17,3 +17,3 @@ /** | ||
*/ | ||
REPLACE: "replace", | ||
REPLACE: 'replace', | ||
@@ -23,3 +23,3 @@ /** | ||
*/ | ||
POP: "pop" | ||
POP: 'pop' | ||
@@ -26,0 +26,0 @@ }; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
var LocationActions = require("../actions/LocationActions"); | ||
var LocationActions = require('../actions/LocationActions'); | ||
@@ -5,0 +5,0 @@ /** |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
/** | ||
@@ -7,2 +5,4 @@ * A scroll behavior that always scrolls to the top of the page | ||
*/ | ||
"use strict"; | ||
var ScrollToTopBehavior = { | ||
@@ -9,0 +9,0 @@ |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
/** | ||
@@ -7,4 +5,6 @@ * Represents a cancellation caused by navigating away | ||
*/ | ||
"use strict"; | ||
function Cancellation() {} | ||
module.exports = Cancellation; |
@@ -1,8 +0,8 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; | ||
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; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; | ||
@@ -15,3 +15,3 @@ /** | ||
var React = require("react"); | ||
var React = require('react'); | ||
@@ -29,9 +29,8 @@ var ContextWrapper = (function (_React$Component) { | ||
_createClass(ContextWrapper, { | ||
render: { | ||
value: function render() { | ||
return this.props.children; | ||
} | ||
_createClass(ContextWrapper, [{ | ||
key: 'render', | ||
value: function render() { | ||
return this.props.children; | ||
} | ||
}); | ||
}]); | ||
@@ -38,0 +37,0 @@ return ContextWrapper; |
@@ -1,10 +0,10 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; | ||
var PropTypes = require("../PropTypes"); | ||
var RouteHandler = require("./RouteHandler"); | ||
var Route = require("./Route"); | ||
var PropTypes = require('../PropTypes'); | ||
var RouteHandler = require('./RouteHandler'); | ||
var Route = require('./Route'); | ||
@@ -11,0 +11,0 @@ /** |
@@ -1,12 +0,12 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; | ||
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; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; | ||
var React = require("react"); | ||
var assign = require("react/lib/Object.assign"); | ||
var PropTypes = require("../PropTypes"); | ||
var React = require('react'); | ||
var assign = require('react/lib/Object.assign'); | ||
var PropTypes = require('../PropTypes'); | ||
@@ -51,63 +51,60 @@ function isLeftClickEvent(event) { | ||
_createClass(Link, { | ||
handleClick: { | ||
value: function handleClick(event) { | ||
var allowTransition = true; | ||
var clickResult; | ||
_createClass(Link, [{ | ||
key: 'handleClick', | ||
value: function handleClick(event) { | ||
var allowTransition = true; | ||
var clickResult; | ||
if (this.props.onClick) clickResult = this.props.onClick(event); | ||
if (this.props.onClick) clickResult = this.props.onClick(event); | ||
if (isModifiedEvent(event) || !isLeftClickEvent(event)) { | ||
return; | ||
}if (clickResult === false || event.defaultPrevented === true) allowTransition = false; | ||
if (isModifiedEvent(event) || !isLeftClickEvent(event)) { | ||
return; | ||
}if (clickResult === false || event.defaultPrevented === true) allowTransition = false; | ||
event.preventDefault(); | ||
event.preventDefault(); | ||
if (allowTransition) this.context.router.transitionTo(this.props.to, this.props.params, this.props.query); | ||
} | ||
}, | ||
getHref: { | ||
if (allowTransition) this.context.router.transitionTo(this.props.to, this.props.params, this.props.query); | ||
} | ||
}, { | ||
key: 'getHref', | ||
/** | ||
* Returns the value of the "href" attribute to use on the DOM element. | ||
*/ | ||
/** | ||
* Returns the value of the "href" attribute to use on the DOM element. | ||
*/ | ||
value: function getHref() { | ||
return this.context.router.makeHref(this.props.to, this.props.params, this.props.query); | ||
} | ||
}, { | ||
key: 'getClassName', | ||
value: function getHref() { | ||
return this.context.router.makeHref(this.props.to, this.props.params, this.props.query); | ||
} | ||
}, | ||
getClassName: { | ||
/** | ||
* Returns the value of the "class" attribute to use on the DOM element, which contains | ||
* the value of the activeClassName property when this <Link> is active. | ||
*/ | ||
value: function getClassName() { | ||
var className = this.props.className; | ||
/** | ||
* Returns the value of the "class" attribute to use on the DOM element, which contains | ||
* the value of the activeClassName property when this <Link> is active. | ||
*/ | ||
if (this.getActiveState()) className += ' ' + this.props.activeClassName; | ||
value: function getClassName() { | ||
var className = this.props.className; | ||
return className; | ||
} | ||
}, { | ||
key: 'getActiveState', | ||
value: function getActiveState() { | ||
return this.context.router.isActive(this.props.to, this.props.params, this.props.query); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var props = assign({}, this.props, { | ||
href: this.getHref(), | ||
className: this.getClassName(), | ||
onClick: this.handleClick.bind(this) | ||
}); | ||
if (this.getActiveState()) className += " " + this.props.activeClassName; | ||
if (props.activeStyle && this.getActiveState()) props.style = props.activeStyle; | ||
return className; | ||
} | ||
}, | ||
getActiveState: { | ||
value: function getActiveState() { | ||
return this.context.router.isActive(this.props.to, this.props.params, this.props.query); | ||
} | ||
}, | ||
render: { | ||
value: function render() { | ||
var props = assign({}, this.props, { | ||
href: this.getHref(), | ||
className: this.getClassName(), | ||
onClick: this.handleClick.bind(this) | ||
}); | ||
if (props.activeStyle && this.getActiveState()) props.style = props.activeStyle; | ||
return React.DOM.a(props, this.props.children); | ||
} | ||
return React.DOM.a(props, this.props.children); | ||
} | ||
}); | ||
}]); | ||
@@ -135,6 +132,6 @@ return Link; | ||
Link.defaultProps = { | ||
activeClassName: "active", | ||
className: "" | ||
activeClassName: 'active', | ||
className: '' | ||
}; | ||
module.exports = Link; |
@@ -1,10 +0,10 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; | ||
var PropTypes = require("../PropTypes"); | ||
var RouteHandler = require("./RouteHandler"); | ||
var Route = require("./Route"); | ||
var PropTypes = require('../PropTypes'); | ||
var RouteHandler = require('./RouteHandler'); | ||
var Route = require('./Route'); | ||
@@ -11,0 +11,0 @@ /** |
@@ -1,9 +0,9 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; | ||
var PropTypes = require("../PropTypes"); | ||
var Route = require("./Route"); | ||
var PropTypes = require('../PropTypes'); | ||
var Route = require('./Route'); | ||
@@ -10,0 +10,0 @@ /** |
@@ -1,13 +0,13 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; | ||
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; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; | ||
var React = require("react"); | ||
var invariant = require("react/lib/invariant"); | ||
var PropTypes = require("../PropTypes"); | ||
var RouteHandler = require("./RouteHandler"); | ||
var React = require('react'); | ||
var invariant = require('react/lib/invariant'); | ||
var PropTypes = require('../PropTypes'); | ||
var RouteHandler = require('./RouteHandler'); | ||
@@ -66,9 +66,8 @@ /** | ||
_createClass(Route, { | ||
render: { | ||
value: function render() { | ||
invariant(false, "%s elements are for router configuration only and should not be rendered", this.constructor.name); | ||
} | ||
_createClass(Route, [{ | ||
key: 'render', | ||
value: function render() { | ||
invariant(false, '%s elements are for router configuration only and should not be rendered', this.constructor.name); | ||
} | ||
}); | ||
}]); | ||
@@ -75,0 +74,0 @@ return Route; |
@@ -1,15 +0,15 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; | ||
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; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
var _inherits = function (subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; | ||
var React = require("react"); | ||
var ContextWrapper = require("./ContextWrapper"); | ||
var assign = require("react/lib/Object.assign"); | ||
var PropTypes = require("../PropTypes"); | ||
var React = require('react'); | ||
var ContextWrapper = require('./ContextWrapper'); | ||
var assign = require('react/lib/Object.assign'); | ||
var PropTypes = require('../PropTypes'); | ||
var REF_NAME = "__routeHandler__"; | ||
var REF_NAME = '__routeHandler__'; | ||
@@ -32,54 +32,62 @@ /** | ||
_createClass(RouteHandler, { | ||
getChildContext: { | ||
value: function getChildContext() { | ||
return { | ||
routeDepth: this.context.routeDepth + 1 | ||
}; | ||
} | ||
}, | ||
componentDidMount: { | ||
value: function componentDidMount() { | ||
this._updateRouteComponent(this.refs[REF_NAME]); | ||
} | ||
}, | ||
componentDidUpdate: { | ||
value: function componentDidUpdate() { | ||
this._updateRouteComponent(this.refs[REF_NAME]); | ||
} | ||
}, | ||
componentWillUnmount: { | ||
value: function componentWillUnmount() { | ||
this._updateRouteComponent(null); | ||
} | ||
}, | ||
_updateRouteComponent: { | ||
value: function _updateRouteComponent(component) { | ||
this.context.router.setRouteComponentAtDepth(this.getRouteDepth(), component); | ||
} | ||
}, | ||
getRouteDepth: { | ||
value: function getRouteDepth() { | ||
return this.context.routeDepth; | ||
} | ||
}, | ||
createChildRouteHandler: { | ||
value: function createChildRouteHandler(props) { | ||
var route = this.context.router.getRouteAtDepth(this.getRouteDepth()); | ||
return route ? React.createElement(route.handler, assign({}, props || this.props, { ref: REF_NAME })) : null; | ||
} | ||
}, | ||
render: { | ||
value: function render() { | ||
var handler = this.createChildRouteHandler(); | ||
// <script/> for things like <CSSTransitionGroup/> that don't like null | ||
return handler ? React.createElement( | ||
ContextWrapper, | ||
null, | ||
handler | ||
) : React.createElement("script", null); | ||
} | ||
_createClass(RouteHandler, [{ | ||
key: 'getChildContext', | ||
value: function getChildContext() { | ||
return { | ||
routeDepth: this.context.routeDepth + 1 | ||
}; | ||
} | ||
}); | ||
}, { | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
this._updateRouteComponent(this.refs[REF_NAME]); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
this._updateRouteComponent(this.refs[REF_NAME]); | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
value: function componentWillUnmount() { | ||
this._updateRouteComponent(null); | ||
} | ||
}, { | ||
key: '_updateRouteComponent', | ||
value: function _updateRouteComponent(component) { | ||
this.context.router.setRouteComponentAtDepth(this.getRouteDepth(), component); | ||
} | ||
}, { | ||
key: 'getRouteDepth', | ||
value: function getRouteDepth() { | ||
return this.context.routeDepth; | ||
} | ||
}, { | ||
key: 'createChildRouteHandler', | ||
value: function createChildRouteHandler(props) { | ||
var route = this.context.router.getRouteAtDepth(this.getRouteDepth()); | ||
if (route == null) { | ||
return null; | ||
}var childProps = assign({}, props || this.props, { | ||
ref: REF_NAME, | ||
params: this.context.router.getCurrentParams(), | ||
query: this.context.router.getCurrentQuery() | ||
}); | ||
return React.createElement(route.handler, childProps); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var handler = this.createChildRouteHandler(); | ||
// <script/> for things like <CSSTransitionGroup/> that don't like null | ||
return handler ? React.createElement( | ||
ContextWrapper, | ||
null, | ||
handler | ||
) : React.createElement('script', null); | ||
} | ||
}]); | ||
return RouteHandler; | ||
@@ -86,0 +94,0 @@ })(React.Component); |
@@ -1,31 +0,31 @@ | ||
"use strict"; | ||
/* jshint -W058 */ | ||
var React = require("react"); | ||
var warning = require("react/lib/warning"); | ||
var invariant = require("react/lib/invariant"); | ||
var canUseDOM = require("react/lib/ExecutionEnvironment").canUseDOM; | ||
var LocationActions = require("./actions/LocationActions"); | ||
var ImitateBrowserBehavior = require("./behaviors/ImitateBrowserBehavior"); | ||
var HashLocation = require("./locations/HashLocation"); | ||
var HistoryLocation = require("./locations/HistoryLocation"); | ||
var RefreshLocation = require("./locations/RefreshLocation"); | ||
var StaticLocation = require("./locations/StaticLocation"); | ||
var ScrollHistory = require("./ScrollHistory"); | ||
var createRoutesFromReactChildren = require("./createRoutesFromReactChildren"); | ||
var isReactChildren = require("./isReactChildren"); | ||
var Transition = require("./Transition"); | ||
var PropTypes = require("./PropTypes"); | ||
var Redirect = require("./Redirect"); | ||
var History = require("./History"); | ||
var Cancellation = require("./Cancellation"); | ||
var Match = require("./Match"); | ||
var Route = require("./Route"); | ||
var supportsHistory = require("./supportsHistory"); | ||
var PathUtils = require("./PathUtils"); | ||
'use strict'; | ||
var React = require('react'); | ||
var warning = require('react/lib/warning'); | ||
var invariant = require('react/lib/invariant'); | ||
var canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM; | ||
var LocationActions = require('./actions/LocationActions'); | ||
var ImitateBrowserBehavior = require('./behaviors/ImitateBrowserBehavior'); | ||
var HashLocation = require('./locations/HashLocation'); | ||
var HistoryLocation = require('./locations/HistoryLocation'); | ||
var RefreshLocation = require('./locations/RefreshLocation'); | ||
var StaticLocation = require('./locations/StaticLocation'); | ||
var ScrollHistory = require('./ScrollHistory'); | ||
var createRoutesFromReactChildren = require('./createRoutesFromReactChildren'); | ||
var isReactChildren = require('./isReactChildren'); | ||
var Transition = require('./Transition'); | ||
var PropTypes = require('./PropTypes'); | ||
var Redirect = require('./Redirect'); | ||
var History = require('./History'); | ||
var Cancellation = require('./Cancellation'); | ||
var Match = require('./Match'); | ||
var Route = require('./Route'); | ||
var supportsHistory = require('./supportsHistory'); | ||
var PathUtils = require('./PathUtils'); | ||
/** | ||
* The default location for new routers. | ||
*/ | ||
var DEFAULT_LOCATION = canUseDOM ? HashLocation : "/"; | ||
var DEFAULT_LOCATION = canUseDOM ? HashLocation : '/'; | ||
@@ -68,3 +68,3 @@ /** | ||
if (route.name) { | ||
invariant(namedRoutes[route.name] == null, "You may not have more than one route named \"%s\"", route.name); | ||
invariant(namedRoutes[route.name] == null, 'You may not have more than one route named "%s"', route.name); | ||
@@ -127,8 +127,8 @@ namedRoutes[route.name] = route; | ||
if (typeof location === "string") location = new StaticLocation(location); | ||
if (typeof location === 'string') location = new StaticLocation(location); | ||
if (location instanceof StaticLocation) { | ||
warning(!canUseDOM || process.env.NODE_ENV === "test", "You should not use a static location in a DOM environment because " + "the router will not be kept in sync with the current URL"); | ||
warning(!canUseDOM || process.env.NODE_ENV === 'test', 'You should not use a static location in a DOM environment because ' + 'the router will not be kept in sync with the current URL'); | ||
} else { | ||
invariant(canUseDOM || location.needsDOM === false, "You cannot use %s without a DOM", location); | ||
invariant(canUseDOM || location.needsDOM === false, 'You cannot use %s without a DOM', location); | ||
} | ||
@@ -142,3 +142,3 @@ | ||
displayName: "Router", | ||
displayName: 'Router', | ||
@@ -202,3 +202,3 @@ statics: { | ||
invariant(route instanceof Route, "Cannot find a route named \"%s\"", to); | ||
invariant(route instanceof Route, 'Cannot find a route named "%s"', to); | ||
@@ -217,3 +217,3 @@ path = route.path; | ||
var path = Router.makePath(to, params, query); | ||
return location === HashLocation ? "#" + path : path; | ||
return location === HashLocation ? '#' + path : path; | ||
}, | ||
@@ -261,3 +261,3 @@ | ||
warning(false, "goBack() was ignored because there is no router history"); | ||
warning(false, 'goBack() was ignored because there is no router history'); | ||
@@ -268,3 +268,3 @@ return false; | ||
handleAbort: options.onAbort || function (abortReason) { | ||
if (location instanceof StaticLocation) throw new Error("Unhandled aborted transition! Reason: " + abortReason); | ||
if (location instanceof StaticLocation) throw new Error('Unhandled aborted transition! Reason: ' + abortReason); | ||
@@ -321,3 +321,3 @@ if (abortReason instanceof Cancellation) { | ||
warning(match != null, "No route matches path \"%s\". Make sure you have <Route path=\"%s\"> somewhere in your routes", path, path); | ||
warning(match != null, 'No route matches path "%s". Make sure you have <Route path="%s"> somewhere in your routes', path, path); | ||
@@ -377,3 +377,3 @@ if (match == null) match = {}; | ||
run: function run(callback) { | ||
invariant(!Router.isRunning, "Router is already running"); | ||
invariant(!Router.isRunning, 'Router is already running'); | ||
@@ -380,0 +380,0 @@ dispatchHandler = function (error, transition, newState) { |
@@ -1,14 +0,14 @@ | ||
"use strict"; | ||
/* jshint -W084 */ | ||
var React = require("react"); | ||
var assign = require("react/lib/Object.assign"); | ||
var warning = require("react/lib/warning"); | ||
var DefaultRoute = require("./components/DefaultRoute"); | ||
var NotFoundRoute = require("./components/NotFoundRoute"); | ||
var Redirect = require("./components/Redirect"); | ||
var Route = require("./Route"); | ||
'use strict'; | ||
var React = require('react'); | ||
var assign = require('react/lib/Object.assign'); | ||
var warning = require('react/lib/warning'); | ||
var DefaultRoute = require('./components/DefaultRoute'); | ||
var NotFoundRoute = require('./components/NotFoundRoute'); | ||
var Redirect = require('./components/Redirect'); | ||
var Route = require('./Route'); | ||
function checkPropTypes(componentName, propTypes, props) { | ||
componentName = componentName || "UnknownComponent"; | ||
componentName = componentName || 'UnknownComponent'; | ||
@@ -15,0 +15,0 @@ for (var propName in propTypes) { |
@@ -1,5 +0,5 @@ | ||
"use strict"; | ||
'use strict'; | ||
var invariant = require("react/lib/invariant"); | ||
var canUseDOM = require("react/lib/ExecutionEnvironment").canUseDOM; | ||
var invariant = require('react/lib/invariant'); | ||
var canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM; | ||
@@ -10,3 +10,3 @@ /** | ||
function getWindowScrollPosition() { | ||
invariant(canUseDOM, "Cannot get current scroll position without a DOM"); | ||
invariant(canUseDOM, 'Cannot get current scroll position without a DOM'); | ||
@@ -13,0 +13,0 @@ return { |
@@ -1,5 +0,5 @@ | ||
"use strict"; | ||
'use strict'; | ||
var invariant = require("react/lib/invariant"); | ||
var canUseDOM = require("react/lib/ExecutionEnvironment").canUseDOM; | ||
var invariant = require('react/lib/invariant'); | ||
var canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM; | ||
@@ -19,3 +19,3 @@ var History = { | ||
back: function back() { | ||
invariant(canUseDOM, "Cannot use History.back without a DOM"); | ||
invariant(canUseDOM, 'Cannot use History.back without a DOM'); | ||
@@ -22,0 +22,0 @@ // Do this first so that History.length will |
@@ -1,29 +0,31 @@ | ||
"use strict"; | ||
'use strict'; | ||
exports.DefaultRoute = require("./components/DefaultRoute"); | ||
exports.Link = require("./components/Link"); | ||
exports.NotFoundRoute = require("./components/NotFoundRoute"); | ||
exports.Redirect = require("./components/Redirect"); | ||
exports.Route = require("./components/Route"); | ||
exports.RouteHandler = require("./components/RouteHandler"); | ||
exports.DefaultRoute = require('./components/DefaultRoute'); | ||
exports.Link = require('./components/Link'); | ||
exports.NotFoundRoute = require('./components/NotFoundRoute'); | ||
exports.Redirect = require('./components/Redirect'); | ||
exports.Route = require('./components/Route'); | ||
exports.ActiveHandler = require('./components/RouteHandler'); | ||
exports.RouteHandler = exports.ActiveHandler; | ||
exports.HashLocation = require("./locations/HashLocation"); | ||
exports.HistoryLocation = require("./locations/HistoryLocation"); | ||
exports.RefreshLocation = require("./locations/RefreshLocation"); | ||
exports.StaticLocation = require("./locations/StaticLocation"); | ||
exports.TestLocation = require("./locations/TestLocation"); | ||
exports.HashLocation = require('./locations/HashLocation'); | ||
exports.HistoryLocation = require('./locations/HistoryLocation'); | ||
exports.RefreshLocation = require('./locations/RefreshLocation'); | ||
exports.StaticLocation = require('./locations/StaticLocation'); | ||
exports.TestLocation = require('./locations/TestLocation'); | ||
exports.ImitateBrowserBehavior = require("./behaviors/ImitateBrowserBehavior"); | ||
exports.ScrollToTopBehavior = require("./behaviors/ScrollToTopBehavior"); | ||
exports.ImitateBrowserBehavior = require('./behaviors/ImitateBrowserBehavior'); | ||
exports.ScrollToTopBehavior = require('./behaviors/ScrollToTopBehavior'); | ||
exports.History = require("./History"); | ||
exports.Navigation = require("./Navigation"); | ||
exports.State = require("./State"); | ||
exports.History = require('./History'); | ||
exports.Navigation = require('./Navigation'); | ||
exports.State = require('./State'); | ||
exports.createRoute = require("./Route").createRoute; | ||
exports.createDefaultRoute = require("./Route").createDefaultRoute; | ||
exports.createNotFoundRoute = require("./Route").createNotFoundRoute; | ||
exports.createRedirect = require("./Route").createRedirect; | ||
exports.createRoutesFromReactChildren = require("./createRoutesFromReactChildren"); | ||
exports.create = require("./createRouter"); | ||
exports.run = require("./runRouter"); | ||
exports.createRoute = require('./Route').createRoute; | ||
exports.createDefaultRoute = require('./Route').createDefaultRoute; | ||
exports.createNotFoundRoute = require('./Route').createNotFoundRoute; | ||
exports.createRedirect = require('./Route').createRedirect; | ||
exports.createRoutesFromReactChildren = require('./createRoutesFromReactChildren'); | ||
exports.create = require('./createRouter'); | ||
exports.run = require('./runRouter'); |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
var React = require("react"); | ||
var React = require('react'); | ||
@@ -5,0 +5,0 @@ function isValidChild(object) { |
@@ -1,5 +0,5 @@ | ||
"use strict"; | ||
'use strict'; | ||
var LocationActions = require("../actions/LocationActions"); | ||
var History = require("../History"); | ||
var LocationActions = require('../actions/LocationActions'); | ||
var History = require('../History'); | ||
@@ -26,5 +26,5 @@ var _listeners = []; | ||
if (path.charAt(0) === "/") { | ||
if (path.charAt(0) === '/') { | ||
return true; | ||
}HashLocation.replace("/" + path); | ||
}HashLocation.replace('/' + path); | ||
@@ -59,5 +59,5 @@ return false; | ||
if (window.addEventListener) { | ||
window.addEventListener("hashchange", onHashChange, false); | ||
window.addEventListener('hashchange', onHashChange, false); | ||
} else { | ||
window.attachEvent("onhashchange", onHashChange); | ||
window.attachEvent('onhashchange', onHashChange); | ||
} | ||
@@ -76,5 +76,5 @@ | ||
if (window.removeEventListener) { | ||
window.removeEventListener("hashchange", onHashChange, false); | ||
window.removeEventListener('hashchange', onHashChange, false); | ||
} else { | ||
window.removeEvent("onhashchange", onHashChange); | ||
window.removeEvent('onhashchange', onHashChange); | ||
} | ||
@@ -93,3 +93,3 @@ | ||
_actionType = LocationActions.REPLACE; | ||
window.location.replace(window.location.pathname + window.location.search + "#" + path); | ||
window.location.replace(window.location.pathname + window.location.search + '#' + path); | ||
}, | ||
@@ -106,7 +106,7 @@ | ||
// consistent across browsers - Firefox will pre-decode it! | ||
window.location.href.split("#")[1] || ""); | ||
window.location.href.split('#')[1] || ''); | ||
}, | ||
toString: function toString() { | ||
return "<HashLocation>"; | ||
return '<HashLocation>'; | ||
} | ||
@@ -113,0 +113,0 @@ |
@@ -1,5 +0,5 @@ | ||
"use strict"; | ||
'use strict'; | ||
var LocationActions = require("../actions/LocationActions"); | ||
var History = require("../History"); | ||
var LocationActions = require('../actions/LocationActions'); | ||
var History = require('../History'); | ||
@@ -38,5 +38,5 @@ var _listeners = []; | ||
if (window.addEventListener) { | ||
window.addEventListener("popstate", onPopState, false); | ||
window.addEventListener('popstate', onPopState, false); | ||
} else { | ||
window.attachEvent("onpopstate", onPopState); | ||
window.attachEvent('onpopstate', onPopState); | ||
} | ||
@@ -55,5 +55,5 @@ | ||
if (window.addEventListener) { | ||
window.removeEventListener("popstate", onPopState, false); | ||
window.removeEventListener('popstate', onPopState, false); | ||
} else { | ||
window.removeEvent("onpopstate", onPopState); | ||
window.removeEvent('onpopstate', onPopState); | ||
} | ||
@@ -66,3 +66,3 @@ | ||
push: function push(path) { | ||
window.history.pushState({ path: path }, "", path); | ||
window.history.pushState({ path: path }, '', path); | ||
History.length += 1; | ||
@@ -73,3 +73,3 @@ notifyChange(LocationActions.PUSH); | ||
replace: function replace(path) { | ||
window.history.replaceState({ path: path }, "", path); | ||
window.history.replaceState({ path: path }, '', path); | ||
notifyChange(LocationActions.REPLACE); | ||
@@ -85,3 +85,3 @@ }, | ||
toString: function toString() { | ||
return "<HistoryLocation>"; | ||
return '<HistoryLocation>'; | ||
} | ||
@@ -88,0 +88,0 @@ |
@@ -1,5 +0,5 @@ | ||
"use strict"; | ||
'use strict'; | ||
var HistoryLocation = require("./HistoryLocation"); | ||
var History = require("../History"); | ||
var HistoryLocation = require('./HistoryLocation'); | ||
var History = require('../History'); | ||
@@ -26,3 +26,3 @@ /** | ||
toString: function toString() { | ||
return "<RefreshLocation>"; | ||
return '<RefreshLocation>'; | ||
} | ||
@@ -29,0 +29,0 @@ |
@@ -1,11 +0,11 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
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; }; })(); | ||
var invariant = require("react/lib/invariant"); | ||
var invariant = require('react/lib/invariant'); | ||
function throwCannotModify() { | ||
invariant(false, "You cannot modify a static location"); | ||
invariant(false, 'You cannot modify a static location'); | ||
} | ||
@@ -26,14 +26,13 @@ | ||
_createClass(StaticLocation, { | ||
getCurrentPath: { | ||
value: function getCurrentPath() { | ||
return this.path; | ||
} | ||
}, | ||
toString: { | ||
value: function toString() { | ||
return "<StaticLocation path=\"" + this.path + "\">"; | ||
} | ||
_createClass(StaticLocation, [{ | ||
key: 'getCurrentPath', | ||
value: function getCurrentPath() { | ||
return this.path; | ||
} | ||
}); | ||
}, { | ||
key: 'toString', | ||
value: function toString() { | ||
return '<StaticLocation path="' + this.path + '">'; | ||
} | ||
}]); | ||
@@ -40,0 +39,0 @@ return StaticLocation; |
@@ -1,10 +0,10 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
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; }; })(); | ||
var invariant = require("react/lib/invariant"); | ||
var LocationActions = require("../actions/LocationActions"); | ||
var History = require("../History"); | ||
var invariant = require('react/lib/invariant'); | ||
var LocationActions = require('../actions/LocationActions'); | ||
var History = require('../History'); | ||
@@ -24,69 +24,68 @@ /** | ||
_createClass(TestLocation, { | ||
needsDOM: { | ||
get: function () { | ||
return false; | ||
} | ||
}, | ||
_updateHistoryLength: { | ||
value: function _updateHistoryLength() { | ||
History.length = this.history.length; | ||
} | ||
}, | ||
_notifyChange: { | ||
value: function _notifyChange(type) { | ||
var change = { | ||
path: this.getCurrentPath(), | ||
type: type | ||
}; | ||
_createClass(TestLocation, [{ | ||
key: 'needsDOM', | ||
get: function () { | ||
return false; | ||
} | ||
}, { | ||
key: '_updateHistoryLength', | ||
value: function _updateHistoryLength() { | ||
History.length = this.history.length; | ||
} | ||
}, { | ||
key: '_notifyChange', | ||
value: function _notifyChange(type) { | ||
var change = { | ||
path: this.getCurrentPath(), | ||
type: type | ||
}; | ||
for (var i = 0, len = this.listeners.length; i < len; ++i) this.listeners[i].call(this, change); | ||
} | ||
}, | ||
addChangeListener: { | ||
value: function addChangeListener(listener) { | ||
this.listeners.push(listener); | ||
} | ||
}, | ||
removeChangeListener: { | ||
value: function removeChangeListener(listener) { | ||
this.listeners = this.listeners.filter(function (l) { | ||
return l !== listener; | ||
}); | ||
} | ||
}, | ||
push: { | ||
value: function push(path) { | ||
this.history.push(path); | ||
this._updateHistoryLength(); | ||
this._notifyChange(LocationActions.PUSH); | ||
} | ||
}, | ||
replace: { | ||
value: function replace(path) { | ||
invariant(this.history.length, "You cannot replace the current path with no history"); | ||
for (var i = 0, len = this.listeners.length; i < len; ++i) this.listeners[i].call(this, change); | ||
} | ||
}, { | ||
key: 'addChangeListener', | ||
value: function addChangeListener(listener) { | ||
this.listeners.push(listener); | ||
} | ||
}, { | ||
key: 'removeChangeListener', | ||
value: function removeChangeListener(listener) { | ||
this.listeners = this.listeners.filter(function (l) { | ||
return l !== listener; | ||
}); | ||
} | ||
}, { | ||
key: 'push', | ||
value: function push(path) { | ||
this.history.push(path); | ||
this._updateHistoryLength(); | ||
this._notifyChange(LocationActions.PUSH); | ||
} | ||
}, { | ||
key: 'replace', | ||
value: function replace(path) { | ||
invariant(this.history.length, 'You cannot replace the current path with no history'); | ||
this.history[this.history.length - 1] = path; | ||
this.history[this.history.length - 1] = path; | ||
this._notifyChange(LocationActions.REPLACE); | ||
} | ||
}, | ||
pop: { | ||
value: function pop() { | ||
this.history.pop(); | ||
this._updateHistoryLength(); | ||
this._notifyChange(LocationActions.POP); | ||
} | ||
}, | ||
getCurrentPath: { | ||
value: function getCurrentPath() { | ||
return this.history[this.history.length - 1]; | ||
} | ||
}, | ||
toString: { | ||
value: function toString() { | ||
return "<TestLocation>"; | ||
} | ||
this._notifyChange(LocationActions.REPLACE); | ||
} | ||
}); | ||
}, { | ||
key: 'pop', | ||
value: function pop() { | ||
this.history.pop(); | ||
this._updateHistoryLength(); | ||
this._notifyChange(LocationActions.POP); | ||
} | ||
}, { | ||
key: 'getCurrentPath', | ||
value: function getCurrentPath() { | ||
return this.history[this.history.length - 1]; | ||
} | ||
}, { | ||
key: 'toString', | ||
value: function toString() { | ||
return '<TestLocation>'; | ||
} | ||
}]); | ||
@@ -93,0 +92,0 @@ return TestLocation; |
@@ -1,9 +0,9 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
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; }; })(); | ||
/* jshint -W084 */ | ||
var PathUtils = require("./PathUtils"); | ||
var PathUtils = require('./PathUtils'); | ||
@@ -53,22 +53,20 @@ function deepSearch(route, pathname, query) { | ||
_createClass(Match, null, { | ||
findMatch: { | ||
_createClass(Match, null, [{ | ||
key: 'findMatch', | ||
/** | ||
* Attempts to match depth-first a route in the given route's | ||
* subtree against the given path and returns the match if it | ||
* succeeds, null if no match can be made. | ||
*/ | ||
/** | ||
* Attempts to match depth-first a route in the given route's | ||
* subtree against the given path and returns the match if it | ||
* succeeds, null if no match can be made. | ||
*/ | ||
value: function findMatch(routes, path) { | ||
var pathname = PathUtils.withoutQuery(path); | ||
var query = PathUtils.extractQuery(path); | ||
var match = null; | ||
value: function findMatch(routes, path) { | ||
var pathname = PathUtils.withoutQuery(path); | ||
var query = PathUtils.extractQuery(path); | ||
var match = null; | ||
for (var i = 0, len = routes.length; match == null && i < len; ++i) match = deepSearch(routes[i], pathname, query); | ||
for (var i = 0, len = routes.length; match == null && i < len; ++i) match = deepSearch(routes[i], pathname, query); | ||
return match; | ||
} | ||
return match; | ||
} | ||
}); | ||
}]); | ||
@@ -75,0 +73,0 @@ return Match; |
@@ -1,14 +0,5 @@ | ||
"use strict"; | ||
'use strict'; | ||
var warning = require("react/lib/warning"); | ||
var PropTypes = require("./PropTypes"); | ||
var PropTypes = require('./PropTypes'); | ||
function deprecatedMethod(routerMethodName, fn) { | ||
return function () { | ||
warning(false, "Router.Navigation is deprecated. Please use this.context.router." + routerMethodName + "() instead"); | ||
return fn.apply(this, arguments); | ||
}; | ||
} | ||
/** | ||
@@ -42,5 +33,5 @@ * A mixin for components that modify the URL. | ||
*/ | ||
makePath: deprecatedMethod("makePath", function (to, params, query) { | ||
makePath: function makePath(to, params, query) { | ||
return this.context.router.makePath(to, params, query); | ||
}), | ||
}, | ||
@@ -51,5 +42,5 @@ /** | ||
*/ | ||
makeHref: deprecatedMethod("makeHref", function (to, params, query) { | ||
makeHref: function makeHref(to, params, query) { | ||
return this.context.router.makeHref(to, params, query); | ||
}), | ||
}, | ||
@@ -60,5 +51,5 @@ /** | ||
*/ | ||
transitionTo: deprecatedMethod("transitionTo", function (to, params, query) { | ||
transitionTo: function transitionTo(to, params, query) { | ||
this.context.router.transitionTo(to, params, query); | ||
}), | ||
}, | ||
@@ -69,5 +60,5 @@ /** | ||
*/ | ||
replaceWith: deprecatedMethod("replaceWith", function (to, params, query) { | ||
replaceWith: function replaceWith(to, params, query) { | ||
this.context.router.replaceWith(to, params, query); | ||
}), | ||
}, | ||
@@ -77,5 +68,5 @@ /** | ||
*/ | ||
goBack: deprecatedMethod("goBack", function () { | ||
goBack: function goBack() { | ||
return this.context.router.goBack(); | ||
}) | ||
} | ||
@@ -82,0 +73,0 @@ }; |
@@ -1,6 +0,6 @@ | ||
"use strict"; | ||
'use strict'; | ||
var invariant = require("react/lib/invariant"); | ||
var objectAssign = require("object-assign"); | ||
var qs = require("qs"); | ||
var invariant = require('react/lib/invariant'); | ||
var assign = require('object-assign'); | ||
var qs = require('qs'); | ||
@@ -20,8 +20,8 @@ var paramCompileMatcher = /:([a-zA-Z_$][a-zA-Z0-9_$]*)|[*.()\[\]\\+|{}^$]/g; | ||
paramNames.push(paramName); | ||
return "([^/?#]+)"; | ||
} else if (match === "*") { | ||
paramNames.push("splat"); | ||
return "(.*?)"; | ||
return '([^/?#]+)'; | ||
} else if (match === '*') { | ||
paramNames.push('splat'); | ||
return '(.*?)'; | ||
} else { | ||
return "\\" + match; | ||
return '\\' + match; | ||
} | ||
@@ -31,3 +31,3 @@ }); | ||
_compiledPatterns[pattern] = { | ||
matcher: new RegExp("^" + source + "$", "i"), | ||
matcher: new RegExp('^' + source + '$', 'i'), | ||
paramNames: paramNames | ||
@@ -46,3 +46,3 @@ }; | ||
isAbsolute: function isAbsolute(path) { | ||
return path.charAt(0) === "/"; | ||
return path.charAt(0) === '/'; | ||
}, | ||
@@ -54,3 +54,3 @@ | ||
join: function join(a, b) { | ||
return a.replace(/\/*$/, "/") + b; | ||
return a.replace(/\/*$/, '/') + b; | ||
}, | ||
@@ -99,18 +99,18 @@ | ||
return pattern.replace(paramInjectMatcher, function (match, paramName) { | ||
paramName = paramName || "splat"; | ||
paramName = paramName || 'splat'; | ||
// If param is optional don't check for existence | ||
if (paramName.slice(-1) === "?") { | ||
if (paramName.slice(-1) === '?') { | ||
paramName = paramName.slice(0, -1); | ||
if (params[paramName] == null) return ""; | ||
if (params[paramName] == null) return ''; | ||
} else { | ||
invariant(params[paramName] != null, "Missing \"%s\" parameter for path \"%s\"", paramName, pattern); | ||
invariant(params[paramName] != null, 'Missing "%s" parameter for path "%s"', paramName, pattern); | ||
} | ||
var segment; | ||
if (paramName === "splat" && Array.isArray(params[paramName])) { | ||
if (paramName === 'splat' && Array.isArray(params[paramName])) { | ||
segment = params[paramName][splatIndex++]; | ||
invariant(segment != null, "Missing splat # %s for path \"%s\"", splatIndex, pattern); | ||
invariant(segment != null, 'Missing splat # %s for path "%s"', splatIndex, pattern); | ||
} else { | ||
@@ -121,3 +121,3 @@ segment = params[paramName]; | ||
return segment; | ||
}).replace(paramInjectTrailingSlashMatcher, "/"); | ||
}).replace(paramInjectTrailingSlashMatcher, '/'); | ||
}, | ||
@@ -138,3 +138,3 @@ | ||
withoutQuery: function withoutQuery(path) { | ||
return path.replace(queryMatcher, ""); | ||
return path.replace(queryMatcher, ''); | ||
}, | ||
@@ -149,8 +149,8 @@ | ||
if (existingQuery) query = query ? objectAssign(existingQuery, query) : existingQuery; | ||
if (existingQuery) query = query ? assign(existingQuery, query) : existingQuery; | ||
var queryString = qs.stringify(query, { arrayFormat: "brackets" }); | ||
var queryString = qs.stringify(query, { arrayFormat: 'brackets' }); | ||
if (queryString) { | ||
return PathUtils.withoutQuery(path) + "?" + queryString; | ||
return PathUtils.withoutQuery(path) + '?' + queryString; | ||
}return PathUtils.withoutQuery(path); | ||
@@ -157,0 +157,0 @@ } |
@@ -1,6 +0,6 @@ | ||
"use strict"; | ||
'use strict'; | ||
var assign = require("react/lib/Object.assign"); | ||
var ReactPropTypes = require("react").PropTypes; | ||
var Route = require("./Route"); | ||
var assign = require('react/lib/Object.assign'); | ||
var ReactPropTypes = require('react').PropTypes; | ||
var Route = require('./Route'); | ||
@@ -14,3 +14,3 @@ var PropTypes = assign({}, ReactPropTypes, { | ||
if (props[propName]) { | ||
return new Error("<" + componentName + "> may not have a \"" + propName + "\" prop"); | ||
return new Error('<' + componentName + '> should not have a "' + propName + '" prop'); | ||
} | ||
@@ -17,0 +17,0 @@ }, |
@@ -1,6 +0,6 @@ | ||
"use strict"; | ||
/** | ||
* Encapsulates a redirect to the given route. | ||
*/ | ||
"use strict"; | ||
function Redirect(to, params, query) { | ||
@@ -7,0 +7,0 @@ this.to = to; |
293
lib/Route.js
@@ -1,11 +0,11 @@ | ||
"use strict"; | ||
'use strict'; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; | ||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; | ||
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; }; })(); | ||
var assign = require("react/lib/Object.assign"); | ||
var invariant = require("react/lib/invariant"); | ||
var warning = require("react/lib/warning"); | ||
var PathUtils = require("./PathUtils"); | ||
var assign = require('react/lib/Object.assign'); | ||
var invariant = require('react/lib/invariant'); | ||
var warning = require('react/lib/warning'); | ||
var PathUtils = require('./PathUtils'); | ||
@@ -29,176 +29,169 @@ var _currentRoute; | ||
_createClass(Route, { | ||
appendChild: { | ||
_createClass(Route, [{ | ||
key: 'appendChild', | ||
/** | ||
* Appends the given route to this route's child routes. | ||
*/ | ||
/** | ||
* Appends the given route to this route's child routes. | ||
*/ | ||
value: function appendChild(route) { | ||
invariant(route instanceof Route, 'route.appendChild must use a valid Route'); | ||
value: function appendChild(route) { | ||
invariant(route instanceof Route, "route.appendChild must use a valid Route"); | ||
if (!this.childRoutes) this.childRoutes = []; | ||
if (!this.childRoutes) this.childRoutes = []; | ||
this.childRoutes.push(route); | ||
} | ||
}, { | ||
key: 'toString', | ||
value: function toString() { | ||
var string = '<Route'; | ||
this.childRoutes.push(route); | ||
} | ||
}, | ||
toString: { | ||
value: function toString() { | ||
var string = "<Route"; | ||
if (this.name) string += ' name="' + this.name + '"'; | ||
if (this.name) string += " name=\"" + this.name + "\""; | ||
string += ' path="' + this.path + '">'; | ||
string += " path=\"" + this.path + "\">"; | ||
return string; | ||
} | ||
return string; | ||
} | ||
}, { | ||
createRoute: { | ||
}], [{ | ||
key: 'createRoute', | ||
/** | ||
* Creates and returns a new route. Options may be a URL pathname string | ||
* with placeholders for named params or an object with any of the following | ||
* properties: | ||
* | ||
* - name The name of the route. This is used to lookup a | ||
* route relative to its parent route and should be | ||
* unique among all child routes of the same parent | ||
* - path A URL pathname string with optional placeholders | ||
* that specify the names of params to extract from | ||
* the URL when the path matches. Defaults to `/${name}` | ||
* when there is a name given, or the path of the parent | ||
* route, or / | ||
* - ignoreScrollBehavior True to make this route (and all descendants) ignore | ||
* the scroll behavior of the router | ||
* - isDefault True to make this route the default route among all | ||
* its siblings | ||
* - isNotFound True to make this route the "not found" route among | ||
* all its siblings | ||
* - onEnter A transition hook that will be called when the | ||
* router is going to enter this route | ||
* - onLeave A transition hook that will be called when the | ||
* router is going to leave this route | ||
* - handler A React component that will be rendered when | ||
* this route is active | ||
* - parentRoute The parent route to use for this route. This option | ||
* is automatically supplied when creating routes inside | ||
* the callback to another invocation of createRoute. You | ||
* only ever need to use this when declaring routes | ||
* independently of one another to manually piece together | ||
* the route hierarchy | ||
* | ||
* The callback may be used to structure your route hierarchy. Any call to | ||
* createRoute, createDefaultRoute, createNotFoundRoute, or createRedirect | ||
* inside the callback automatically uses this route as its parent. | ||
*/ | ||
/** | ||
* Creates and returns a new route. Options may be a URL pathname string | ||
* with placeholders for named params or an object with any of the following | ||
* properties: | ||
* | ||
* - name The name of the route. This is used to lookup a | ||
* route relative to its parent route and should be | ||
* unique among all child routes of the same parent | ||
* - path A URL pathname string with optional placeholders | ||
* that specify the names of params to extract from | ||
* the URL when the path matches. Defaults to `/${name}` | ||
* when there is a name given, or the path of the parent | ||
* route, or / | ||
* - ignoreScrollBehavior True to make this route (and all descendants) ignore | ||
* the scroll behavior of the router | ||
* - isDefault True to make this route the default route among all | ||
* its siblings | ||
* - isNotFound True to make this route the "not found" route among | ||
* all its siblings | ||
* - onEnter A transition hook that will be called when the | ||
* router is going to enter this route | ||
* - onLeave A transition hook that will be called when the | ||
* router is going to leave this route | ||
* - handler A React component that will be rendered when | ||
* this route is active | ||
* - parentRoute The parent route to use for this route. This option | ||
* is automatically supplied when creating routes inside | ||
* the callback to another invocation of createRoute. You | ||
* only ever need to use this when declaring routes | ||
* independently of one another to manually piece together | ||
* the route hierarchy | ||
* | ||
* The callback may be used to structure your route hierarchy. Any call to | ||
* createRoute, createDefaultRoute, createNotFoundRoute, or createRedirect | ||
* inside the callback automatically uses this route as its parent. | ||
*/ | ||
value: function createRoute(options, callback) { | ||
options = options || {}; | ||
value: function createRoute(options, callback) { | ||
options = options || {}; | ||
if (typeof options === 'string') options = { path: options }; | ||
if (typeof options === "string") options = { path: options }; | ||
var parentRoute = _currentRoute; | ||
var parentRoute = _currentRoute; | ||
if (parentRoute) { | ||
warning(options.parentRoute == null || options.parentRoute === parentRoute, 'You should not use parentRoute with createRoute inside another route\'s child callback; it is ignored'); | ||
} else { | ||
parentRoute = options.parentRoute; | ||
} | ||
if (parentRoute) { | ||
warning(options.parentRoute == null || options.parentRoute === parentRoute, "You should not use parentRoute with createRoute inside another route's child callback; it is ignored"); | ||
} else { | ||
parentRoute = options.parentRoute; | ||
} | ||
var name = options.name; | ||
var path = options.path || name; | ||
var name = options.name; | ||
var path = options.path || name; | ||
if (path && !(options.isDefault || options.isNotFound)) { | ||
if (PathUtils.isAbsolute(path)) { | ||
if (parentRoute) { | ||
invariant(path === parentRoute.path || parentRoute.paramNames.length === 0, "You cannot nest path \"%s\" inside \"%s\"; the parent requires URL parameters", path, parentRoute.path); | ||
} | ||
} else if (parentRoute) { | ||
// Relative paths extend their parent. | ||
path = PathUtils.join(parentRoute.path, path); | ||
} else { | ||
path = "/" + path; | ||
if (path && !(options.isDefault || options.isNotFound)) { | ||
if (PathUtils.isAbsolute(path)) { | ||
if (parentRoute) { | ||
invariant(path === parentRoute.path || parentRoute.paramNames.length === 0, 'You cannot nest path "%s" inside "%s"; the parent requires URL parameters', path, parentRoute.path); | ||
} | ||
} else if (parentRoute) { | ||
// Relative paths extend their parent. | ||
path = PathUtils.join(parentRoute.path, path); | ||
} else { | ||
path = parentRoute ? parentRoute.path : "/"; | ||
path = '/' + path; | ||
} | ||
} else { | ||
path = parentRoute ? parentRoute.path : '/'; | ||
} | ||
if (options.isNotFound && !/\*$/.test(path)) path += "*"; // Auto-append * to the path of not found routes. | ||
if (options.isNotFound && !/\*$/.test(path)) path += '*'; // Auto-append * to the path of not found routes. | ||
var route = new Route(name, path, options.ignoreScrollBehavior, options.isDefault, options.isNotFound, options.onEnter, options.onLeave, options.handler); | ||
var route = new Route(name, path, options.ignoreScrollBehavior, options.isDefault, options.isNotFound, options.onEnter, options.onLeave, options.handler); | ||
if (parentRoute) { | ||
if (route.isDefault) { | ||
invariant(parentRoute.defaultRoute == null, "%s may not have more than one default route", parentRoute); | ||
if (parentRoute) { | ||
if (route.isDefault) { | ||
invariant(parentRoute.defaultRoute == null, '%s may not have more than one default route', parentRoute); | ||
parentRoute.defaultRoute = route; | ||
} else if (route.isNotFound) { | ||
invariant(parentRoute.notFoundRoute == null, "%s may not have more than one not found route", parentRoute); | ||
parentRoute.defaultRoute = route; | ||
} else if (route.isNotFound) { | ||
invariant(parentRoute.notFoundRoute == null, '%s may not have more than one not found route', parentRoute); | ||
parentRoute.notFoundRoute = route; | ||
} | ||
parentRoute.appendChild(route); | ||
parentRoute.notFoundRoute = route; | ||
} | ||
// Any routes created in the callback | ||
// use this route as their parent. | ||
if (typeof callback === "function") { | ||
var currentRoute = _currentRoute; | ||
_currentRoute = route; | ||
callback.call(route, route); | ||
_currentRoute = currentRoute; | ||
} | ||
return route; | ||
parentRoute.appendChild(route); | ||
} | ||
}, | ||
createDefaultRoute: { | ||
/** | ||
* Creates and returns a route that is rendered when its parent matches | ||
* the current URL. | ||
*/ | ||
value: function createDefaultRoute(options) { | ||
return Route.createRoute(assign({}, options, { isDefault: true })); | ||
// Any routes created in the callback | ||
// use this route as their parent. | ||
if (typeof callback === 'function') { | ||
var currentRoute = _currentRoute; | ||
_currentRoute = route; | ||
callback.call(route, route); | ||
_currentRoute = currentRoute; | ||
} | ||
}, | ||
createNotFoundRoute: { | ||
/** | ||
* Creates and returns a route that is rendered when its parent matches | ||
* the current URL but none of its siblings do. | ||
*/ | ||
return route; | ||
} | ||
}, { | ||
key: 'createDefaultRoute', | ||
value: function createNotFoundRoute(options) { | ||
return Route.createRoute(assign({}, options, { isNotFound: true })); | ||
} | ||
}, | ||
createRedirect: { | ||
/** | ||
* Creates and returns a route that is rendered when its parent matches | ||
* the current URL. | ||
*/ | ||
value: function createDefaultRoute(options) { | ||
return Route.createRoute(assign({}, options, { isDefault: true })); | ||
} | ||
}, { | ||
key: 'createNotFoundRoute', | ||
/** | ||
* Creates and returns a route that automatically redirects the transition | ||
* to another route. In addition to the normal options to createRoute, this | ||
* function accepts the following options: | ||
* | ||
* - from An alias for the `path` option. Defaults to * | ||
* - to The path/route/route name to redirect to | ||
* - params The params to use in the redirect URL. Defaults | ||
* to using the current params | ||
* - query The query to use in the redirect URL. Defaults | ||
* to using the current query | ||
*/ | ||
/** | ||
* Creates and returns a route that is rendered when its parent matches | ||
* the current URL but none of its siblings do. | ||
*/ | ||
value: function createNotFoundRoute(options) { | ||
return Route.createRoute(assign({}, options, { isNotFound: true })); | ||
} | ||
}, { | ||
key: 'createRedirect', | ||
value: function createRedirect(options) { | ||
return Route.createRoute(assign({}, options, { | ||
path: options.path || options.from || "*", | ||
onEnter: function onEnter(transition, params, query) { | ||
transition.redirect(options.to, options.params || params, options.query || query); | ||
} | ||
})); | ||
} | ||
/** | ||
* Creates and returns a route that automatically redirects the transition | ||
* to another route. In addition to the normal options to createRoute, this | ||
* function accepts the following options: | ||
* | ||
* - from An alias for the `path` option. Defaults to * | ||
* - to The path/route/route name to redirect to | ||
* - params The params to use in the redirect URL. Defaults | ||
* to using the current params | ||
* - query The query to use in the redirect URL. Defaults | ||
* to using the current query | ||
*/ | ||
value: function createRedirect(options) { | ||
return Route.createRoute(assign({}, options, { | ||
path: options.path || options.from || '*', | ||
onEnter: function onEnter(transition, params, query) { | ||
transition.redirect(options.to, options.params || params, options.query || query); | ||
} | ||
})); | ||
} | ||
}); | ||
}]); | ||
@@ -205,0 +198,0 @@ return Route; |
@@ -1,4 +0,4 @@ | ||
"use strict"; | ||
'use strict'; | ||
var createRouter = require("./createRouter"); | ||
var createRouter = require('./createRouter'); | ||
@@ -35,3 +35,3 @@ /** | ||
function runRouter(routes, location, callback) { | ||
if (typeof location === "function") { | ||
if (typeof location === 'function') { | ||
callback = location; | ||
@@ -38,0 +38,0 @@ location = null; |
@@ -1,6 +0,6 @@ | ||
"use strict"; | ||
'use strict'; | ||
var invariant = require("react/lib/invariant"); | ||
var canUseDOM = require("react/lib/ExecutionEnvironment").canUseDOM; | ||
var getWindowScrollPosition = require("./getWindowScrollPosition"); | ||
var invariant = require('react/lib/invariant'); | ||
var canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM; | ||
var getWindowScrollPosition = require('./getWindowScrollPosition'); | ||
@@ -54,3 +54,3 @@ function shouldUpdateScroll(state, prevState) { | ||
componentWillMount: function componentWillMount() { | ||
invariant(this.constructor.getScrollBehavior() == null || canUseDOM, "Cannot use scroll behavior without a DOM"); | ||
invariant(this.constructor.getScrollBehavior() == null || canUseDOM, 'Cannot use scroll behavior without a DOM'); | ||
}, | ||
@@ -57,0 +57,0 @@ |
@@ -1,14 +0,5 @@ | ||
"use strict"; | ||
'use strict'; | ||
var warning = require("react/lib/warning"); | ||
var PropTypes = require("./PropTypes"); | ||
var PropTypes = require('./PropTypes'); | ||
function deprecatedMethod(routerMethodName, fn) { | ||
return function () { | ||
warning(false, "Router.State is deprecated. Please use this.context.router." + routerMethodName + "() instead"); | ||
return fn.apply(this, arguments); | ||
}; | ||
} | ||
/** | ||
@@ -24,6 +15,6 @@ * A mixin for components that need to know the path, routes, URL | ||
* var className = this.props.className; | ||
* | ||
* | ||
* if (this.isActive('about')) | ||
* className += ' is-active'; | ||
* | ||
* | ||
* return React.DOM.a({ className: className }, this.props.children); | ||
@@ -42,5 +33,5 @@ * } | ||
*/ | ||
getPath: deprecatedMethod("getCurrentPath", function () { | ||
getPath: function getPath() { | ||
return this.context.router.getCurrentPath(); | ||
}), | ||
}, | ||
@@ -50,5 +41,5 @@ /** | ||
*/ | ||
getPathname: deprecatedMethod("getCurrentPathname", function () { | ||
getPathname: function getPathname() { | ||
return this.context.router.getCurrentPathname(); | ||
}), | ||
}, | ||
@@ -58,5 +49,5 @@ /** | ||
*/ | ||
getParams: deprecatedMethod("getCurrentParams", function () { | ||
getParams: function getParams() { | ||
return this.context.router.getCurrentParams(); | ||
}), | ||
}, | ||
@@ -66,5 +57,5 @@ /** | ||
*/ | ||
getQuery: deprecatedMethod("getCurrentQuery", function () { | ||
getQuery: function getQuery() { | ||
return this.context.router.getCurrentQuery(); | ||
}), | ||
}, | ||
@@ -74,5 +65,5 @@ /** | ||
*/ | ||
getRoutes: deprecatedMethod("getCurrentRoutes", function () { | ||
getRoutes: function getRoutes() { | ||
return this.context.router.getCurrentRoutes(); | ||
}), | ||
}, | ||
@@ -83,5 +74,5 @@ /** | ||
*/ | ||
isActive: deprecatedMethod("isActive", function (to, params, query) { | ||
isActive: function isActive(to, params, query) { | ||
return this.context.router.isActive(to, params, query); | ||
}) | ||
} | ||
@@ -88,0 +79,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -10,8 +10,8 @@ function supportsHistory() { | ||
var ua = navigator.userAgent; | ||
if ((ua.indexOf("Android 2.") !== -1 || ua.indexOf("Android 4.0") !== -1) && ua.indexOf("Mobile Safari") !== -1 && ua.indexOf("Chrome") === -1 && ua.indexOf("Windows Phone") === -1) { | ||
if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) { | ||
return false; | ||
} | ||
return window.history && "pushState" in window.history; | ||
return window.history && 'pushState' in window.history; | ||
} | ||
module.exports = supportsHistory; |
@@ -1,18 +0,18 @@ | ||
"use strict"; | ||
'use strict'; | ||
var React = require("react"); | ||
var RouteHandler = require("./components/RouteHandler"); | ||
var PropTypes = require("./PropTypes"); | ||
var React = require('react'); | ||
var RouteHandler = require('./components/RouteHandler'); | ||
var PropTypes = require('./PropTypes'); | ||
exports.Nested = React.createClass({ | ||
displayName: "Nested", | ||
displayName: 'Nested', | ||
render: function render() { | ||
return React.createElement( | ||
"div", | ||
'div', | ||
null, | ||
React.createElement( | ||
"h1", | ||
{ className: "Nested" }, | ||
"Nested" | ||
'h1', | ||
{ className: 'Nested' }, | ||
'Nested' | ||
), | ||
@@ -25,9 +25,9 @@ React.createElement(RouteHandler, null) | ||
exports.Foo = React.createClass({ | ||
displayName: "Foo", | ||
displayName: 'Foo', | ||
render: function render() { | ||
return React.createElement( | ||
"div", | ||
{ className: "Foo" }, | ||
"Foo" | ||
'div', | ||
{ className: 'Foo' }, | ||
'Foo' | ||
); | ||
@@ -38,9 +38,9 @@ } | ||
exports.Bar = React.createClass({ | ||
displayName: "Bar", | ||
displayName: 'Bar', | ||
render: function render() { | ||
return React.createElement( | ||
"div", | ||
{ className: "Bar" }, | ||
"Bar" | ||
'div', | ||
{ className: 'Bar' }, | ||
'Bar' | ||
); | ||
@@ -51,9 +51,9 @@ } | ||
exports.Baz = React.createClass({ | ||
displayName: "Baz", | ||
displayName: 'Baz', | ||
render: function render() { | ||
return React.createElement( | ||
"div", | ||
{ className: "Baz" }, | ||
"Baz" | ||
'div', | ||
{ className: 'Baz' }, | ||
'Baz' | ||
); | ||
@@ -64,3 +64,3 @@ } | ||
exports.Async = React.createClass({ | ||
displayName: "Async", | ||
displayName: 'Async', | ||
@@ -77,5 +77,5 @@ statics: { | ||
return React.createElement( | ||
"div", | ||
{ className: "Async" }, | ||
"Async" | ||
'div', | ||
{ className: 'Async' }, | ||
'Async' | ||
); | ||
@@ -86,7 +86,7 @@ } | ||
exports.RedirectToFoo = React.createClass({ | ||
displayName: "RedirectToFoo", | ||
displayName: 'RedirectToFoo', | ||
statics: { | ||
willTransitionTo: function willTransitionTo(transition) { | ||
transition.redirect("/foo"); | ||
transition.redirect('/foo'); | ||
} | ||
@@ -101,3 +101,3 @@ }, | ||
exports.RedirectToFooAsync = React.createClass({ | ||
displayName: "RedirectToFooAsync", | ||
displayName: 'RedirectToFooAsync', | ||
@@ -109,3 +109,3 @@ statics: { | ||
setTimeout(function () { | ||
transition.redirect("/foo"); | ||
transition.redirect('/foo'); | ||
callback(); | ||
@@ -122,3 +122,3 @@ }, exports.RedirectToFooAsync.delay); | ||
exports.Abort = React.createClass({ | ||
displayName: "Abort", | ||
displayName: 'Abort', | ||
@@ -137,3 +137,3 @@ statics: { | ||
exports.AbortAsync = React.createClass({ | ||
displayName: "AbortAsync", | ||
displayName: 'AbortAsync', | ||
@@ -157,7 +157,7 @@ statics: { | ||
exports.EchoFooProp = React.createClass({ | ||
displayName: "EchoFooProp", | ||
displayName: 'EchoFooProp', | ||
render: function render() { | ||
return React.createElement( | ||
"div", | ||
'div', | ||
null, | ||
@@ -170,3 +170,3 @@ this.props.foo | ||
exports.EchoBarParam = React.createClass({ | ||
displayName: "EchoBarParam", | ||
displayName: 'EchoBarParam', | ||
@@ -178,4 +178,4 @@ contextTypes: { | ||
return React.createElement( | ||
"div", | ||
{ className: "EchoBarParam" }, | ||
'div', | ||
{ className: 'EchoBarParam' }, | ||
this.context.router.getCurrentParams().bar | ||
@@ -182,0 +182,0 @@ ); |
@@ -1,8 +0,8 @@ | ||
"use strict"; | ||
/* jshint -W058 */ | ||
var Cancellation = require("./Cancellation"); | ||
var Redirect = require("./Redirect"); | ||
'use strict'; | ||
var Cancellation = require('./Cancellation'); | ||
var Redirect = require('./Redirect'); | ||
/** | ||
@@ -22,3 +22,3 @@ * Encapsulates a transition to a given path. | ||
Transition.prototype.abort = function (reason) { | ||
if (this.abortReason == null) this.abortReason = reason || "ABORT"; | ||
if (this.abortReason == null) this.abortReason = reason || 'ABORT'; | ||
}; | ||
@@ -25,0 +25,0 @@ |
{ | ||
"name": "react-router", | ||
"version": "0.13.2", | ||
"version": "0.13.3", | ||
"description": "A complete routing library for React.js", | ||
@@ -21,5 +21,4 @@ "main": "lib", | ||
"dependencies": { | ||
"qs": "2.4.1", | ||
"classnames": "1.1.x", | ||
"object-assign": "^2.0.0" | ||
"object-assign": "^2.0.0", | ||
"qs": "2.4.1" | ||
}, | ||
@@ -26,0 +25,0 @@ "tags": [ |
[![npm package](https://img.shields.io/npm/v/react-router.svg?style=flat-square)](https://www.npmjs.org/package/react-router) | ||
[![build status](https://img.shields.io/travis/rackt/react-router/master.svg?style=flat-square)](https://travis-ci.org/rackt/react-router) | ||
[![dependency status](https://img.shields.io/david/rackt/react-router.svg?style=flat-square)](https://david-dm.org/rackt/react-router) | ||
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/rackt/react-router?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) | ||
@@ -5,0 +6,0 @@ React Router |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
226904
3
39
5000
141
3
1
- Removedclassnames@1.1.x
- Removedclassnames@1.1.4(transitive)