Skip to content

Clarify whitespace handling #7

Open

Description

@Swatinem

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.

Activity

  1. Rich-Harris commented on May 1, 2018

    @Rich-Harris
    Collaborator

    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!

  2. morleytatro commented on May 2, 2018

    @morleytatro

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

  3. arxpoetica commented on May 2, 2018

    @arxpoetica

    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?

  4. Swatinem commented on May 2, 2018

    @Swatinem
    Author

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

    • flexbox/grid as alternative to inline-block
    • firstElementChild/nextElementSibling and friends
    • inspectors that do pretty-printing for you
    • modern frameworks that
      • suppress whitespace by default (?)
      • free you from having to touch the dom manually

    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.

  5. Rich-Harris commented on May 2, 2018

    @Rich-Harris
    Collaborator

    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!

  6. jacob-ebey commented on Feb 24, 2019

    @jacob-ebey

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions