parseAttribute: a boolean attribute without a value reads as false

Abierto
#199 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
javascript
Área
frontend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
JavaScript
Estrellas
30
Forks
5
Merge medio
1 h 57 min
PR fusionados (30 d)
10

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de webtides/element-js

Todos los issues de webtides/element-js

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.