adopted-ember-addons / adopted-ember-addons/validated-changeset

getters/setters are executed against the original model, not the modified one

オープン
#161 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
38
フォーク
27
PR マージ指標
30日以内にマージされた PR はありません

説明

Consider the following class:
```ts
class A {
foo = 1;

get bar(): number {
return 2 * this.foo;
}

set bar(value: number) {
this.foo = value / 2;
}
}
```
If you create a change buffer over an instance of this class and modify it:
```ts
changebuffer.set('foo', 2);
console.log(changebuffer.get('bar')); // 2, but I'd expect 4

changebuffer.set('bar', 6);
console.log(changebuffer.get('foo')); // 1, but I'd expect 3
```
the results are a bit unexpected. Would you consider getting the property descriptor
```ts
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(target), prop);
```
and then executing it against the change buffer instance?

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。