From 9ab6067c103e3229f5335d89dea20c69f379ad4e Mon Sep 17 00:00:00 2001 From: figuerom16 <112363116+figuerom16@users.noreply.github.com> Date: Sun, 14 Jun 2026 19:04:18 -0700 Subject: [PATCH 1/4] Change recompute function to not mutate on mx-ignore --- moxi.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/moxi.js b/moxi.js index 3a146bc..a4b4820 100644 --- a/moxi.js +++ b/moxi.js @@ -2,8 +2,8 @@ let doc = document if(doc.__moxi_mo) return let liveFns = new Set(), pending = false, - recompute = ()=>{ - if (pending) return + recompute = (evt)=>{ + if (pending || ignore(evt.target)) return pending = true queueMicrotask(()=>{liveFns.forEach(f=>f()); setTimeout(()=>pending = false)}) } From ba555f5a1798587401693103871b36f1ad091c2b Mon Sep 17 00:00:00 2001 From: figuerom16 <112363116+figuerom16@users.noreply.github.com> Date: Sun, 14 Jun 2026 23:55:47 -0700 Subject: [PATCH 2/4] Use optional chaining for evt.target in recompute evt can be undefined. --- moxi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moxi.js b/moxi.js index a4b4820..bc323cc 100644 --- a/moxi.js +++ b/moxi.js @@ -3,7 +3,7 @@ if(doc.__moxi_mo) return let liveFns = new Set(), pending = false, recompute = (evt)=>{ - if (pending || ignore(evt.target)) return + if (pending || ignore(evt?.target)) return pending = true queueMicrotask(()=>{liveFns.forEach(f=>f()); setTimeout(()=>pending = false)}) } From 343d8d03128610444b27ec5cea24b555aa1d9e92 Mon Sep 17 00:00:00 2001 From: figuerom16 <112363116+figuerom16@users.noreply.github.com> Date: Mon, 15 Jun 2026 00:13:36 -0700 Subject: [PATCH 3/4] Fix condition check in recompute function evt was still throwing undefined error --- moxi.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moxi.js b/moxi.js index bc323cc..20bc75b 100644 --- a/moxi.js +++ b/moxi.js @@ -3,7 +3,7 @@ if(doc.__moxi_mo) return let liveFns = new Set(), pending = false, recompute = (evt)=>{ - if (pending || ignore(evt?.target)) return + if (pending || (evt && ignore(evt.target))) return pending = true queueMicrotask(()=>{liveFns.forEach(f=>f()); setTimeout(()=>pending = false)}) } From dfaac789159397a38469ee91e1c50a3194c07165 Mon Sep 17 00:00:00 2001 From: figuerom16 <112363116+figuerom16@users.noreply.github.com> Date: Mon, 15 Jun 2026 00:18:41 -0700 Subject: [PATCH 4/4] Use optional chaining for simplicity --- moxi.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/moxi.js b/moxi.js index 20bc75b..91f370e 100644 --- a/moxi.js +++ b/moxi.js @@ -3,7 +3,7 @@ if(doc.__moxi_mo) return let liveFns = new Set(), pending = false, recompute = (evt)=>{ - if (pending || (evt && ignore(evt.target))) return + if (pending || ignore(evt?.target)) return pending = true queueMicrotask(()=>{liveFns.forEach(f=>f()); setTimeout(()=>pending = false)}) } @@ -17,7 +17,7 @@ DB = Symbol(), mkDb = ()=>{let last = 0, j; return ms=>new Promise((r,rj)=>{j?.(DB); j = rj; let id = ++last; setTimeout(()=>id == last && (j = null, r()), ms)})}, mkWait = ctx=>x=>new Promise(r=>typeof x == "number" ? setTimeout(r,x) : el(ctx,x,r,{once:1})), - ignore = elt=>elt.closest("[mx-ignore]"), + ignore = elt=>elt?.closest("[mx-ignore]"), one = x=>x?[x]:[], POS = {before:"beforebegin",after:"afterend",start:"afterbegin",end:"beforeend"}, proxy = elts=>new Proxy({}, {