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

calling reverse on a model list breaks its "destroyed" bindings #1040

Closed
moschel opened this issue Jun 3, 2014 · 0 comments
Closed

calling reverse on a model list breaks its "destroyed" bindings #1040

moschel opened this issue Jun 3, 2014 · 0 comments
Milestone

Comments

@moschel
Copy link
Contributor

moschel commented Jun 3, 2014

The following test breaks. destroyed is triggered once, for the first trigger, but not the second one. Removing the .reverse() call will cause the test to work.

    test("model list destroy after calling reverse", function(){
        expect(2);
        var map = new can.Model({name: "map1"})
        var map2 = new can.Model({name: "map2"});
        var list = new can.Model.List([map, map2]);
        list.bind('destroyed', function(ev){
            ok(true, 'trigger destroyed')
        })
        can.trigger(map, 'destroyed');
        list.reverse();
        can.trigger(map2, 'destroyed');
    });

Reverse is calling .replace and replacing the contents of the list with the same items. So this bug might be because .replace isn't setting up the bubbling correctly.

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