1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2024-11-21 15:39:36 +01:00

dispatchEvent

This commit is contained in:
Jan Andrle 2023-11-21 21:22:04 +01:00
parent a2b4e19d1b
commit 56206343d1
Signed by: jaandrle
GPG Key ID: B3A25AED155AFFAB
8 changed files with 25 additions and 14 deletions

File diff suppressed because one or more lines are too long

2
dist/dde.js vendored

File diff suppressed because one or more lines are too long

View File

@ -96,6 +96,8 @@ export function chainableAppend<EL extends SupportedElement>(el: EL): EL;
export function dispatchEvent(name: keyof DocumentEventMap | string, options?: EventInit):
(element: SupportedElement, data?: any)=> void;
export function dispatchEvent(name: keyof DocumentEventMap | string, options: EventInit | null, element: SupportedElement | (()=> SupportedElement)):
(data?: any)=> void;
interface On{
/** Listens to the DOM event. See {@link Document.addEventListener} */
<

File diff suppressed because one or more lines are too long

2
dist/esm.d.ts vendored
View File

@ -96,6 +96,8 @@ export function chainableAppend<EL extends SupportedElement>(el: EL): EL;
export function dispatchEvent(name: keyof DocumentEventMap | string, options?: EventInit):
(element: SupportedElement, data?: any)=> void;
export function dispatchEvent(name: keyof DocumentEventMap | string, options: EventInit | null, element: SupportedElement | (()=> SupportedElement)):
(data?: any)=> void;
interface On{
/** Listens to the DOM event. See {@link Document.addEventListener} */
<

2
dist/esm.js vendored

File diff suppressed because one or more lines are too long

2
index.d.ts vendored
View File

@ -95,6 +95,8 @@ export function chainableAppend<EL extends SupportedElement>(el: EL): EL;
export function dispatchEvent(name: keyof DocumentEventMap | string, options?: EventInit):
(element: SupportedElement, data?: any)=> void;
export function dispatchEvent(name: keyof DocumentEventMap | string, options: EventInit | null, element: SupportedElement | (()=> SupportedElement)):
(data?: any)=> void;
interface On{
/** Listens to the DOM event. See {@link Document.addEventListener} */
<

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);
};