JSFiddle - React, Tailwind, and code Playground

by pimvdb

HTML

<input type="text" oncustombind="console.log(e, type, getElementById);" id="x" />

JavaScript

function trigger(elem, name, e) {
    var func = new Function('e',
    
      'with(document) {'
    + 'with(this) {'
    + elem.getAttribute('on' + name)
    + '}'
    + '}');
    
    func.call(elem, e);
}

trigger(document.getElementById('x'), 'custombind', {foo: 123});