This would be simpler with something like:

```
var eventNameMap = {
  transitionend: {
    'transition': 'transitionend',
    'WebkitTransition': 'webkitTransitionEnd',
    'MozTransition': 'mozTransitionEnd',
    'OTransition': 'oTransitionEnd',
    'msTransition': 'MSTransitionEnd'
  },

  animationend: {
  'animation': 'animationend' 
  }
} 

if {!('AnimationEvent' in window) {
  delete eventNameMap['animation']
}
```