ember-cli / ember-cli/core-object
Clobbering `this` from `options` might be murky
- Vorherrschende Sprache
- JavaScript
- Sterne
- 16
- Forks
- 16
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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?
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Beginne mit dem Konstruktor in core-object.js in den Zeilen 18–20 und prüfe, wie die Basisklasse Eigenschaften aus dem options hash zuweist. Ermittle die Kompatibilitäts- und Migrationsauswirkungen eines leeren Konstruktors; abgeschlossen ist die Aufgabe, wenn die breaking-change-Entscheidung und das erwartete Verhalten dokumentiert und die betroffenen Tests identifiziert sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- developer-experience
- Issue-Typ
- Refactoring
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100