-
Notifications
You must be signed in to change notification settings - Fork 79
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
Keyed DOM-nodes get rerendered when they shouldn't? #66
Comments
@cjh9 Could you please write more readable code? I could edit your post and format the code for you, but then that's kind of disrespectful to the maintainer of the project. |
@jorgebucaran Sry, just updated the code and ran it trough prettierJS :) Ok? |
@cjh9 Yes currently that's the behavior. If I understand what's going on correctly, it's not a bug, but a potential optimization to the patch-algorithm. It's been discussed elsewhere (can't recall where now though), but the idea is that we should identify how much of the beginning and end of the list that hasn't changed, and leave those parts alone. Only apply the keyed patching algo to the middle-part where there have been changes. (@jorgebucaran do you know the issue where the "prefix/suffix" thing was discussed? That's what this is about I think. Or?) |
@cjh9 :) Not a bug! The vnodes are just being touched by setElementProp, we are setting onclick and onupdate handlers on them on every render. |
@zaceno @jorgebucaran I've just debugged the thing and it looks like it is just reattaching the event listeners, so the dom-nodes are not recreated. However this is not why the nodes are flashing, try attaching an event listener in devtools
|
@cjh9 Ah I see. And that is something I think could only be fixed with an algorithm that ignores the unchanged beginning and end of a list. The "prefix/suffix" discussion from jorgebucaran/hyperapp#216 |
@cjh9 Thanks for figuring it out why stuff was flashing! 👍 |
This problem is now fixed after backporting jorgebucaran/hyperapp#663 from Hyperapp. Thanks, @SkaterDad! 🎉 |
Take a look at these runnable examples, one written with petit-dom and the other with picodom:
Picodom
Petit-dom
Open Chrome devtools, inspect elements and click on any text label do remove it, notice that the algorithm in picodom applies dom-changes to all the text-labels after the actual label (see animated gif below). They are also logged with the onupdate hook. But with petit-dom they are not. Is this expected behavior?
The text was updated successfully, but these errors were encountered: