Improve runtime error handling for missing close tags
- 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
Research direction
Start by running the provided tagged-template sample with the htm runtime and reproduce how the missing is handled. Trace the parser path for an unclosed tag; done means the sample throws an exception instead of treating the element name as a text node, while valid tags continue to produce the expected object.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100