Description
It may be worth extending JSXText
with a case for Comment
. In a way it's a bit weird as it is technically as if the comment in 'abc/*def*/ghi'
would actually work. But practically, I think it makes sense, commenting out JSXElements is currently quite unintuitive/hacky as you have to write:
<compa>
{/*This text should not be printed: */} value
<compb>
{//<compc></compc>} -- actually broken right now IIRC
</compb>
</compa>
Note that comments actually affect (split) the children too, rather than being transparent. I'm proposing extending the syntax to support the following:
<compa>
/*This text should not be printed: */ value
<compb>
//<compc></compc>
</compb>
</compa>
As I mentioned, it is a bit weird in a way but still rather intuitive and useful, especially in the sense of having JSX feel like a true extension of JS and not just sugar. I think there is little to lose here; /*
, */
and //
are unlikely to occur in text, if they do then HTML-entities or JS-escaping (#4) to the rescue. Or if you don't care about children {'/*'}
(half-related #6, leading/tailing whitespace).