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

@tracked on a property does not allow that property to be reverted via unexecute

Aperta
#207 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
38
Fork
27
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

If the object passed into changeset has a property marked with `@tracked` this causes the property
not to be able to be reverted with the `unexecute` method.

This is because in the `mergeDeep` the method [`mergeTargetAndSource`](https://github.com/adopted-ember-addons/validated-changeset/blob/main/src/utils/merge-deep.ts#L87) is called. In that method,
the test for `propertyIsUnsafe` is true because the `@tracked` used `defineProperty` to create the property
which is by default not enumerable and fails the test in [`propertyIsUnsafe`](https://github.com/adopted-ember-addons/validated-changeset/blob/main/src/utils/merge-deep.ts#L47). Not exactly sure what this unsafe
test is guarding against. Since the property is unsafe, it continues on to the code to [`buildPathToValue`](https://github.com/adopted-ember-addons/validated-changeset/blob/main/src/utils/merge-deep.ts#L93) which
yields no valid paths for the property, so the old value is not reassigned.

Had the `@tracked` property been defined as enumerable, the code would have considered it a safe continued on to one of
the sets at line [113](https://github.com/adopted-ember-addons/validated-changeset/blob/main/src/utils/merge-deep.ts#L113), [121](https://github.com/adopted-ember-addons/validated-changeset/blob/main/src/utils/merge-deep.ts#121), or [124](https://github.com/adopted-ember-addons/validated-changeset/blob/main/src/utils/merge-deep.ts#L124)

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.