Dispatch event on the target element.
@param {Element} element - The event target.
@param {string} type - The event type(s).
@param {Object} data - The additional event data.
@returns {boolean} Indicate if the event is default prevented or not.
function dispatchEvent(element, type, data) {
  var event; // Event and CustomEvent on IE9-11 are global objects, not constructors

  if (isFunction(Event) && isFunction(CustomEvent)) {
    event = new CustomEvent(type, {
      detail: data,
      bubbles: true,
      cancelable: true
    });
  } else {
    event = document.createEvent('CustomEvent');
    event.initCustomEvent(type, true, true, data);
  }

  return element.dispatchEvent(event);
}