Simon Legner 1 year ago
parent 0f497e57c8
commit aeb9f8037f

@ -84,36 +84,18 @@ $.off = function (el, event, callback, useCapture) {
}; };
$.trigger = function (el, type, canBubble, cancelable) { $.trigger = function (el, type, canBubble, cancelable) {
if (canBubble == null) { const event = new Event(type, {
canBubble = true; bubbles: canBubble ?? true,
} cancelable: cancelable ?? true,
if (cancelable == null) { });
cancelable = true;
}
const event = document.createEvent("Event");
event.initEvent(type, canBubble, cancelable);
el.dispatchEvent(event); el.dispatchEvent(event);
}; };
$.click = function (el) { $.click = function (el) {
const event = document.createEvent("MouseEvent"); const event = new MouseEvent("click", {
event.initMouseEvent( bubbles: true,
"click", cancelable: true,
true, });
true,
window,
null,
0,
0,
0,
0,
false,
false,
false,
false,
0,
null,
);
el.dispatchEvent(event); el.dispatchEvent(event);
}; };

Loading…
Cancel
Save