cherrytree
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -0,1 +1,5 @@ | ||
### v2.2.0 | ||
* Add router.isActive method for testing if a given route is currently active. See [docs](docs/api.md#routerisactivename-params-query) | ||
### v2.1.0 | ||
@@ -2,0 +6,0 @@ |
@@ -263,2 +263,32 @@ 'use strict'; | ||
/** | ||
* Check if the given route/params/query combo is active | ||
* @param {String} name target route name | ||
* @param {Object} params | ||
* @param {Object} query | ||
* @return {Boolean} | ||
* | ||
* @api public | ||
*/ | ||
Cherrytree.prototype.isActive = function (name, params, query) { | ||
params = params || {}; | ||
query = query || {}; | ||
var activeRoutes = this.state.routes || []; | ||
var activeParams = this.state.params || {}; | ||
var activeQuery = this.state.query || []; | ||
var isNameActive = !!activeRoutes.find(function (route) { | ||
return route.name === name; | ||
}); | ||
var areParamsActive = !!Object.keys(params).every(function (key) { | ||
return activeParams[key] === params[key]; | ||
}); | ||
var isQueryActive = !!Object.keys(query).every(function (key) { | ||
return activeQuery[key] === query[key]; | ||
}); | ||
return isNameActive && areParamsActive && isQueryActive; | ||
}; | ||
/** | ||
* @api private | ||
@@ -265,0 +295,0 @@ */ |
{ | ||
"name": "cherrytree", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Cherrytree - a flexible hierarchical client side router", | ||
@@ -5,0 +5,0 @@ "main": "index", |
@@ -145,1 +145,9 @@ # <img src="https://cloud.githubusercontent.com/assets/324440/11302251/2c573b4a-8f94-11e5-9df6-889b19c2ad48.png" width="320" /> | ||
* Why is `cherrytree` written as one word? You got me, I'd say that represents the [wabisabi](https://en.wikipedia.org/wiki/Wabi-sabi) nature of the library. | ||
## Want to work on this for your day job? | ||
This project was created by the Engineering team at [Qubit](http://www.qubit.com). As we use open source libraries, we make our projects public where possible. | ||
We’re currently looking to grow our team, so if you’re a JavaScript engineer and keen on ES2016 React+Redux applications and Node micro services, why not get in touch? Work with like minded engineers in an environment that has fantastic perks, including an annual ski trip, yoga, a competitive foosball league, and copious amounts of yogurt. | ||
Find more details on our [Engineering site](https://eng.qubit.com). Don’t have an up to date CV? Just link us your Github profile! Better yet, send us a pull request that improves this project. |
@@ -327,2 +327,32 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/** | ||
* Check if the given route/params/query combo is active | ||
* @param {String} name target route name | ||
* @param {Object} params | ||
* @param {Object} query | ||
* @return {Boolean} | ||
* | ||
* @api public | ||
*/ | ||
Cherrytree.prototype.isActive = function (name, params, query) { | ||
params = params || {}; | ||
query = query || {}; | ||
var activeRoutes = this.state.routes || []; | ||
var activeParams = this.state.params || {}; | ||
var activeQuery = this.state.query || []; | ||
var isNameActive = !!activeRoutes.find(function (route) { | ||
return route.name === name; | ||
}); | ||
var areParamsActive = !!Object.keys(params).every(function (key) { | ||
return activeParams[key] === params[key]; | ||
}); | ||
var isQueryActive = !!Object.keys(query).every(function (key) { | ||
return activeQuery[key] === query[key]; | ||
}); | ||
return isNameActive && areParamsActive && isQueryActive; | ||
}; | ||
/** | ||
* @api private | ||
@@ -329,0 +359,0 @@ */ |
112321
2987
153