Make the attribute's qualifier separator configurable (the dot breaks JSX)? #4164
Replies: 4 comments 2 replies
-
I believe _ is not allowed in attribute names. And . Is tough in jsx. Have you thought about using astro for this instead of Preact? It works nicely there. |
Beta Was this translation helpful? Give feedback.
-
Checked, and I feel like it should be possible to make this work with your linters. Does this not work at all? or just TS complains? |
Beta Was this translation helpful? Give feedback.
-
In the meantime, I think I have found a workaround - using the spread operator const onKeypress = {
'x-on:keypress.escape': 'alert(123)',
};
return (
<div {...onKeypress}>
{/* something something */}
</div>
); |
Beta Was this translation helpful? Give feedback.
-
Another way to do the same thing, also a bit of a crusty hack but in my opinion maybe less so. <div { ...{
'x:on:keypress.escape': 'alert(123)',
'x:otherattribute': 'whatever()',
} }>
{/* something something */}
</div>
); |
Beta Was this translation helpful? Give feedback.
-
I am building an application that is (only) rendered on the server (Fastify); I am building it in the open, so you can take a look. I am using JSX for server-side templating and Preact as the server-side JSX renderer. I also use Alpine and HTMX for client-side interactivity. So far, so good - the project is a BIG proof-of-concept of this idea of using mostly SSR but with modern tools, like JSX and reactivity via Alpine, without the need of a bundler...
The issue is that I cannot use qualifiers in Alpine's attribute, as in
x-on:keydown.escape
since the dot is not syntactically valid for Preact (also Prettier and eslint apparently).I wonder if we could somehow configure that dot to be another character, like "_" (which is probably safe, in Alpine's context).
What do you think? Is there any other way to fix this problem that I haven't thought of?
Attaching a screenshot just for reference.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions