From d42717d4b9a354ae77c3986f6c42b04debd357a9 Mon Sep 17 00:00:00 2001 From: giles Date: Mon, 13 Apr 2026 11:29:54 +0000 Subject: [PATCH] HS: route hide through hs-hide! runtime (dialog/details support) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirrors hs-show! pattern — dialog calls close(), details sets open=false. No test count change (custom strategy tests need behavior system). Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/hyperscript/compiler.sx | 7 +------ lib/hyperscript/runtime.sx | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/hyperscript/compiler.sx b/lib/hyperscript/compiler.sx index 15abbccc..710c98ca 100644 --- a/lib/hyperscript/compiler.sx +++ b/lib/hyperscript/compiler.sx @@ -926,12 +926,7 @@ (let ((tgt (hs-to-sx (nth ast 1))) (strategy (if (> (len ast) 2) (nth ast 2) "display"))) - (cond - ((= strategy "opacity") - (list (quote dom-set-style) tgt "opacity" "0")) - ((= strategy "visibility") - (list (quote dom-set-style) tgt "visibility" "hidden")) - (true (list (quote dom-set-style) tgt "display" "none"))))) + (list (quote hs-hide!) tgt strategy))) ((= head (quote show)) (let ((tgt (hs-to-sx (nth ast 1))) diff --git a/lib/hyperscript/runtime.sx b/lib/hyperscript/runtime.sx index 25450134..41286add 100644 --- a/lib/hyperscript/runtime.sx +++ b/lib/hyperscript/runtime.sx @@ -497,6 +497,20 @@ (host-call el "close") (dom-set-prop el "open" false))))) +(define + hs-hide! + (fn + (el strategy) + (let + ((tag (dom-get-prop el "tagName"))) + (cond + ((= tag "DIALOG") + (when (dom-has-attr? el "open") (host-call el "close"))) + ((= tag "DETAILS") (dom-set-prop el "open" false)) + ((= strategy "opacity") (dom-set-style el "opacity" "0")) + ((= strategy "visibility") (dom-set-style el "visibility" "hidden")) + (true (dom-set-style el "display" "none")))))) + (define hs-show! (fn