developit / developit/htm

Trimming newlines near elements

Offen
#253 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
9k
Forks
181
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

When running the following code:
```javascript
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`


bold
regular
` );
```
I am getting the following object:
```javascript
{
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 ` ` (#234). I'd appreciate any comments on this.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.