Comparing version 0.5.1 to 0.5.2
@@ -40,7 +40,15 @@ 'use strict'; | ||
// https://github.com/jashkenas/backbone/blob/d682061a/backbone.js#L1537-L1547 | ||
var routeRegexp = routeExpr.replace(escapeRegExp, '\\$&').replace(optionalParam, '(?:$1)?').replace(namedParam, function (match, optional) { | ||
var expr = routeExpr.replace(escapeRegExp, '\\$&').replace(optionalParam, '(?:$1)?').replace(namedParam, function (match, optional) { | ||
return optional ? match : '([^/?]+)'; | ||
}).replace(splatParam, '([^?]*?)'); | ||
routeRegexp = new RegExp('^' + routeRegexp + '(?:\\?([\\s\\S]*))?$'); | ||
return { expr: routeRegexp, handler: routeDefs[routeExpr] }; | ||
expr = new RegExp('^' + expr + '(?:\\?([\\s\\S]*))?$'); | ||
// hook up route handler function | ||
var handler = routeDefs[routeExpr]; | ||
if (typeof handler === 'string') { | ||
// reference to another handler rather than its own function | ||
handler = routeDefs[handler]; | ||
} | ||
return { expr: expr, handler: handler }; | ||
}); | ||
@@ -101,3 +109,6 @@ | ||
var routeStateUpdate = (_route$handler = route.handler).call.apply(_route$handler, [_this2.app, stateUpdate].concat(_toConsumableArray(params))); | ||
_this2.app.update(Object.assign({}, stateUpdate, routeStateUpdate)); | ||
if (routeStateUpdate) { | ||
// don't update if route handler returned a falsey result | ||
_this2.app.update(Object.assign({}, stateUpdate, routeStateUpdate)); | ||
} | ||
return { | ||
@@ -104,0 +115,0 @@ v: void 0 |
@@ -19,3 +19,3 @@ // just the necessary bits of Backbone router+history | ||
// https://github.com/jashkenas/backbone/blob/d682061a/backbone.js#L1537-L1547 | ||
let routeRegexp = routeExpr | ||
let expr = routeExpr | ||
.replace(escapeRegExp, '\\$&') | ||
@@ -25,4 +25,12 @@ .replace(optionalParam, '(?:$1)?') | ||
.replace(splatParam, '([^?]*?)'); | ||
routeRegexp = new RegExp('^' + routeRegexp + '(?:\\?([\\s\\S]*))?$'); | ||
return {expr: routeRegexp, handler: routeDefs[routeExpr]}; | ||
expr = new RegExp('^' + expr + '(?:\\?([\\s\\S]*))?$'); | ||
// hook up route handler function | ||
let handler = routeDefs[routeExpr]; | ||
if (typeof handler === 'string') { | ||
// reference to another handler rather than its own function | ||
handler = routeDefs[handler]; | ||
} | ||
return {expr, handler}; | ||
}); | ||
@@ -63,3 +71,6 @@ | ||
const routeStateUpdate = route.handler.call(this.app, stateUpdate, ...params); | ||
this.app.update(Object.assign({}, stateUpdate, routeStateUpdate)); | ||
if (routeStateUpdate) { | ||
// don't update if route handler returned a falsey result | ||
this.app.update(Object.assign({}, stateUpdate, routeStateUpdate)); | ||
} | ||
return; | ||
@@ -66,0 +77,0 @@ } |
{ | ||
"name": "panel", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "virtual-dom view management and routing", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -23,4 +23,4 @@ [![Build Status](https://travis-ci.org/mixpanel/panel.svg?branch=master)](https://travis-ci.org/mixpanel/panel) | ||
return { | ||
incr: () => this.app.update({counter: this.app.state.counter + 1}), | ||
decr: () => this.app.update({counter: this.app.state.counter - 1}), | ||
incr: () => this.app.update({counter: this.app.state.countVal + 1}), | ||
decr: () => this.app.update({counter: this.app.state.countVal - 1}), | ||
} | ||
@@ -30,3 +30,3 @@ } | ||
new CounterApp('app', {$screen: 'counter', counter: 1}).start(); | ||
new CounterApp('app', {$screen: 'counter', countVal: 1}).start(); | ||
``` | ||
@@ -33,0 +33,0 @@ ```jade |
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
33538
728