parseAttribute: a boolean attribute without a value reads as false

Aperta
#199 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript
Ambito
frontend

Direzione di ricerca

Start by finding parseAttribute() and tracing where declared property defaults are available to attribute parsing on both the server and client. Check the existing tests for boolean and string defaults, then add coverage for a bare attribute, an absent attribute, "false", and an empty string with a string default. Done when both renderers agree and all acceptance criteria pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Goal

A boolean attribute without a value (<el-notification open>) turns its property on, as it does on every native element.

Context

parseAttribute() turns "true" and "false" into booleans and leaves the empty string as it is, so open="" is falsy. Svelte renders open={true} on a custom element as a bare open, and so does anyone who writes HTML by hand. With @webtides/element-library 0.2.0 a server-rendered <el-notification open> therefore reads open as off when it connects, adds is-hidden, and shows again a few frames later, once the framework has set the property: the notification blinks on every page load, and the content below it jumps. element-js 1.3.0. Hit in loewen-digital/sveltekit-ai-starter-template (issue #22 there); the template writes open="true" on every notification that starts open.

Acceptance criteria

  • For a property whose default is a boolean, an attribute that is present with an empty value reads as true; an absent attribute and "false" read as false.
  • A property with a string default keeps the empty string.
  • The server renderer and the client agree on this.

Proposal (non-binding)

In parseAttribute(), or where attributes become properties: when the declared default is a boolean and the value is "", return true.

Out of scope

How a true property is reflected back to the attribute.

Lingua principale
JavaScript
Stelle
30
Fork
5
Merge medio
1h 57m
PR unite (30g)
10

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di webtides/element-js

Tutte le issue di webtides/element-js

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.