From 394fb5922b792fcd8d33e5969dad515bddfb0375 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Thu, 13 Nov 2014 21:50:26 -0500 Subject: [PATCH] restoring state --- .gitignore | 2 +- mithril.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 4b1d2cfa..aeab5a02 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ node_modules -archive \ No newline at end of file +archive diff --git a/mithril.js b/mithril.js index a9f4834f..47b45655 100644 --- a/mithril.js +++ b/mithril.js @@ -108,6 +108,7 @@ Mithril = m = new function app(window, undefined) { } if (dataType == sArr) { + new function a() { data = flatten(data); var nodes = [], intact = cached.length === data.length, subArrayCount = 0; @@ -194,11 +195,7 @@ Mithril = m = new function app(window, undefined) { //update the list of DOM nodes by collecting the nodes from each item for (var i = 0; i < data.length; i++) { - if (cached[i] != null) { - for (var j = 0; j < cached[i].nodes.length; j++) { - nodes.push(cached[i].nodes[j]); - } - } + if (cached[i] != null) nodes.push.apply(nodes, cached[i].nodes) } //remove items from the end of the array if the new array is shorter than the old one //if errors ever happen here, the issue is most likely a bug in the construction of the `cached` data structure somewhere earlier in the program @@ -212,8 +209,10 @@ Mithril = m = new function app(window, undefined) { if (data.length < cached.length) cached.length = data.length; cached.nodes = nodes } + } } else if (data != null && dataType == sObj) { + new function b() { if (!data.attrs) data.attrs = {}; if (!cached.attrs) cached.attrs = {}; @@ -265,6 +264,7 @@ Mithril = m = new function app(window, undefined) { }; configs.push(callback(data, [node, !isNew, context, cached])) } + } } else if (typeof dataType != sFn) { //handle text nodes