#524 fix diff bug when mixing undefined in a tree

This commit is contained in:
Leo Horie 2015-03-30 13:25:32 -04:00
parent b6c2f70526
commit 648f4734b5
2 changed files with 42 additions and 12 deletions

View file

@ -138,13 +138,15 @@ var m = (function app(window, undefined) {
existing[cached[i].attrs.key] = {action: DELETION, index: i}
}
}
data = data.filter(function(x) {return x != null})
var guid = 0
for (var i = 0, len = data.length; i < len; i++) {
if (data[i] && data[i].attrs && data[i].attrs.key == null) data[i].attrs.key = "__mithril__" + guid++
}
if (shouldMaintainIdentities) {
if (data.indexOf(null) > -1) data = data.filter(function(x) {return x != null})
var keysDiffer = false
if (data.length != cached.length) keysDiffer = true
else for (var i = 0, cachedCell, dataCell; cachedCell = cached[i], dataCell = data[i]; i++) {