adobe / adobe/react-webcomponent

Default model values are passed for attributes that are not present

Aperta
#13 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
104
Fork
20
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### Expected Behaviour

If I have defined a model where I specify a boolean attribute. e.g. `@byBooleanAttrVal() checked`. And, I have an instance of my web component where I do not specify that attribute (e.g. . The props passed to my React components `render` method contain the `checked` prop set to the default value from the model definition.

### Actual Behaviour

I would expect any model attributes that are not specified to not be passed as props. Otherwise, I have no way of telling whether the user set that attribute or not.

### Reproduce Scenario (including but not limited to)

I was wrapping up a React implemented checkbox widget.

#### Steps to Reproduce

1. Create a React component that takes a boolean prop
2. Create a model for that component that uses `@byBooleanAttrVal()`
3. Instantiate the web component without using the boolean attribute from your model
4. Set a breakpoint in the `render` method of your React component
5. Look at the props and see that the boolean prop has been passed in

#### Platform and Version

Chrome 72

#### Sample Code that illustrates the problem

#### Logs taken while reproducing problem

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia riproducendo lo scenario documentato di custom-element e render React, concentrandoti su come gli attributi del modello vengono raccolti e passati come props. È completato quando un attributo booleano omesso è assente dalle props di React, mentre un attributo specificato esplicitamente continua ad arrivare al render con il valore previsto.

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

Valutazione

Stack tecnologico
javascript, react
Ambito
frontend
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.