developit / developit/htm

Improve runtime error handling for missing close tags

Ouverte
#166 5 commentaires 1 réaction 0 personnes assignées Voir sur GitHub
debugging duplicate enhancement proposal
Langage dominant
JavaScript
Étoiles
9k
Forks
181
Métriques de merge des PR
Aucune PR mergée en 30 j

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.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
javascript
Domaine
frontend
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.