developit / developit/htm

Improve runtime error handling for missing close tags

Aperta
#166 5 commenti 1 reazione 0 assegnatari Vedi su GitHub
debugging duplicate enhancement proposal
Lingua principale
JavaScript
Stelle
9k
Fork
181
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.