WebReflection/hyperHTML

_hyper comments are unexpectedly added

Closed this issue · 2 comments

On hyperHTML 2.5.10:

html`<a>${""}</a>`
//<a><!--_hyper: 1357959763;--></a>

Is this intended behavior?

Yes, it is by design.

You may read the following issue: #79 (comment)

comments are a way to anchor interpolations to a specific point in the DOM.

comments are causing zero issues in terms of layout, these do not affect performance because do not trigger repaints or reflows, and are "ugly" only for the inspector but also very handy for debugging since these mark where hyperHTML would swap nodes.

html`a ${'b'} c`

That simple template targets the comment right after b, and relate the interpolation to it.

Whenever you pass another string or even a document fragment, whatever is related before that comment will be replaced by the new content.

node.insertBefore(newValue, commentAsAnchor)

In this way, there's no way there could be memory leaks holding previous nodes anywhere around, the only reference is a comment and when such content will be trashed, its comments and related interpolations will vanish.

TL;DR yes, this is by design and there is nothing to worry about.