code: function fireEvent (element, type, data) {
    const evt = document.createEvent('Event')
    evt.data = data
    for (const k in data) {
      if (data.hasOwnProperty(k)) {
        evt[k] = data[k]
      }
    }
    // need bubble.
    evt.initEvent(type, true, true)
  
    element.dispatchEvent(evt)
  }
docs: trigger and broadcast events.