-
-
Notifications
You must be signed in to change notification settings - Fork 340
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
Migrate LiveComponent to Idiomorph #1255
Migrate LiveComponent to Idiomorph #1255
Conversation
THANK YOU for getting this rolling ❤️. To make LiveComponents stable (which we will do shortly), the most important changes are those that could be BC breaks (which we need to do now). This is one of the main ones left. I'll check this out a bit later today.
Hmm. It is probably important that the child is replaced if And sorry for closing - tripped over my keyboard ;) |
This test is already implemented and worked, thanks to some tweaks 😁 |
After looking at this PR, in order to finish it, what I need from you @weaverryan: is to look at the 3 last failing tests and tell me if this is a behavior we should keep or not. Sorry to ask you that, but I am missing some context and can't understand why this test is made for. Thanks you 😁 |
Perfectly ok - this is complex functionality that I created! I will get back to you today. |
Wow nice work @WebMamba <3 i'll try tomorrow, hoping my demo is still working and that has no impact on the DOM/CSS behaviour 😅 |
That will be an excellent test for this :) |
Yes, this is important. The key thing is that each child in this test has a <div data-live-id="1" ....>Child component 1</div>
Other content
<div data-live-id="2" ....>Child component 2</div> Then, after a re-render, the HTML is suddenly: <div data-live-id="2" ....>Child component 2</div>
Other content
<div data-live-id="1" ....>Child component 1</div> When handling this, the system needs to be smart enough to realize that "Child component 1" is still the
Hmm, I'm not sure what the cause is, but the test should pass / the behavior is still desired. The Let me know if this helps or not. I'm glad we're tackling this now |
So for now i have some bugs/differences with an embedded livecomponent, which is sometimes voided ... So i insist, it may be related to other things on my machine, but i write it here by precaution (and to remember to continue those tests soon) |
Sorry did not have really the time to make a "scientific" comparaison... and i have big performances issues with something between
And i cannot find what / why.... so don't wait for me on this one i won't have time before some time :)) |
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 one question - I tried this locally with all of the UX demos and even some parent child components (both when they share a prop with updateFromParent
and not). Everything seems very smooth 😎
return !node.hasAttribute('data-live-ignore'); | ||
}, | ||
childComponentInResult?.replaceWith(element); | ||
childComponent.updateFromNewElementFromParentRender(childComponentInResult); |
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.
Can you explain why this is now needed? I see some slight change in the logic above, but I can't quite understand the significance. Also, for reference, I'm checking the diff with https://github.com/symfony/ux/pull/1255/files?w=1 so that it hides whitespace differences and it's easier for me to see what actually changed.
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.
Ho man! This PR looks so far away now! But I think this is related to the last failing test. The thing is idiomorph is more clever than morphdom so when you have a component that has children and the children. If your component rerender and the children swap position idiopmorph is clever enough to just morph the position of the children. But the thing is this is so clever that the child is not rerender. So here we forced the children to be rerender in this situation. I hope this help
Thank you a million for this Matheo! |
👏 |
This PR migrate the LiveComponent morph system from
morphdom
toidiomorph
.I still have 4 tests that are not passing, and I am not sure how to solve it:
1 -
test/controller/child.test.ts > Component parent -> child initialization and rendering tests > replaces old child with new child if the "id" changes
In
idiomorph
they don't use the id the same waymorphdom
does. So this is the expected behavior, I am not sure if we should replicate the old behavior or not?2 -
test/controller/child.test.ts > Component parent -> child initialization and rendering tests > tracks various children correctly, even if position changes
I think the issue comes from the behavior explained here: https://github.com/bigskysoftware/idiomorph#example-morph.
Idiomorph
is more clever thanmorphdom
, and doesn't need to morph the child on every parent morph.3 -
test/controller/render-with-external-changes.test.ts > LiveController rendering with external changes tests > will not remove an added element
Looks like a similar issue to the problem above.
Idiomorph
doesn't need to morph every child, so the child is not added to theExternalMutationTracker
?4 -
test/controller/render-with-external-changes.test.ts > LiveController rendering with external changes tests > keeps external changes across multiple renders
...
I'm still digging, but ideas are welcome! 😁