@attr boolean/number setter function called with an empty string (v2-beta)

Offen
#295 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
45/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
typescript
Bereich
frontend

Rechercherichtung

Beginne am Einstiegspunkt des @attr-Dekorators und reproduziere das Verhalten mit der TypeScript-Komponente und den HTML-Snippets im Issue. Verfolge die Setter-Aufrufe für ein fehlendes boolean-prop-Attribut und vergleiche sie mit den Aufrufen, wenn ein Initialwert vorhanden ist. Die Aufgabe ist abgeschlossen, wenn das erwartete Setter-Verhalten festgestellt und durch einen geeigneten Test abgedeckt oder als Einschränkung dokumentiert ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

This is maybe related to #117, but not 100% sure on that.

With a component defined like this:

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):

<test-component></test-component>

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:

<test-component boolean-prop='anything'></test-component>

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 🫣

Vorherrschende Sprache
TypeScript
Sterne
1.4k
Forks
61
Ø Merge
1 T. 15 Std.
Gemergte PRs (30 T.)
8

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus github/catalyst

Alle Issues in github/catalyst

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.