[render/render] move keyed cached nodes when needed, fix diff semantics for cached nodes, fix #2132
This commit is contained in:
parent
878e4958dc
commit
801bde219e
2 changed files with 9 additions and 11 deletions
|
|
@ -42,7 +42,8 @@
|
|||
(https://github.com/MithrilJS/mithril.js/pull/2130)
|
||||
- render/core: Render state correctly on select change event [#1916](https://github.com/MithrilJS/mithril.js/issues/1916) ([#1918](https://github.com/MithrilJS/mithril.js/pull/1918) [@robinchew](https://github.com/robinchew), [#2052](https://github.com/MithrilJS/mithril.js/pull/2052))
|
||||
- render/core: fix various updateNodes/removeNodes issues when the pool and fragments are involved [#1990](https://github.com/MithrilJS/mithril.js/issues/1990), [#1991](https://github.com/MithrilJS/mithril.js/issues/1991), [#2003](https://github.com/MithrilJS/mithril.js/issues/2003), [#2021](https://github.com/MithrilJS/mithril.js/pull/2021)
|
||||
- render/core: fix crashes when the keyed vnodes with the same `key` had different `tag` values [#2128](https://github.com/MithrilJS/mithril.js/issues/2128) [@JacksonJN](https://github.com/JacksonJN) ([#2130]
|
||||
- render/core: fix crashes when the keyed vnodes with the same `key` had different `tag` values [#2128](https://github.com/MithrilJS/mithril.js/issues/2128) [@JacksonJN](https://github.com/JacksonJN) ([#2130](https://github.com/MithrilJS/mithril.js/pull/2130))
|
||||
- render/core: fix cached nodes behavior in some keyed diff scenarios [#2132](https://github.com/MithrilJS/mithril.js/issues/2132) ([#2130](https://github.com/MithrilJS/mithril.js/pull/2130))
|
||||
- render/events: `addEventListener` and `removeEventListener` are always used to manage event subscriptions, preventing external interference.
|
||||
- render/events: Event listeners allocate less memory, swap at low cost, and are properly diffed now when rendered via `m.mount()`/`m.redraw()`.
|
||||
- render/events: `Object.prototype` properties can no longer interfere with event listener calls.
|
||||
|
|
|
|||
|
|
@ -296,21 +296,19 @@ module.exports = function($window) {
|
|||
while (oldEnd >= oldStart && end >= start) {
|
||||
o = old[oldStart]
|
||||
v = vnodes[start]
|
||||
if (o === v || o == null && v == null) oldStart++, start++
|
||||
else if (o == null) oldStart++
|
||||
if (o == null) oldStart++
|
||||
else if (v == null) start++
|
||||
else if (o.key === v.key) {
|
||||
oldStart++, start++
|
||||
updateNode(parent, o, v, hooks, getNextSibling(old, oldStart, nextSibling), ns)
|
||||
if (o !== v) updateNode(parent, o, v, hooks, getNextSibling(old, oldStart, nextSibling), ns)
|
||||
} else {
|
||||
v = vnodes[end]
|
||||
if (o === v) oldStart++, end--
|
||||
else if (o == null) oldStart++
|
||||
if (o == null) oldStart++
|
||||
else if (v == null) end--
|
||||
else if (o.key === v.key) {
|
||||
oldStart++
|
||||
if (start < end--) insertNode(parent, toFragment(o), nextSibling)
|
||||
updateNode(parent, o, v, hooks, nextSibling, ns)
|
||||
if (o !== v) updateNode(parent, o, v, hooks, nextSibling, ns)
|
||||
if(v.dom != null) nextSibling = v.dom
|
||||
}
|
||||
else break
|
||||
|
|
@ -319,11 +317,10 @@ module.exports = function($window) {
|
|||
while (oldEnd >= oldStart && end >= start) {
|
||||
o = old[oldEnd]
|
||||
v = vnodes[end]
|
||||
if (o === v) oldEnd--, end--
|
||||
else if (o == null) oldEnd--
|
||||
if (o == null) oldEnd--
|
||||
else if (v == null) end--
|
||||
else if (o.key === v.key) {
|
||||
updateNode(parent, o, v, hooks, nextSibling, ns)
|
||||
if (o !== v) updateNode(parent, o, v, hooks, nextSibling, ns)
|
||||
if (v.dom != null) nextSibling = v.dom
|
||||
oldEnd--, end--
|
||||
} else {
|
||||
|
|
@ -333,7 +330,7 @@ module.exports = function($window) {
|
|||
if (oldIndex != null) {
|
||||
o = old[oldIndex]
|
||||
insertNode(parent, toFragment(o), nextSibling)
|
||||
updateNode(parent, o, v, hooks, nextSibling, ns)
|
||||
if (o !== v) updateNode(parent, o, v, hooks, nextSibling, ns)
|
||||
o.skip = true
|
||||
if (v.dom != null) nextSibling = v.dom
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue