Merge branch 'fix-bug-issue424' of https://github.com/ersinfotech/mithril.js into ersinfotech-fix-bug-issue424

Conflicts:
	mithril.js
This commit is contained in:
Leo Horie 2015-01-27 21:06:27 -05:00
commit fa7e2b4afb

View file

@ -133,7 +133,7 @@ var m = (function app(window, undefined) {
for (var i = 0; i < cached.length; i++) { for (var i = 0; i < cached.length; i++) {
if (cached[i] && cached[i].attrs && cached[i].attrs.key != null) { if (cached[i] && cached[i].attrs && cached[i].attrs.key != null) {
shouldMaintainIdentities = true; shouldMaintainIdentities = true;
existing[cached[i].attrs.key] = {action: DELETION, index: i, element: cached[i].nodes[0]} existing[cached[i].attrs.key] = {action: DELETION, index: i}
} }
} }
if (shouldMaintainIdentities) { if (shouldMaintainIdentities) {
@ -154,13 +154,11 @@ var m = (function app(window, undefined) {
if (data[i].attrs.key != null) { if (data[i].attrs.key != null) {
var key = data[i].attrs.key; var key = data[i].attrs.key;
if (!existing[key]) existing[key] = {action: INSERTION, index: i}; if (!existing[key]) existing[key] = {action: INSERTION, index: i};
else { else existing[key] = {
existing[key] = { action: MOVE,
action: MOVE, index: i,
index: i, from: existing[key].index,
from: existing[key].index, element: cached.nodes[existing[key].index] || $document.createElement("div")
element: existing[key].element || $document.createElement("div")
}
} }
} }
else unkeyed.push({index: i, element: parentElement.childNodes[i] || $document.createElement("div")}) else unkeyed.push({index: i, element: parentElement.childNodes[i] || $document.createElement("div")})