@attr boolean/number setter function called with an empty string (v2-beta)
- Lenguaje dominante
- TypeScript
- Estrellas
- 1.4k
- Forks
- 59
- Merge medio
- 22 h 12 min
- PR fusionados (30 d)
- 5
Descripción
This is maybe related to #117, but not 100% sure on that.
With a component defined like this:
```typescript
import { controller, attr } from '@github/catalyst'
@controller
class TestComponentElement extends HTMLElement {
@attr get booleanProp() {
return false
}
set booleanProp( _v: boolean ) {
console.dir( `booleanProp type: ${ typeof _v }` )
console.dir( `booleanProp value: '${ _v }'` )
}
connectedCallback() {
this.booleanProp = true
}
}
```
and html like this (note the lack of an initial `boolean-prop` value):
```html
```
I get these log messages:
```
booleanProp type: boolean
booleanProp value: 'true'
booleanProp type: string
booleanProp value: ''
```
Changing the html to include an initial value like this:
```html
```
get's rid of that final empty string call:
```
booleanProp type: boolean
booleanProp value: 'true'
```
Maybe this is a limitation? Hopefully this isn't another ghost bug, sorry about the last one 🫣
Guía de contribución
Línea de trabajo
Start at the @attr decorator entry point and reproduce the behavior with the TypeScript component and HTML snippets in the issue. Trace the setter calls for a missing boolean-prop attribute and compare them with the calls when an initial value is present. Done means the expected setter behavior is established and covered by an appropriate test or documented as a limitation.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- frontend
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100