-
-
Notifications
You must be signed in to change notification settings - Fork 143
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
[rdom] comment nodes cause exception #367
Comments
Hi @usernolan 👋 - that's a good question and TBH the first time I ever thought about that. Taking a look at the So in short, putting in the extra check & branch to create a comment node is the easy part, but then we would also have to change the return type of If you want to work on a PR, then by all means - happy to guide you! :) |
Ah, indeed. How naive of me to assume that I'd love to work through it if you think that's a feature you'd want to support (consider this 1 vote in favor!). It'd be great to learn the Edit: On second thought, would winding back up to |
- add $comment(), isComment() - add Component.$comment() syntax sugar - add comment check/branch in $tree() - update args for $addChild(), $remove(), $moveTo() - update $text(), $html() to support SVG elements - add doc strings
Oh, damn! I didn't see your new reply and whilst checking & experimenting with a possible solution this morning, I got carried away updating/cleaning & documenting various other rdom pieces and think this all could & does work. If you want to take a look at the updated rdom-delayed-update example, you should see something like this: Relevant source here (using newly added umbrella/examples/rdom-delayed-update/src/index.ts Lines 81 to 82 in 565990f
Ps. Similar to your edited proposal, I've added a new check/branch in Would be grateful if you could do some further testing. I still think there could be some potential issues if used within |
@usernolan - so sorry again, really didn't mean to beat you to your first PR to this project!!! 😩 I'm sure there'll another chance for you! |
No, this is WONDERFUL! So glad to see this all in action. Once I was able to escape the mindset of adding a branch in $el, the $comment solution became quite visible. I’ll be able to test this in a number of scenarios over the next few days. If I find any surprises I’ll either reopen or log a new issue, vibe-dependent. Thanks so much again for knocking this out. Next time I’ll have to be quicker on the draw. 😂🙏 |
Awesome & thank you (for this feature & testing)! |
@postspectacular I ran into an edge case that I wanted to flag in case you ever revisit this feature. It seems related to your
What I experience here is that, on first render, the last two I can't pretend to know what might be going on, but I thought I'd call it out. Also, I haven't seen anything similar at any point when the comment is embedded in a plain hiccup component. Thanks again for this! I love this feature. I love this library! |
Hi @usernolan - Happy New Year & apols for the slow response... Do you think you could prep a full, minimal standalone example for me to try to debug this (maybe in a gist or codesandbox somewhere)? As predicted, both of these list component wrappers just aren't prepared for any inserted comment nodes (or any other external manipulations), but maybe we can work around that... thank you (also for the kind words!) :) |
This may be ill-advised, but I was hoping that I could add comments to the DOM from
rdom
. Long story short: special content and exposition for those who care to inspect.From
hiccup
:umbrella/packages/hiccup/src/serialize.ts
Lines 118 to 119 in 2065c92
However, trying to use this form from
rdom
results in an exception in the browser:I can't tell exactly what path the
__COMMENT__
tag would follow through rdom's$el
a priori, but it seems like a properly orienteddocument.createComment()
in that function might work. If you think this approach is worth pursuing, I'd be more than glad to submit a PR.The text was updated successfully, but these errors were encountered: