From f3b4de844a387509e0458824aac9e93bd44664f5 Mon Sep 17 00:00:00 2001 From: Frankie Bagnardi Date: Wed, 6 Aug 2014 16:55:24 -0700 Subject: [PATCH 1/2] [added] support for extra props in Links, fixes #170 --- modules/components/Link.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/components/Link.js b/modules/components/Link.js index bf4141ddd4..6fa461af31 100644 --- a/modules/components/Link.js +++ b/modules/components/Link.js @@ -3,7 +3,7 @@ var ActiveState = require('../mixins/ActiveState'); var withoutProperties = require('../helpers/withoutProperties'); var transitionTo = require('../helpers/transitionTo'); var makeHref = require('../helpers/makeHref'); - +var hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty); /** * A map of component props that are reserved for use by the * router and/or React. All other props are used as params that are @@ -124,6 +124,13 @@ var Link = React.createClass({ onClick: this.handleClick }; + // pull in props without overriding + for (var propName in this.props) { + if (hasOwn(this.props, propName) && hasOwn(props, propName) === false) { + props[propName] = this.props[propName]; + } + } + return React.DOM.a(props, this.props.children); } From e3ba108d55765e5c757d25754029d96481733f4d Mon Sep 17 00:00:00 2001 From: Frankie Bagnardi Date: Wed, 6 Aug 2014 16:57:45 -0700 Subject: [PATCH 2/2] updated Link docs to include the mention of aditional props --- docs/api/components/Link.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/api/components/Link.md b/docs/api/components/Link.md index d099aba5bb..6cbb567b1c 100644 --- a/docs/api/components/Link.md +++ b/docs/api/components/Link.md @@ -27,6 +27,10 @@ name through the link's properties to the resulting url. The className a `Link` receives when it's route is active. Defaults to `active`. +### *others* + +You can also pass props you'd like to be on the `` such as a title, id, or className. + Example -------