inline flatten
This commit is contained in:
parent
6736537fcf
commit
1321aec9fb
1 changed files with 8 additions and 11 deletions
19
mithril.js
19
mithril.js
|
|
@ -108,7 +108,14 @@ Mithril = m = new function app(window, undefined) {
|
|||
}
|
||||
|
||||
if (dataType == sArr) {
|
||||
data = flatten(data);
|
||||
//recursively flatten array
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
if (type.call(data[i]) == sArr) {
|
||||
data = data.concat.apply([], data);
|
||||
i-- //check current index again and flatten until there are no more nested arrays at that index
|
||||
}
|
||||
}
|
||||
|
||||
var nodes = [], intact = cached.length === data.length, subArrayCount = 0;
|
||||
|
||||
//keys algorithm: sort elements without recreating them if keys are present
|
||||
|
|
@ -390,16 +397,6 @@ Mithril = m = new function app(window, undefined) {
|
|||
}
|
||||
return nodes
|
||||
}
|
||||
function flatten(data) {
|
||||
//recursive flatten
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
if (type.call(data[i]) == sArr) {
|
||||
data = data.concat.apply([], data);
|
||||
i-- //check current index again and flatten until there are no more nested arrays at that index
|
||||
}
|
||||
}
|
||||
return data
|
||||
}
|
||||
function autoredraw(callback, object) {
|
||||
return function(e) {
|
||||
e = e || event;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue