[rdom] comment nodes cause exception
See original GitHub issueThis 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.
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 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:
- Created 10 months ago
- Comments:7 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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!
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 nativeComment
type unfortunately is not a normalElement
: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! 😃