Setting computes created with computeData will throw if set first #1297

Closed
matthewp opened this Issue Oct 31, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@matthewp
Contributor

matthewp commented Oct 31, 2014

Because of this line if you try to set the value of a compute created this way before having read the value, an exception will be thrown.

Breaking test added.

@matthewp matthewp added the bug label Oct 31, 2014

matthewp added a commit that referenced this issue Oct 31, 2014

@daffl daffl added this to the 2.1.4 milestone Nov 7, 2014

matthewp added a commit that referenced this issue Nov 19, 2014

Allow scope computeData to be written to before being read
Fixes #1297. You can't set a value before reading because the setter
depends on having a rootObserve (that is a compute) and rootReads (an
		array) that were not given initial values. Simply giving them
initial values fixes it.

matthewp added a commit that referenced this issue Nov 19, 2014

matthewp added a commit that referenced this issue Nov 19, 2014

Allow scope computeData to be written to before being read
Fixes #1297. You can't set a value before reading because the setter
depends on having a rootObserve (that is a compute) and rootReads (an
		array) that were not given initial values. Simply giving them
initial values fixes it.
@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Nov 21, 2014

Contributor

#1336 has a fix which allows setting properties on the scope. The test referenced here needs to be slightly changed and now looks like this:

test("Compute set prior to being read", function(){
  var scope = new can.view.Scope({
    name: "Matthew"
  });

  scope.attr("name", "Wilbur");

  equal(scope.attr("name"), "Wilbur", "Value updated");
});

This also works for computes and nested maps.

Contributor

daffl commented Nov 21, 2014

#1336 has a fix which allows setting properties on the scope. The test referenced here needs to be slightly changed and now looks like this:

test("Compute set prior to being read", function(){
  var scope = new can.view.Scope({
    name: "Matthew"
  });

  scope.attr("name", "Wilbur");

  equal(scope.attr("name"), "Wilbur", "Value updated");
});

This also works for computes and nested maps.

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Nov 21, 2014

Contributor

Closed via #1336

Contributor

daffl commented Nov 21, 2014

Closed via #1336

@daffl daffl closed this Nov 21, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment