Add support for (m.mount + m.route) × (factory + constructible) components

This commit is contained in:
Pierre-Yves Gerardy 2017-02-15 21:58:10 +01:00
parent f4fb5ac4be
commit f273b012c9
2 changed files with 4 additions and 3 deletions

View file

@ -21,11 +21,12 @@ module.exports = function($window, redrawService) {
routeService.defineRoutes(routes, function(payload, params, path) {
var update = lastUpdate = function(routeResolver, comp) {
if (update !== lastUpdate) return
component = comp != null && typeof comp.view === "function" ? comp : "div", attrs = params, currentPath = path, lastUpdate = null
component = comp != null && (typeof comp.view === "function" || typeof comp === "function")? comp : "div"
attrs = params, currentPath = path, lastUpdate = null
render = (routeResolver.render || identity).bind(routeResolver)
run()
}
if (payload.view) update({}, payload)
if (payload.view || typeof payload === "function") update({}, payload)
else {
if (payload.onmatch) {
Promise.resolve(payload.onmatch(params, path)).then(function(resolved) {