Merge branch 'Subtree-retain-fix' of https://github.com/dhinesh03/mithril.js into dhinesh03-Subtree-retain-fix

This commit is contained in:
Leo Horie 2015-12-20 19:09:24 -05:00
commit 309f2d561d

View file

@ -445,7 +445,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;
@ -460,6 +460,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 || {};