1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2025-07-01 20:32:13 +02:00

dispatchEvent

This commit is contained in:
2023-11-21 21:22:04 +01:00
parent a2b4e19d1b
commit 56206343d1
8 changed files with 25 additions and 14 deletions

View File

@ -1,7 +1,12 @@
export { registerReactivity } from './signals-common.js';
export function dispatchEvent(name, options= {}){
export function dispatchEvent(name, options, host){
if(!options) options= {};
return function dispatch(element, ...d){
if(host){
d.unshift(element);
element= typeof host==="function"? host() : host;
}
const event= d.length ? new CustomEvent(name, Object.assign({ detail: d[0] }, options)) : new Event(name, options);
return element.dispatchEvent(event);
};