Closed CaptainJKoB closed 3 years ago
All interpolations use comments by design, but as these comments are always the same, and you should serve gzipped/compressed content, this should never be an issue for you.
Your workaround is OK, but also unnecessary.
TL;DR: this is how every template literal engine works (via comments used as pins for updates) and heresy uses lighterhtml, so this won't change and this is not a real-world issue.
Hope this answered your question.
I use heresy features, I just wanted to show a reproducible example. My problem isn't really the size/compression of the content, but the final output that is interpreted by the browser. I understand the usage of comments in template engines, but in this particular instance I don't think it's working as intended.
Currently for the first example above, heresy-ssr
output for the <title>
element is:
<title>My awesome title<!---0.368698%--></title>
The specification states that any content within the <title>
is interpreted as text.
So the title browsers are going to display is My awesome title<!---0.368698%-->
. The comment is not ignored.
This could cause some SEO problems, but the workaround in the second example seems to fix this issue.
The specification states that any content within the
is interpreted as text.
OK, this is a bummer, yes, but your workaround, if meant for title only, is the way I'd go too.
Herey uses basicHTML which is DOM after all, it's not a text parser, it's like a browser in NodeJS.
Being based on lighterhtml, I can't change this, but what I could do, is erase comments from <title>...</title>
only, whenever the output is rendered (via the toString()
) ... would that work for you?
Alternatively I can put this in the README, as it's a weird W3C caveat I wasn't aware myself, so apologies for closing this prematurely.
No harm done.
Rendering using toString()
seems as an acceptable solution for the <title>
element.
Using the workaround just for this instance seems kinda more as a hack to me.
Being based on lighterhtml, I can't change this
I lied ... there are special cases for uhtml/lighterhtml such as textarea and style, and I think title, together with script, xmp, and plaintext, should be added to the list of exception.
Will test around, and fix this properly.
Thanks for the bug though 👋
This should have been fixed, together with other weird cases:
Tested, works like a charm 👍 Thanks, great work.
Hello,
When rendering a dynamic title for the site heresy-ssr appends the anchor comment
<!---0.368698%-->
, which is later displayed in the title bar of the page.Example:
I found a workaround using the
ref
method but I am not really sure if it is the best solution.Is this behaviour for the
title
element right?Thank you.