ember-cli / ember-cli/core-object

Clobbering `this` from `options` might be murky

Aperta
#26 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
16
Fork
16
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

If I understand [the constructor](https://github.com/ember-cli/core-object/blob/9138b1f55da74386b9547110ee5b6f52afcdfa65/core-object.js#L18-L20) correctly, we're providing the ability to assign arbitrary properties on `this` through an `options` hash as a common base class constructor.

I used to do this in early versions of Broccoli plugin classes because it seemed convenient. I stopped doing it when I started running into cases where some library upgrade would cause property names to start colliding with option names. I simply do `this.options = options` in constructors ever since, and have been much happier with that.

My suggestion would be to make the base class constructor empty, and let people do their own option handling. I realize this might be a breaking change, but perhaps it's worth considering for the next major version?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia dal costruttore in core-object.js alle righe 18–20 e verifica in che modo la classe base assegna le proprietà a partire dall'options hash. Determina le implicazioni di compatibilità e migrazione del rendere vuoto quel costruttore; il lavoro è completo quando la decisione relativa al breaking-change e il comportamento previsto sono documentati e sono stati identificati i test interessati.

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

Valutazione

Stack tecnologico
javascript
Ambito
developer-experience
Tipo di issue
Refactoring
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.