From 875e9ba317e77da76134f5fb2cd6a22ef9daaf63 Mon Sep 17 00:00:00 2001 From: giles Date: Sun, 26 Apr 2026 15:02:47 +0000 Subject: [PATCH] HS: empty multi-element fix (+1 test) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit empty .class compiled (empty-target (query ".class")) to (hs-empty-target! (hs-query-first ".class")) via hs-to-sx — only emptying the first match. Fix: detect (query ...) target in the empty-target compiler case and emit (for-each (fn (_el) (hs-empty-target! _el)) (hs-query-all sel)) instead, mirroring the add-class pattern. Suite hs-upstream-empty: 12/13 → 13/13. Smoke 0-195: 175/195 unchanged. Co-Authored-By: Claude Sonnet 4.6 --- lib/hyperscript/compiler.sx | 12 +++++++++++- shared/static/wasm/sx/hs-compiler.sx | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/hyperscript/compiler.sx b/lib/hyperscript/compiler.sx index 67188e5e..ada765d4 100644 --- a/lib/hyperscript/compiler.sx +++ b/lib/hyperscript/compiler.sx @@ -1547,7 +1547,17 @@ (emit-set tgt (list (quote hs-empty-like) (hs-to-sx tgt)))) - (true (list (quote hs-empty-target!) (hs-to-sx tgt)))))) + (true + (if + (and (list? tgt) (= (first tgt) (quote query))) + (list + (quote for-each) + (list + (quote fn) + (list (quote _el)) + (list (quote hs-empty-target!) (quote _el))) + (list (quote hs-query-all) (nth tgt 1))) + (list (quote hs-empty-target!) (hs-to-sx tgt))))))) ((= head (quote open-element)) (list (quote hs-open!) (hs-to-sx (nth ast 1)))) ((= head (quote close-element)) diff --git a/shared/static/wasm/sx/hs-compiler.sx b/shared/static/wasm/sx/hs-compiler.sx index 67188e5e..ada765d4 100644 --- a/shared/static/wasm/sx/hs-compiler.sx +++ b/shared/static/wasm/sx/hs-compiler.sx @@ -1547,7 +1547,17 @@ (emit-set tgt (list (quote hs-empty-like) (hs-to-sx tgt)))) - (true (list (quote hs-empty-target!) (hs-to-sx tgt)))))) + (true + (if + (and (list? tgt) (= (first tgt) (quote query))) + (list + (quote for-each) + (list + (quote fn) + (list (quote _el)) + (list (quote hs-empty-target!) (quote _el))) + (list (quote hs-query-all) (nth tgt 1))) + (list (quote hs-empty-target!) (hs-to-sx tgt))))))) ((= head (quote open-element)) (list (quote hs-open!) (hs-to-sx (nth ast 1)))) ((= head (quote close-element))