abstract-state-router
Advanced tools
Comparing version 3.6.1 to 4.0.0
26
index.js
@@ -52,4 +52,7 @@ var StateState = require('./state-state') | ||
delete activeEmitters[stateName] | ||
delete activeStateResolveContent[stateName] | ||
return resetDom(activeDomApis[stateName]) | ||
return resetDom({ | ||
domApi: activeDomApis[stateName], | ||
content: getContentObject(activeStateResolveContent, stateName), | ||
template: prototypalStateHolder.get(stateName).template | ||
}) | ||
} | ||
@@ -70,6 +73,8 @@ | ||
function renderStateName(stateName) { | ||
var state = prototypalStateHolder.get(stateName) | ||
return getChildElementForStateName(stateName).then(function(childElement) { | ||
return renderDom(childElement, state.template) | ||
return renderDom({ | ||
element: childElement, | ||
template: prototypalStateHolder.get(stateName).template, | ||
content: getContentObject(activeStateResolveContent, stateName) | ||
}) | ||
}).then(function(domApi) { | ||
@@ -109,9 +114,2 @@ activeDomApis[stateName] = domApi | ||
function emit() { | ||
var args = Array.prototype.slice.apply(arguments) | ||
return function() { | ||
return stateProviderEmitter.emit.apply(stateProviderEmitter, args) | ||
} | ||
} | ||
function getStatesToResolve(stateChanges) { | ||
@@ -189,3 +187,5 @@ return stateChanges.change.concat(stateChanges.create).map(prototypalStateHolder.get) | ||
} catch (e) { | ||
console.error(e) | ||
process.nextTick(function() { | ||
throw e | ||
}) | ||
} | ||
@@ -192,0 +192,0 @@ }) |
{ | ||
"name": "abstract-state-router", | ||
"version": "3.6.1", | ||
"version": "4.0.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", |
@@ -5,13 +5,13 @@ var test = require('tape') | ||
test('All dom functions called in order', function(t) { | ||
function noop() {} | ||
var actions = [] | ||
var renderer = { | ||
render: function render(element, template, cb) { | ||
render: function render(context, cb) { | ||
var element = context.element | ||
var template = context.template | ||
actions.push('render ' + template + ' on ' + element) | ||
cb(null, template) | ||
}, | ||
reset: function reset(renderedTemplateApi, cb) { | ||
actions.push('reset ' + renderedTemplateApi) | ||
reset: function reset(context, cb) { | ||
actions.push('reset ' + context.domApi) | ||
cb() | ||
@@ -18,0 +18,0 @@ }, |
module.exports = function assertingRendererFactory(t, expectedTemplates) { | ||
return { | ||
render: function render(element, template, cb) { | ||
render: function render(context, cb) { | ||
var template = context.template | ||
t.ok(expectedTemplates.length, 'The render function hasn\'t been called too many times yet') | ||
@@ -14,3 +15,3 @@ var expected = expectedTemplates.shift() | ||
}, | ||
reset: function reset(renderedTemplateApi, cb) { | ||
reset: function reset(context, cb) { | ||
setTimeout(cb, 100) | ||
@@ -17,0 +18,0 @@ }, |
@@ -22,3 +22,5 @@ var myArbitraryRenderFunction = function lol(parent, cb) { | ||
module.exports = { | ||
render: function render(element, template, cb) { | ||
render: function render(context, cb) { | ||
var element = context.element | ||
var template = context.template | ||
myArbitraryRenderFunction(element, function(renderedTemplateApi) { | ||
@@ -28,3 +30,5 @@ cb(null, renderedTemplateApi) | ||
}, | ||
reset: function reset(renderedTemplateApi, cb) { | ||
reset: function reset(context, cb) { | ||
var renderedTemplateApi = context.domApi | ||
var template = context.template | ||
renderedTemplateApi.reset() | ||
@@ -31,0 +35,0 @@ setTimeout(cb, 100) |
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
75888
2236