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

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

Đang mở
#161 4 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
38
Fork
27
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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?

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.