You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #1255 Migrate LiveComponent to Idiomorph (matheo, WebMamba)
This PR was merged into the 2.x branch.
Discussion
----------
Migrate LiveComponent to Idiomorph
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| Issues |
| License | MIT
This PR migrate the LiveComponent morph system from `morphdom` to `idiomorph`.
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 way `morphdom` 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 than `morphdom`, 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 the `ExternalMutationTracker`?
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! 😁
Commits
-------
d5fc3c3 add missing build files
317d390 rebuild other ux packages
0df4faa resolve prittier errors
a9143ab resolve yarn errors
e5a187c fix last bugs
3bce29e Migrate LiveComponent to Idiomorph
if(kind==="a"&&!f)thrownewTypeError("Private accessor was defined without a getter");
21
23
if(typeofstate==="function" ? receiver!==state||!f : !state.has(receiver))thrownewTypeError("Cannot read private member from an object whose class did not declare it");
22
24
returnkind==="m" ? f : kind==="a" ? f.call(receiver) : f ? f.value : state.get(receiver);
'Unable to access Alpine.js morph function. Please make sure the Alpine.js Morph plugin is installed and loaded, see https://alpinejs.dev/plugins/morph for more information.'
58
-
);
45
+
// skip special checking if this is, for example, an SVG
// We assume fromEl is an Alpine component if it has `__x` property.
48
+
// If it's the case, then we should morph `fromEl` to `ToEl` (thanks to https://alpinejs.dev/plugins/morph)
49
+
// in order to keep the component state and UI in sync.
50
+
if(typeoffromEl.__x!=='undefined'){
51
+
if(!window.Alpine){
52
+
thrownewError(
53
+
'Unable to access Alpine.js though the global window.Alpine variable. Please make sure Alpine.js is loaded before Symfony UX LiveComponent.'
54
+
);
55
+
}
56
+
57
+
if(typeofwindow.Alpine.morph!=='function'){
58
+
thrownewError(
59
+
'Unable to access Alpine.js morph function. Please make sure the Alpine.js Morph plugin is installed and loaded, see https://alpinejs.dev/plugins/morph for more information.'
0 commit comments