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

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

Abierto
#207 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
38
Forks
27
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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)

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.