Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

abstract-state-router

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abstract-state-router - npm Package Compare versions

Comparing version 5.14.1 to 5.15.0

4

changelog.md

@@ -0,1 +1,5 @@

# [5.15.0](https://github.com/TehShrike/abstract-state-router/releases/tag/v5.15.0)
- feature: renderers may now return a new DOM API from the reset function. [c07a45fb](https://github.com/TehShrike/abstract-state-router/commit/c07a45fba4d50d95c78822e2227529ca4aea29f8)
# [5.14.1](https://github.com/TehShrike/abstract-state-router/releases/tag/v5.14.1)

@@ -2,0 +6,0 @@

8

index.js

@@ -100,5 +100,9 @@ var StateState = require('./lib/state-state')

parameters: parameters
}).then(function() {
}).then(function(newDomApi) {
if (newDomApi) {
activeDomApis[stateName] = newDomApi
}
stateProviderEmitter.emit('afterResetState', {
domApi: domApi,
domApi: activeDomApis[stateName],
content: content,

@@ -105,0 +109,0 @@ state: state,

{
"name": "abstract-state-router",
"version": "5.14.1",
"version": "5.15.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",

@@ -44,6 +44,6 @@ # Create your own renderer

$(context.element).html(myHtml) // Apply to the DOM
// domApi is a jquery object in these examples
// You should expose the interface provided by your dom manipulation library of choice
var domApi = $(context.element)
var domApi = $(context.element)
cb(null, domApi)

@@ -89,4 +89,6 @@ }

This function doesn't return anything, just call the callback or whatever once the resetting is complete.
This function doesn't have to return anything, it's totally fine to call the callback or return a resolved promise without any value once the resetting is complete. The router will assume that the previous DOM API is still valid.
If you do pass a truthy value to the callback or in the promise, the router will assume that the value is the new DOM API which should replace the previous one.
```js

@@ -93,0 +95,0 @@ function reset(context, cb) {

@@ -7,3 +7,3 @@ var test = require('tape-catch')

var renderer = function makeRenderer() {
function makeRenderer() {
return {

@@ -31,3 +31,3 @@ render: function render(context, cb) {

var state = getTestState(t, renderer)
var state = getTestState(t, makeRenderer)

@@ -86,1 +86,51 @@ var expectedActions = [

})
test('Supplying a value to reset replaces the active DOM API', function(t) {
var originalDomApi = {}
var domApiAfterReset = {}
function makeRenderer() {
return {
render: function render(context, cb) {
cb(null, originalDomApi)
},
reset: function reset(context, cb) {
t.equal(originalDomApi, context.domApi)
cb(null, domApiAfterReset)
},
destroy: function destroy(renderedTemplateApi, cb) {
cb()
},
getChildElement: function getChildElement(renderedTemplateApi, cb) {
cb()
}
}
}
var state = getTestState(t, makeRenderer)
var firstActivation = true
state.stateRouter.addState({
name: 'top',
template: 'topTemplate',
querystringParameters: ['myFancyParam'],
activate: function(context) {
if (firstActivation) {
t.equal(context.domApi, originalDomApi)
firstActivation = false
state.stateRouter.go('top', {
myFancyParam: 'new value'
})
} else {
t.equal(context.domApi, domApiAfterReset)
t.end()
}
}
})
state.stateRouter.go('top', {
myFancyParam: 'original value'
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc