developit / developit/htm

Improve runtime error handling for missing close tags

Open
#166 5 comments 1 reaction 0 assignees View on GitHub
debugging duplicate enhancement proposal
Dominant language
JavaScript
Stars
9k
Forks
181
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.