use CustomEvent instead of document.createEvent