From 422ff19d18b4cdb87c89ceb2d788f88788099cf4 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Sat, 5 Jul 2014 16:54:44 -0400 Subject: [PATCH] clean up --- mithril.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/mithril.js b/mithril.js index 8e398275..a77af48f 100644 --- a/mithril.js +++ b/mithril.js @@ -269,11 +269,6 @@ Mithril = m = new function app(window) { } return nodes } - function clone(object) { - var result = {} - for (var prop in object) result[prop] = object[prop] - return result - } function autoredraw(callback, object) { return function(e) { e = e || event @@ -442,9 +437,7 @@ Mithril = m = new function app(window) { for (var route in router) { if (route == path) { - var cacheKey = getCellCacheKey(root) - clear(root.childNodes, cellCache[cacheKey]) - cellCache[cacheKey] = undefined + reset(root) m.module(root, router[route]) return true } @@ -452,9 +445,7 @@ Mithril = m = new function app(window) { var matcher = new RegExp("^" + route.replace(/:[^\/]+?\.{3}/g, "(.*?)").replace(/:[^\/]+/g, "([^\\/]+)") + "\/?$") if (matcher.test(path)) { - var cacheKey = getCellCacheKey(root) - clear(root.childNodes, cellCache[cacheKey]) - cellCache[cacheKey] = undefined + reset(root) path.replace(matcher, function() { var keys = route.match(/:[^\/]+/g) || [] var values = [].slice.call(arguments, 1, -2) @@ -465,6 +456,11 @@ Mithril = m = new function app(window) { } } } + function reset(root) { + var cacheKey = getCellCacheKey(root) + clear(root.childNodes, cellCache[cacheKey]) + cellCache[cacheKey] = undefined + } function routeUnobtrusive(e) { e = e || event if (e.ctrlKey || e.metaKey || e.which == 2) return