Skip to content
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

Trimming newlines near elements #253

Open
kurumpa opened this issue Nov 14, 2023 · 0 comments
Open

Trimming newlines near elements #253

kurumpa opened this issue Nov 14, 2023 · 0 comments

Comments

@kurumpa
Copy link

kurumpa commented Nov 14, 2023

When running the following code:

import htm from 'https://unpkg.com/htm?module'

function h(type, props, ...children) {
  return { type, props, children };
}

const html = htm.bind(h);

console.log( html`<div>
        <b>bold</b>
        regular
    </div>` );

I am getting the following object:

{
  type: 'div',
  props: null,
  children: [{type: 'b' /* , ... */}, 'regular']
}

The string have been auto-formatted but still seems to be a valid HTML code. Now I have implemented my own h() function as I'd like to compose the DOM elements in my way. However, I don't see any obvious way to split bold and regular elements with a space except for inserting &nbsp; (#234). I'd appreciate any comments on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant