htmlx-org / HTMLx

One Template to rule them all
585 stars 8 forks source link

Clarify whitespace handling #7

Open Swatinem opened 6 years ago

Swatinem commented 6 years ago

What I am missing so far from the proposal is how whitespace in-between tags, or in-between tags and control statements is handled. I actually like the way that jsx forces you to be explicit with whitespace, often forcing you to do things like <div>{" "}</div> or the like.

Rich-Harris commented 6 years ago

Good question. I'll update the README in a bit, but basically I think that HTMLx should have the same whitespace handling as HTML. Personally, <div>{" "}</div> makes me retch!

morleytatro commented 6 years ago

Agreed @Swatinem. As discussed in this thread, collapsed whitespace would be really helpful.

arxpoetica commented 6 years ago

While it's true that controlling whitespace has long ago been a pain point in plain ol' HTML, this problem has very little to do with reactive frameworks. Most of the problems mentioned in that thread are easily solved with modern CSS techniques.

If this problem is still in high demand, can we please do something other than {" "} which doesn't read anything like a whitespace handler?

Swatinem commented 6 years ago

@arxpoetica you are right, most pain points are solved today:

White it is easier to work around / handle the presence of whitespace with recent styling and dom apis, I would still argue that there is a big difference between intentional whitespace that you really want, as part of text, and unintentional whitespace that comes from code formatting and indentation which has nothing to do with text content at all.

I haven’t looked at svelte since quite some time, but back in the days I remember it used to create a lot of garbage text nodes that served absolutely no purpose and just bloated up the generated code.

Rich-Harris commented 6 years ago

I haven’t looked at svelte since quite some time, but back in the days I remember it used to create a lot of garbage text nodes that served absolutely no purpose and just bloated up the generated code.

I'm afraid that's still true — removing the unnecessary nodes is perpetually on our TODO list but never quite cracks the top three. I still think it's far preferable to {" "} though!

jacob-ebey commented 5 years ago

If it's on the TODO list, is there somewhere to vote it to the top? This is a continual source of frustration for me and with how much I talk up svelte, it's hard to talk around this one when it comes up.