flux-router-component
Advanced tools
Comparing version 0.5.13 to 0.5.14
# NavLink | ||
`NavLink` is the a React component for navigational links. When the link is clicked, NavLink will dispatch `NAVIGATE` action to flux dispatcher. The dispatcher can then dispatch the action to the stores that can handle it. | ||
| Prop Name | Prop Type | Description | | ||
|------------|---------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| href | String | The url string | | ||
| routeName | String | Not used if `href` is specified. This is the name of the target route, which should be defined in your app's routes. | | ||
| navParams | Object | If `href` prop is not available, `navParams` object will be used together with `routeName` to generate the href for the link. This object needs to contain route params the route path needs. Eg. for a route path `/article/:id`, `navParams.id` will be the article ID. | | ||
| followLink | boolean, default to false | If set to true, client side navigation will be disabled. NavLink will just act like a regular anchor link. | | ||
## Example Usage | ||
@@ -5,0 +13,0 @@ |
@@ -87,2 +87,3 @@ /** | ||
} | ||
this.setTitle(title); | ||
} else if (url) { | ||
@@ -113,5 +114,16 @@ win.location.href = url; | ||
} | ||
this.setTitle(title); | ||
} else if (url) { | ||
win.location.replace(url); | ||
} | ||
}, | ||
/** | ||
* Sets document title. No-op if title is empty. | ||
* @param {String} title The title string. | ||
*/ | ||
setTitle: function (title) { | ||
if (title) { | ||
this.win.document.title = title; | ||
} | ||
} | ||
@@ -118,0 +130,0 @@ }; |
@@ -29,7 +29,15 @@ /** | ||
propTypes: { | ||
context: React.PropTypes.object | ||
context: React.PropTypes.object, | ||
href: React.PropTypes.string, | ||
routeName: React.PropTypes.string, | ||
navParams: React.PropTypes.object, | ||
followLink: React.PropTypes.bool | ||
}, | ||
dispatchNavAction: function (e) { | ||
debug('dispatchNavAction: action=NAVIGATE', this.props.href, this.props.navParams); | ||
debug('dispatchNavAction: action=NAVIGATE', this.props.href, this.props.followLink, this.props.navParams); | ||
if (this.props.followLink) { | ||
return; | ||
} | ||
if (isModifiedEvent(e) || !isLeftClickEvent(e)) { | ||
@@ -36,0 +44,0 @@ // this is a click with a modifier or not a left-click |
@@ -125,5 +125,6 @@ /** | ||
var nav = newState.route.navigate; | ||
var navType = (nav && nav.type) || TYPE_DEFAULT; | ||
var nav = newState.route.navigate || {}; | ||
var navType = nav.type || TYPE_DEFAULT; | ||
var historyState; | ||
var pageTitle; | ||
@@ -133,3 +134,3 @@ switch (navType) { | ||
case TYPE_DEFAULT: | ||
historyState = {params: (nav && nav.params) || {}}; | ||
historyState = {params: (nav.params || {})}; | ||
if (this._enableScroll) { | ||
@@ -140,3 +141,4 @@ window.scrollTo(0, 0); | ||
} | ||
this._history.pushState(historyState, null, newState.route.url); | ||
pageTitle = nav.params && nav.params.pageTitle || null; | ||
this._history.pushState(historyState, pageTitle, newState.route.url); | ||
break; | ||
@@ -143,0 +145,0 @@ case TYPE_POPSTATE: |
{ | ||
"name": "flux-router-component", | ||
"version": "0.5.13", | ||
"version": "0.5.14", | ||
"description": "Router-related React component and mixin for applications with Fluxible architecture", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -133,2 +133,3 @@ /** | ||
history.pushState(state, title, url); | ||
this.setTitle(title); | ||
} else if (hash) { | ||
@@ -149,2 +150,3 @@ location.hash = hash; | ||
} | ||
this.setTitle(title); | ||
} else if (url) { | ||
@@ -178,2 +180,3 @@ location.href = url; | ||
history.replaceState(state, title, url); | ||
this.setTitle(title); | ||
} else if (url) { | ||
@@ -195,2 +198,3 @@ url = location.pathname + location.search + hash; | ||
} | ||
this.setTitle(title); | ||
} else if (url) { | ||
@@ -200,2 +204,12 @@ location.replace(url); | ||
} | ||
}, | ||
/** | ||
* Sets document title. No-op if title is empty. | ||
* @param {String} title The title string. | ||
*/ | ||
setTitle: function (title) { | ||
if (title) { | ||
this.win.document.title = title; | ||
} | ||
} | ||
@@ -202,0 +216,0 @@ }; |
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
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
620
43254
17