question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[rdom] comment nodes cause exception

See original GitHub issue

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: https://github.com/thi-ng/umbrella/blob/2065c927cfe52fe72534fcc0ee74260c760d9966/packages/hiccup/src/serialize.ts#L118-L119

However, trying to use this form from rdom results in an exception in the browser:

Screen Shot 2022-11-29 at 11 38 24 AM

I can’t tell exactly what path the __COMMENT__ tag would follow through rdom’s $el a priori, but it seems like a properly oriented document.createComment() in that function might work. If you think this approach is worth pursuing, I’d be more than glad to submit a PR.

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
postspectacularcommented, Nov 30, 2022

@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!

2reactions
postspectacularcommented, Nov 29, 2022

Hi @usernolan 👋 - that’s a good question and TBH the first time I ever thought about that. Taking a look at the $el it seems the problem will be that the created element (or now comment) will have to be returned, however the JS native Comment type unfortunately is not a normal Element:

https://github.com/microsoft/TypeScript/blob/cee6366c4871e42ea05a38d5011128fe932b6591/lib/lib.dom.d.ts#L3652-L3654

https://github.com/microsoft/TypeScript/blob/cee6366c4871e42ea05a38d5011128fe932b6591/lib/lib.dom.d.ts#L4858-L4967

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 $el and that’s where things start to get complicated. At first glance I think it would even cause a breaking change for user component code, but first I will have to take a closer look at all the call sites and some of the secondary effects in user code in more detail… 👍

If you want to work on a PR, then by all means - happy to guide you! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

What exactly can cause an "HIERARCHY_REQUEST_ERR ...
It means you've tried to insert a DOM node into a place in the DOM tree where it cannot go. The most common...
Read more >
Undeclared use of node's process causes exception ... - GitHub
I suggest avoiding the use of a node module bundler that doesn't properly bundle node modules.
Read more >
1. Document Object Model XPath - W3C
XPathException, XPathExceptionCode, XPathEvaluator ... The DOM model uses Comment nodes to represent Comment Information Items.
Read more >
JavaScript DOM and Exception Related Random topics
Hello everyone! we will discuss here some random topics about JavaScript dom and exception.And will learn try..catch blocks ,nodes, ...
Read more >
DOMException - Web APIs | MDN
DOMException is a Serializable object, so it can be cloned with structuredClone() or copied ... The node tree hierarchy is not correct.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found