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

Projects
None yet
1 participant
@daffl
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 daffl added the regression label Jun 25, 2015

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Jul 8, 2015

Contributor

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.

Contributor

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 from Control binding on can.compute change gets can.Compute instance to can.compute change handler context should be the function not the can.Compute object Jul 8, 2015

daffl added a commit that referenced this issue Jul 10, 2015

daffl added a commit that referenced this issue Jul 10, 2015

daffl added a commit that referenced this issue Jul 10, 2015

@daffl daffl closed this in #1777 Jul 10, 2015

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