abstract-state-router
Advanced tools
Comparing version 3.3.0 to 3.4.0
14
index.js
@@ -237,8 +237,7 @@ var StateState = require('./state-state') | ||
stateProviderEmitter.makePath = function makePathAndPrependHash(stateName, parameters) { | ||
try { | ||
return '#' + makePath(stateName, parameters) | ||
} catch (err) { | ||
console.error(err) | ||
} | ||
return '#' + makePath(stateName, parameters) | ||
} | ||
stateProviderEmitter.stateIsActive = function stateIsActive(stateName) { | ||
return current.get().name.indexOf(stateName) === 0 | ||
} | ||
@@ -248,2 +247,5 @@ if (renderer.setUpMakePathFunction) { | ||
} | ||
if (renderer.setUpStateIsActiveFunction) { | ||
renderer.setUpStateIsActiveFunction(stateProviderEmitter.stateIsActive) | ||
} | ||
@@ -288,3 +290,3 @@ return stateProviderEmitter | ||
if (res && (typeof res === 'object' || typeof res === 'function') && typeof res.then === 'function') { | ||
resolve(res) | ||
resolve(res) | ||
} | ||
@@ -291,0 +293,0 @@ }) |
{ | ||
"name": "abstract-state-router", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"description": "The basics of a client-side state router ala the AngularJS ui-router, but without any DOM interactions", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -247,1 +247,69 @@ var test = require('tape') | ||
}) | ||
test('makePath', function(t) { | ||
var stateRouter = getTestState(t).stateRouter | ||
t.plan(2) | ||
stateRouter.addState({ | ||
name: 'parent', | ||
template: '', | ||
route: '/parent', | ||
}) | ||
stateRouter.addState({ | ||
name: 'parent.child1', | ||
template: '', | ||
route: '/child1', | ||
}) | ||
stateRouter.addState({ | ||
name: 'parent.child2', | ||
template: '', | ||
route: '/child2', | ||
}) | ||
t.equal('#/parent/child1?param=value', stateRouter.makePath('parent.child1', { param: 'value' })) | ||
t.throws(function() { | ||
stateRouter.makePath('parent.doesnotexist') | ||
}, /doesnotexist/) | ||
t.end() | ||
}) | ||
test('stateIsActive', function(t) { | ||
var stateRouter = getTestState(t).stateRouter | ||
t.plan(4) | ||
stateRouter.addState({ | ||
name: 'parent', | ||
template: '', | ||
route: '/parent', | ||
}) | ||
stateRouter.addState({ | ||
name: 'parent.child1', | ||
template: '', | ||
route: '/child1' | ||
}) | ||
stateRouter.addState({ | ||
name: 'parent.child2', | ||
template: '', | ||
route: '/child2', | ||
}) | ||
stateRouter.on('stateChangeEnd', function() { | ||
t.ok(stateRouter.stateIsActive('parent'), 'parent is active') | ||
t.ok(stateRouter.stateIsActive('parent.child1'), 'parent.child1 is active') | ||
t.notOk(stateRouter.stateIsActive('parent.child2'), 'parent.child2 is not active') | ||
t.notOk(stateRouter.stateIsActive('not a real state'), 'non-existant state is not active') | ||
t.end() | ||
}) | ||
stateRouter.go('parent.child1') | ||
}) | ||
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
74191
2187