-
-
Notifications
You must be signed in to change notification settings - Fork 927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix 2128 #2130
Fix 2128 #2130
Conversation
render/render.js
Outdated
updateNode(parent, o, v, hooks, getNextSibling(old, oldEnd + 1, nextSibling), ns) | ||
insertNode(parent, toFragment(v), nextSibling) | ||
insertNode(parent, toFragment(o), nextSibling) | ||
updateNode(parent, o, v, hooks, nextSibling, ns) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just below, replacing o.skip = true
with old[oldIndex] = null
works as well, and it would save us a vnode slot.
Is there a reason not to mutate the old children list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
save us a vnode slot
Not sure I follow...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, that wasn't clear. If we do that, we can remove the .skip
field on vnodes, improving their memory footprint.
@@ -51,18 +51,17 @@ module.exports = function($window) { | |||
vnode.state = {} | |||
if (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks) | |||
switch (tag) { | |||
case "#": return createText(parent, vnode, nextSibling) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion one way or another, but why'd this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The individual createX
methods used to return a DOM node that was used in createComponent()
and updateNodes()
(in the map-based diff section).
This isn't needed anymore (and wasn't necessary in the first place AFAICT, since insertNode()
in createComponent()
was redundant and we can get v.dom
in updateNodes()
).
So I made it explicit that createNode()
wasn't returning anything.
This seems... reasonable. This is definitely the parts of mithril I understand the least though so I'm hesitant to actually post a review. |
The main change here is the simplification to get the When processing both lists downwards (unkeyed diff, first part of the keyed diff), the bottom part of the list hasn't been updated yet, and we need to look for the When processing the new list upwards (after the patch, the other three sections of the keyed list algo), the DOM nodes below I've changed the list reversal part of the diff so that it processes the old list top-down and the new list bottom up to take advantage of that. I've also moved the All in all, It saves us many |
@tivac I just pushed another commit that fully disentangles keyed and unkeyed diff. With that, the pool stuff removed and the bug fixes, |
…cs for cached nodes, fix MithrilJS#2132
I'll take a look tomorrow |
Ok, I've cleaned it up some more, and added some comments :-) Edit: some more... I've also updated the large comment that explains |
dacefe5
to
795a41f
Compare
@isiahmeadows do you want to be removed from the owners file as well (that was an automatic review request)? |
👍 I had missed it. |
render/render.js
Outdated
for(; start < commonLength; start++) { | ||
if (old[start] != null && vnodes[start] != null) { | ||
if (old[start].key == null && vnodes[start].key == null) isUnkeyed = true | ||
// default to keyed because, when either list isfull of null nodes, it has fewer branches |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isfull
"is full"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not convinced I 100% understand this, but the logic all seems reasonable to me!
Here we go! |
Thanks @pygy. Any updates on when these changes and the other fixes to |
I think most of the updateNodes fixes could be backported, I'll have to review the patches (I'm quite busy at the moment though so I can't promise it'll be quick). |
I appreciate it, let me know if there is something I can do to help |
@JacksonJN actually there are some changes in the |
@pygy Is v2 currently planned or is there an ETA? |
We're actively working on it (there was a hiatus). |
Thanks for the info. |
This fixes #2128, a DOM mocks bug that I discovered while fixing #2128, and removes quite a bit of code.
Change log item coming as soon as I have the PR number.
Types of changes
Checklist:
docs/change-log.md