Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

each-in breaks for getters and keys with dots #17927

Closed
asakusuma opened this issue Apr 16, 2019 · 3 comments
Closed

each-in breaks for getters and keys with dots #17927

asakusuma opened this issue Apr 16, 2019 · 3 comments

Comments

@asakusuma
Copy link
Contributor

  1. If you pass an object defined with defineProperties, the property is ignored.
  2. If you pass an object with a property that has a key with a dot in it, the property value is empty.

Whatever version ember-twiddle uses (3.4.3 I think) doesn't have the dot key problem, but it does have the getter problem: https://ember-twiddle.com/306025f713fe62a25bf8eb61dafc5e1d

Reproduction on 3.9 that has both problems: asakusuma/each-in-getter-repro@bd2dab3

@rwjblue
Copy link
Member

rwjblue commented Apr 16, 2019

Duplicate of #17529, would you mind chiming in over there?

@asakusuma
Copy link
Contributor Author

@rwjblue I believe the If you pass an object defined with defineProperties, the property is ignored. is not a duplicate. I think it's a separate issue. The twiddle is on ember 3.4, and can reproduce the defineProperties issue. I believe #17529 was introduced much later.

@rwjblue
Copy link
Member

rwjblue commented May 8, 2020

The second item (the one that is talking about {{#each-in with an object with keys that have a period in them) is working now, and I've debugged to figure out what is going on in the other case.

{{#each-in is iterating over all of a given object's keys, effectively Object.keys(theObject). If we were to use { get foo() { return 'bar'; } } in the demo, it works perfectly. The difference is that in the defineProperties version, we have not declared that foo is enumerable!.

tldr; Changing your demo to:

    const getter = Object.create(Object.prototype, {
      foo: {
        enumerable: true,
        get: function () {
          return 'bar';
        }
      }
    });

Works perfectly 😸.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants