Skip to content
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

examples/99-server-components: Uncaught TypeError: child is null #223

Open
bbigras opened this issue Dec 9, 2024 · 2 comments
Open

examples/99-server-components: Uncaught TypeError: child is null #223

bbigras opened this issue Dec 9, 2024 · 2 comments

Comments

@bbigras
Copy link

bbigras commented Dec 9, 2024

with examples/99-server-components, I got this error when I click a button:

Uncaught TypeError: child is null
    getDeepChild http://127.0.0.1:3000/lustre-server-component.mjs:329
    patch http://127.0.0.1:3000/lustre-server-component.mjs:62
    #diff http://127.0.0.1:3000/lustre-server-component.mjs:583
    messageReceivedCallback http://127.0.0.1:3000/lustre-server-component.mjs:498
    reconnect http://127.0.0.1:3000/lustre-server-component.mjs:567
    #reconnect http://127.0.0.1:3000/lustre-server-component.mjs:565
    attributeChangedCallback http://127.0.0.1:3000/lustre-server-component.mjs:489
    <anonymous> http://127.0.0.1:3000/:234
    <anonymous> http://127.0.0.1:3000/lustre-server-component.mjs:633
lustre-server-component.mjs:329:5

with e32e1b7
gleam 1.5.1

@hayleigh-dot-dev
Copy link
Collaborator

Thanks, I’ll take a look!

@bbigras
Copy link
Author

bbigras commented Dec 10, 2024

Do you think this would help? I'm embarrassed to say that aider chat suggested that 😅 . It does seem to work though.

diff --git a/src/vdom.ffi.mjs b/src/vdom.ffi.mjs
index 5f9a445c01..31e8589aef 100644
--- a/src/vdom.ffi.mjs
+++ b/src/vdom.ffi.mjs
@@ -590,6 +590,9 @@
   let isFirstInPath = true;

   while ((([n, ...rest] = path), n !== undefined)) {
+    if (!child) {
+      return null;
+    }
     child = child.childNodes.item(isFirstInPath ? n + stylesOffset : n);
     isFirstInPath = false;
     path = rest;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants