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

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

Aberta
#161 4 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
TypeScript
Estrelas
38
Forks
27
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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?

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.