1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2025-07-01 12:22:15 +02:00

💥 Events and README idea presentation

This commit is contained in:
2023-08-23 15:37:32 +02:00
parent dc3d8133bb
commit 31563c4f7b
5 changed files with 253 additions and 86 deletions

8
src/events.js Normal file
View File

@ -0,0 +1,8 @@
export function listen(event, listener, options){
return element=> element.addEventListener(event, listener, options);
}
export function dispatch(event, detail){
if(typeof event === "string")
event= typeof detail==="undefined" ? new Event(event) : new CustomEvent(event, { detail });
return element=> element.dispatchEvent(event);
}