restoring state
This commit is contained in:
parent
e472f7b9ac
commit
394fb5922b
2 changed files with 6 additions and 6 deletions
10
mithril.js
10
mithril.js
|
|
@ -108,6 +108,7 @@ Mithril = m = new function app(window, undefined) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataType == sArr) {
|
if (dataType == sArr) {
|
||||||
|
new function a() {
|
||||||
data = flatten(data);
|
data = flatten(data);
|
||||||
var nodes = [], intact = cached.length === data.length, subArrayCount = 0;
|
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
|
//update the list of DOM nodes by collecting the nodes from each item
|
||||||
for (var i = 0; i < data.length; i++) {
|
for (var i = 0; i < data.length; i++) {
|
||||||
if (cached[i] != null) {
|
if (cached[i] != null) nodes.push.apply(nodes, cached[i].nodes)
|
||||||
for (var j = 0; j < cached[i].nodes.length; j++) {
|
|
||||||
nodes.push(cached[i].nodes[j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//remove items from the end of the array if the new array is shorter than the old one
|
//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
|
//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;
|
if (data.length < cached.length) cached.length = data.length;
|
||||||
cached.nodes = nodes
|
cached.nodes = nodes
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (data != null && dataType == sObj) {
|
else if (data != null && dataType == sObj) {
|
||||||
|
new function b() {
|
||||||
if (!data.attrs) data.attrs = {};
|
if (!data.attrs) data.attrs = {};
|
||||||
if (!cached.attrs) cached.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]))
|
configs.push(callback(data, [node, !isNew, context, cached]))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (typeof dataType != sFn) {
|
else if (typeof dataType != sFn) {
|
||||||
//handle text nodes
|
//handle text nodes
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue