Pessoalmente, uso uma função de wrapper para manipular eventos criados manualmente. O código a seguir adicionará um método estático em todas as Eventinterfaces (todas as variáveis globais terminadas em Eventsão uma interface de eventos) e permitirá que você chame funções como element.dispatchEvent(MouseEvent.create('click'));no IE9 +.
(function eventCreatorWrapper(eventClassNames){
eventClassNames.forEach(function(eventClassName){
window[eventClassName].createEvent = function(type,bubbles,cancelable){
var evt
try{
evt = new window[eventClassName](type,{
bubbles: bubbles,
cancelable: cancelable
});
} catch (e){
evt = document.createEvent(eventClassName);
evt.initEvent(type,bubbles,cancelable);
} finally {
return evt;
}
}
});
}(function(root){
return Object.getOwnPropertyNames(root).filter(function(propertyName){
return /Event$/.test(propertyName)
});
}(window)));
EDIT: A função para encontrar todas as Eventinterfaces também pode ser substituída por uma matriz para alterar apenas as interfaces de evento necessárias ( ['Event', 'MouseEvent', 'KeyboardEvent', 'UIEvent' /*, etc... */]).