From 96874484f3b55d692573ac57430a79779bc21be1 Mon Sep 17 00:00:00 2001 From: Abhishiv Saxena Date: Wed, 16 Oct 2024 11:12:16 +0530 Subject: [PATCH] v1.3.10 --- package.json | 2 +- src/dom/api.ts | 16 ++++++---------- src/dom/types.ts | 22 ---------------------- 3 files changed, 7 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index e8a2cef..26c3b1e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "alfama", - "version": "1.3.9", + "version": "1.3.10", "author": "Abhishiv Saxena", "license": "MIT", "description": "Fine-grained reactive library with no compiler, no magic, and no virtual DOM", diff --git a/src/dom/api.ts b/src/dom/api.ts index 6c6bcdc..eee232c 100644 --- a/src/dom/api.ts +++ b/src/dom/api.ts @@ -4,7 +4,6 @@ import { RenderContext, ComponentTreeStep, ComponentUtils, - EEmitter, } from "./types"; import { getDescendants, @@ -201,15 +200,12 @@ export const getRenderContext = ( const id = getVirtualElementId(element); if (!id) throw createError(101); - const renderContext: RenderContext = - (container as any)[id] || - ({ - prevState: new Map(), - el: container, - id, - reg: new Set(), - emitter: new EEmitter(), - } as RenderContext); + const renderContext: RenderContext = (container as any)[id] || { + prevState: new Map(), + el: container, + id, + reg: new Set(), + }; //console.log("renderContext", renderContext); renderContext.prevState.clear(); diff --git a/src/dom/types.ts b/src/dom/types.ts index 8c7121f..4074495 100644 --- a/src/dom/types.ts +++ b/src/dom/types.ts @@ -118,31 +118,9 @@ export interface RenderContext { el: Element; prevState: Map; reg: Set; - emitter: EEmitter; } // Context like you'll find in react/solid export type Context = { sym: symbol; }; - -export class EEmitter { - t: EventTarget; - constructor() { - this.t = new EventTarget(); - } - on(eventName: string, listener: EventListenerOrEventListenerObject | null) { - return this.t.addEventListener(eventName, listener); - } - once(eventName: string, listener: EventListenerOrEventListenerObject | null) { - return this.t.addEventListener(eventName, listener, { once: true }); - } - off(eventName: string, listener: EventListenerOrEventListenerObject | null) { - return this.t.removeEventListener(eventName, listener); - } - emit(eventName: string, detail: any) { - return this.t.dispatchEvent( - new CustomEvent(eventName, { detail, cancelable: true }) - ); - } -}