Merge remote-tracking branch 'origin/next' into components

This commit is contained in:
Leo Horie 2015-03-16 20:03:49 -04:00
commit a3929ba871
2 changed files with 6 additions and 1 deletions

View file

@ -17,6 +17,7 @@
- set promise's default value to initialValue if coming from m.request [#454](https://github.com/lhorie/mithril.js/issues/454)
- fix dom element ownership bug when mixing keyed elements and third party plugin elements [#463](https://github.com/lhorie/mithril.js/issues/463)
- fix edge case in flatten algorithm [#448](https://github.com/lhorie/mithril.js/issues/448)
- prevent unnecessary DOM move operation when mixing keyed and unkeyed elements [#398](https://github.com/lhorie/mithril.js/issues/398)
---

View file

@ -137,6 +137,10 @@ var m = (function app(window, undefined) {
existing[cached[i].attrs.key] = {action: DELETION, index: i}
}
}
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})
@ -212,7 +216,7 @@ var m = (function app(window, undefined) {
//fix offset of next element if item was a trusted string w/ more than one html element
//the first clause in the regexp matches elements
//the second clause (after the pipe) matches text nodes
subArrayCount += (item.match(/<[^\/]|\>\s*[^<]|&/g) || []).length
subArrayCount += (item.match(/<[^\/]|\>\s*[^<]/g) || [0]).length
}
else subArrayCount += type.call(item) === ARRAY ? item.length : 1;
cached[cacheCount++] = item