From 50d678dfdfe4c91960d524a3e37d787ab7bc75b8 Mon Sep 17 00:00:00 2001 From: Dhinesh Kumar Date: Tue, 29 Sep 2015 20:26:09 +0530 Subject: [PATCH] Subtree Directives Not Working - Issue Fix Fixed mithril not aborting the diff algorithm for the {subtree:retain} node. --- mithril.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mithril.js b/mithril.js index 58760547..146f682d 100644 --- a/mithril.js +++ b/mithril.js @@ -448,7 +448,7 @@ var m = (function app(window, undefined) { //Faster to coerce to number and check for NaN var key = +(data && data.attrs && data.attrs.key); data = pendingRequests === 0 || forcing || cachedControllers && cachedControllers.indexOf(controller) > -1 ? data.view(controller) : {tag: "placeholder"}; - if (data.subtree === "retain") return cached; + if (data.subtree === "retain") return data; if (key === key) (data.attrs = data.attrs || {}).key = key; updateLists(views, controllers, view, controller); return data; @@ -463,6 +463,7 @@ var m = (function app(window, undefined) { function buildObject(data, cached, editable, parentElement, index, shouldReattach, namespace, configs) { var views = [], controllers = []; data = markViews(data, cached, views, controllers); + if (data.subtree === "retain") return cached; if (!data.tag && controllers.length) throw new Error("Component template must return a virtual element, not an array, string, etc."); data.attrs = data.attrs || {}; cached.attrs = cached.attrs || {};