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

[BUG 3.13] Observer on CP receiving wrong value #18246

Closed
simonihmig opened this issue Aug 9, 2019 · 5 comments
Closed

[BUG 3.13] Observer on CP receiving wrong value #18246

simonihmig opened this issue Aug 9, 2019 · 5 comments

Comments

@simonihmig
Copy link
Contributor

Here is a reproduction, that is failing starting w/ 3.13.0-beta.1 (same on canary): https://codesandbox.io/embed/my-app-i4i02?initialpath=/tests

The failing test is this one:

  test("case 3", function(assert) {
    assert.expect(3);

    const Dummy = EmberObject.extend({
      foo: true,

      _foo: computed("foo", {
        get() {
          return this.get("foo");
        },
        set(key, value) {
          // eslint-disable-line no-unused-vars
          return value;
        }
      }),

      _fooTracker: observer("_foo", function() {
        let value = this.get("_foo");
        assert.notOk(value);
      })
    });

    const subject = Dummy.create();

    assert.ok(subject.get("_foo"));
    subject.set("_foo", false);
    assert.notOk(subject.get("_foo"));
  });

_foo in the observer function is (still) true (makes the assertion fail), while it should be false as the observer is triggered by setting it explicitly to false. Another super weird thing is that the third assertion (the last line in the test) now also fails, while it does not fail when _foo is not read from in the observer (see the "case2" test in the sandbox).

Also the observer does see the updated value of true, when not observing the CP _foo, but directly the simple property foo (see "case1").

@pzuraq
Copy link
Contributor

pzuraq commented Aug 9, 2019

I believe this may be fixed by some changes in #18223

@rwjblue
Copy link
Member

rwjblue commented Aug 9, 2019

We should ensure (by adding a test)...

@simonihmig
Copy link
Contributor Author

Ok, I'll try to add a PR with that failing test...

simonihmig added a commit to simonihmig/ember.js that referenced this issue Aug 9, 2019
@simonihmig
Copy link
Contributor Author

Here's a failing test: #18248

@simonihmig
Copy link
Contributor Author

Fixed by #18248!

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

3 participants