I'm using this bit of code to remove an element from the DOM once its CSS transition has completed.
elem.addEventListener('transitionend',function(e) {
this.parentNode.removeChild(this);
}, false);
But since the transition affects two properties opacity 1 -> 0, height 20px -> 0, the event fires twice, and errors on the second firing (since the element has been removed from the DOM at that point).
I tried testing for the property (as seen here: https://stackoverflow.com/a/18689069/1058739), but then obviously THAT test then fails instead.
Surely when an element is removed from the DOM all event listeners attached to it should also be removed?
What's the trick that I'm missing here?
thanks