Skip to content
This repository has been archived by the owner on May 23, 2018. It is now read-only.

Commit

Permalink
fix; add children to link and pass listener params in mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
troch committed Jul 7, 2015
1 parent 1c1b242 commit 2c641fd
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "router5-react",
"version": "0.1.0-alpha.4",
"version": "0.1.0-alpha.5",
"homepage": "http://router5.github.io",
"authors": [
"Thomas Roch <thomas.c.roch@gmail.com>"
Expand Down
8 changes: 4 additions & 4 deletions dist/amd/link-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ define(['exports', 'module', 'react'], function (exports, module, _react) {
className: '',
activeClassName: 'active',
routeParams: {},
routeOptions: {},
onClick: this.clickHandler
routeOptions: {}
};
},

Expand Down Expand Up @@ -66,9 +65,10 @@ define(['exports', 'module', 'react'], function (exports, module, _react) {
var active = this.state.active;

var href = router.buildUrl(props.routeName, props.routeParams);
var className = props.className.split(' ').concat(active ? [props.activeClassName] : []).join(' ');
var className = (props.className ? props.className.split(' ') : []).concat(active ? [props.activeClassName] : []).join(' ');
var onClick = props.onClick || this.clickHandler;

return _React['default'].createElement('a', { href: href, className: props.className, onClick: props.onClick });
return _React['default'].createElement('a', { href: href, className: className, onClick: onClick }, props.children);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions dist/amd/segment-mixin-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ define(["exports", "module"], function (exports, module) {
function segmentMixinFactory(router) {
return function (routeName, listener) {
return {
nodeListener: function nodeListener() {
listener.call(this);
nodeListener: function nodeListener(toState, fromState) {
listener.call(this, toState, fromState);
},

componentDidMount: function componentDidMount() {
Expand Down
12 changes: 6 additions & 6 deletions dist/browser/router5-react.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ function linkFactory(router) {
className: '',
activeClassName: 'active',
routeParams: {},
routeOptions: {},
onClick: this.clickHandler
routeOptions: {}
};
},

Expand Down Expand Up @@ -84,17 +83,18 @@ function linkFactory(router) {
var active = this.state.active;

var href = router.buildUrl(props.routeName, props.routeParams);
var className = props.className.split(' ').concat(active ? [props.activeClassName] : []).join(' ');
var className = (props.className ? props.className.split(' ') : []).concat(active ? [props.activeClassName] : []).join(' ');
var onClick = props.onClick || this.clickHandler;

return React.createElement('a', { href: href, className: props.className, onClick: props.onClick });
return React.createElement('a', { href: href, className: className, onClick: onClick }, props.children);
}
});
}
function segmentMixinFactory(router) {
return function (routeName, listener) {
return {
nodeListener: function nodeListener() {
listener.call(this);
nodeListener: function nodeListener(toState, fromState) {
listener.call(this, toState, fromState);
},

componentDidMount: function componentDidMount() {
Expand Down
2 changes: 1 addition & 1 deletion dist/browser/router5-react.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions dist/commonjs/link-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ function linkFactory(router) {
className: '',
activeClassName: 'active',
routeParams: {},
routeOptions: {},
onClick: this.clickHandler
routeOptions: {}
};
},

Expand Down Expand Up @@ -71,9 +70,10 @@ function linkFactory(router) {
var active = this.state.active;

var href = router.buildUrl(props.routeName, props.routeParams);
var className = props.className.split(' ').concat(active ? [props.activeClassName] : []).join(' ');
var className = (props.className ? props.className.split(' ') : []).concat(active ? [props.activeClassName] : []).join(' ');
var onClick = props.onClick || this.clickHandler;

return _react2['default'].createElement('a', { href: href, className: props.className, onClick: props.onClick });
return _react2['default'].createElement('a', { href: href, className: className, onClick: onClick }, props.children);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions dist/commonjs/segment-mixin-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ exports["default"] = segmentMixinFactory;
function segmentMixinFactory(router) {
return function (routeName, listener) {
return {
nodeListener: function nodeListener() {
listener.call(this);
nodeListener: function nodeListener(toState, fromState) {
listener.call(this, toState, fromState);
},

componentDidMount: function componentDidMount() {
Expand Down
10 changes: 5 additions & 5 deletions modules/link-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ function linkFactory(router) {
className: '',
activeClassName: 'active',
routeParams: {},
routeOptions: {},
onClick: this.clickHandler
routeOptions: {}
};
},

Expand Down Expand Up @@ -63,11 +62,12 @@ function linkFactory(router) {
let props = this.props
let active = this.state.active

let href = router.buildUrl(props.routeName, props.routeParams);
let className = props.className.split(' ')
let href = router.buildUrl(props.routeName, props.routeParams)
let className = (props.className ? props.className.split(' ') : [])
.concat(active ? [props.activeClassName] : []).join(' ')
let onClick = props.onClick || this.clickHandler

return React.createElement('a', {href, className: props.className, onClick: props.onClick})
return React.createElement('a', {href, className, onClick}, props.children)
}
})
}
4 changes: 2 additions & 2 deletions modules/segment-mixin-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ export default segmentMixinFactory

function segmentMixinFactory(router) {
return (routeName, listener) => ({
nodeListener() {
listener.call(this)
nodeListener(toState, fromState) {
listener.call(this, toState, fromState)
},

componentDidMount() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "router5-react",
"version": "0.1.0-alpha.4",
"version": "0.1.0-alpha.5",
"description": "router5 helpers for React",
"main": "dist/commonjs/index.js",
"scripts": {
Expand Down

0 comments on commit 2c641fd

Please sign in to comment.