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

can.compute change handler context should be the function not the can.Compute object #1763

Closed
daffl opened this issue Jun 25, 2015 · 1 comment

Comments

@daffl
Copy link
Contributor

daffl commented Jun 25, 2015

When binding to a can.compute in can.Control with a templated event handler the handler gets the instance of can.Compute not the compute function as it was in 2.1:

test('templated binding a compute', function() {
    var comp = can.compute(null);
    var Control = can.Control.extend({
        '{mycompute} change': function(value) {
            ok(typeof value === 'function', 'Compute change value is a function');
        }
    });

    new Control('#qunit-fixture', {
        mycompute: comp
    });

    comp('test');
});
@daffl daffl added the bug label Jun 25, 2015
@daffl daffl added this to the 2.2.7 milestone Jun 25, 2015
@daffl
Copy link
Contributor Author

daffl commented Jul 8, 2015

Here is a simpler test:

test('compute change handler context is set to the function not can.Compute', function() {
    var comp = can.compute(null);

    comp.bind('change', function() {
        equal(typeof this, 'function');
    });

    comp('test');
});

Basically the change handler context needs to be the can.compute function (which is what it used to be in 2.1) not the new can.Compute object.

@daffl daffl changed the title Control binding on can.compute change gets can.Compute instance can.compute change handler context should be the function not the can.Compute object Jul 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant