developit / developit/htm

Improve runtime error handling for missing close tags

Offen
#166 5 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
debugging duplicate enhancement proposal
Vorherrschende Sprache
JavaScript
Sterne
9k
Forks
181
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Consider this sample code, which accidentally omits a closing tag.

```js
import htm from 'https://unpkg.com/htm?module'
const h = (type, props, ...children) => ({type, props, children});
const html = htm.bind(h)

console.log(JSON.stringify(html`

Hello, world!`));
```

In this case, the user intended to include a closing tag `

`, and so the user's desired logged result is `{"type":"h1","props":null,"children":["Hello, world!"]}`

Actual: `["h1","Hello, world!"]` The element name is incorrectly handled as a text node.

Expected: Throw an exception.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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