fix(browserTrigger): do not use document.createEvent method

Firefox 23 has deprecated the use of createEvent for transition and
animation events.  We must now use `new TransitionEvent()` and
`new AnimationEvent()` if they are available.

But of course IE doesn't support this format correctly so we must wrap
the attempt in a try block and revert to document.createEvent if necessary..
This commit is contained in:
Pete Bacon Darwin 2013-09-07 07:19:25 +01:00
parent d50ed6bfb8
commit 4def730de7

View file

@ -96,8 +96,13 @@
evnt.initEvent(eventType, false, true);
}
else {
evnt = document.createEvent('TransitionEvent');
evnt.initTransitionEvent(eventType, null, null, null, eventData.elapsedTime);
try {
evnt = new TransitionEvent(eventType, eventData);
}
catch(e) {
evnt = document.createEvent('TransitionEvent');
evnt.initTransitionEvent(eventType, null, null, null, eventData.elapsedTime);
}
}
}
else if(/animationend/.test(eventType)) {
@ -106,8 +111,13 @@
evnt.initEvent(eventType, false, true);
}
else {
evnt = document.createEvent('AnimationEvent');
evnt.initAnimationEvent(eventType, null, null, null, eventData.elapsedTime);
try {
evnt = new AnimationEvent(eventType, eventData);
}
catch(e) {
evnt = document.createEvent('AnimationEvent');
evnt.initAnimationEvent(eventType, null, null, null, eventData.elapsedTime);
}
}
}
else {