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

Object.keys(property) returns an empty array on an object property that has not been mutated

未关闭
#191 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
38
派生
27
PR 合并指标
30 天内没有已合并 PR

描述

Given this code

```
let objectToWrap = {
objectProperty: {
foo: 'bar',
},
};

let changeset = Changeset(objectToWrap);

let keys = Object.keys(changeset.objectProperty);
```

I would expect `keys` to be `['foo']` but it returns an empty array.

I believe the issue lies here: https://github.com/validated-changeset/validated-changeset/blob/c1c95b729aae80fd30b30b691202a94c974a3309/src/utils/object-tree-node.ts#L56

It always returns `ownKeys` from `node.changes` even if no changes have been made.

I have created a repro here, but it's just the code above https://github.com/elgordino/validated-changeset-repro

I've raised a PR with tests. Not sure if the overall approach is the best way forward, but it works :)

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。