JSFiddle - React, Tailwind, and code Playground
HTML
<div id="output"></div>
JavaScript
// create div
var div = document.createElement("div");
div.style.border = "1px dotted red";
div.innerHTML = "I'm the div";
document.body.appendChild(div);
// implement eventListenerList property
(function() {
Element.prototype.eventListenerList = {};
Element.prototype._addEventListener = Element.prototype.addEventListener;
Element.prototype.addEventListener = function(a,b,c) {
this._addEventListener(a,b,c);
if(!this.eventListenerList[a]) this.eventListenerList[a] = [];
this.eventListenerList[a].push(b);
};
})();
// create handlers
function handlerA() { alert('a'); }
function handlerB() { alert('b'); }
function handlerC() { alert('c'); }
// attach handlers
div.addEventListener("click",handlerA);
div.onclick = handlerC;
div.addEventListener("click",handlerB);
// print click handlers
var output = document.getElementById("output");
if(div.eventListenerList.click)
div.eventListenerList.click.forEach(function(f) {
output.innerHTML+= f.toString();
});
if(div.onclick)
output.innerHTML+= div.onclick.toString();