fixed an error that is caused by the timeout firing after the element has been removed from the DOM #591

Merged
merged 3 commits into from Dec 10, 2013

Conversation

Projects
None yet
3 participants
@ghost

ghost commented Dec 6, 2013

In some cases where a can-value bound select-element is inserted and then removed from the DOM in the same can.batch, the .set function may throw an error because this.element is not defined anymore, when the timeout from init finally fires.

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Dec 9, 2013

Contributor

Is there a way to test this? I can see that something goes wrong and wouldn't have too much of a problem merging without one but it would be nice to know when this happens.

Contributor

daffl commented Dec 9, 2013

Is there a way to test this? I can see that something goes wrong and wouldn't have too much of a problem merging without one but it would be nice to know when this happens.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Dec 9, 2013

Phew, let me look into my code and see if I can make it test out of it.

ghost commented Dec 9, 2013

Phew, let me look into my code and see if I can make it test out of it.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Dec 9, 2013

Hm, I'm not quite sure if the test is a good idea. It works, if you run it in the browser and with jQuery. It won't work with any other lib (due to the fact I needed jQuery's .remove in order to actually remove the DOM-node.)

If you have any idea how to do that without jQuery, please tell me. If I do it simply by using parent.removeChild() the node will be gone from DOM, but the binding will still have this.element; while using $('select').remove() does set this to null - thus, causing the issue.

ghost commented Dec 9, 2013

Hm, I'm not quite sure if the test is a good idea. It works, if you run it in the browser and with jQuery. It won't work with any other lib (due to the fact I needed jQuery's .remove in order to actually remove the DOM-node.)

If you have any idea how to do that without jQuery, please tell me. If I do it simply by using parent.removeChild() the node will be gone from DOM, but the binding will still have this.element; while using $('select').remove() does set this to null - thus, causing the issue.

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Dec 10, 2013

Contributor

Ah nice. I think can.remove should work for all libraries.

Contributor

daffl commented Dec 10, 2013

Ah nice. I think can.remove should work for all libraries.

0ff added some commits Dec 10, 2013

Added a breaking test for can-value bindings on select-elements, wher…
…e the timeout is firing after the element has been removed from the DOM
Fixed a bug in can-value bindings on select-elements, where the timeo…
…ut is firing after the element has been removed from the DOM.
@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Dec 10, 2013

Awesome, thanks for the hint :-) I was able to build a working async-test now and even find another issue which I fixed with the latest commit. All should be fine now.

ghost commented Dec 10, 2013

Awesome, thanks for the hint :-) I was able to build a working async-test now and even find another issue which I fixed with the latest commit. All should be fine now.

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Dec 10, 2013

Contributor

Awesome, thank you for catching that!

Contributor

daffl commented Dec 10, 2013

Awesome, thank you for catching that!

daffl added a commit that referenced this pull request Dec 10, 2013

Merge pull request #591 from simpleTechs/patch-3
fixed an error that is caused by the timeout firing after the element has been removed from the DOM

@daffl daffl merged commit aae41de into canjs:master Dec 10, 2013

1 check passed

default The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment