-
Notifications
You must be signed in to change notification settings - Fork 174
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
string interpolation in attribute does not work as expected #58
Comments
See #49 (comment) for a solution. |
Any reason this wouldn't (or couldn't) be supported? Coming from nanohtml, this was a confusing change of behavior (especially without any warning or error). It also seems weird that html`<div class="x y z"></div>` yields three classes but the interpolated version doesn't. |
This is something we lost in 2.0 as part of aligning the syntax with JSX I'm open to supporting it, since we do other things JSX doesn't support (eg: unquoted attributes). I just wouldn't want it to balloon the size if we choose to support it. FWIW for classes it might be worth using something like clsx to ensure the resulting value is normalized (when values are falsey, etc): |
I really liked the previous behavior.
the current behavior lops off everything after the The work around is to define these strings with another string template literal before usage, but then you end up having to reference variables defined at the top of the function instead of in the attribute you are reading, or use the |
I guess we could base this off of the effect on size? That's the only metric we have to compare against. If it were possible to add back support for interpolated attribute values in only a few bytes, that would seem justifiable. |
Having support for this added back in would be awesome! I'm sure @developit can work his magic and make it happen in less than one byte! 🎩 ✨ 💖 😄 |
lol I'm more counting on @jviide's magic, he's better at this than I am |
+26 bytes was the best I could do. See #93. |
The just merged PR #93 implements this functionality, adding +23 bytes to the compressed bundle size. Hopefully it works for your use case! |
...and this has now been released as a part of HTM 2.2 🎉 |
currently returns
expected
The text was updated successfully, but these errors were encountered: