UNPKG

@kickscondor/umbrellajs

Version:

Lightweight and intuitive javascript library

22 lines (17 loc) 621 B
// Call an event manually on all the nodes u.prototype.trigger = function (events) { var data = this.slice(arguments).slice(1); return this.eacharg(events, function (node, event) { var ev; // Allow the event to bubble up and to be cancelable (as default) var opts = { bubbles: true, cancelable: true, detail: data }; try { // Accept different types of event names or an event itself ev = new window.CustomEvent(event, opts); } catch (e) { ev = document.createEvent('CustomEvent'); ev.initCustomEvent(event, true, true, data); } node.dispatchEvent(ev); }); };