diff --git a/lib/hyperscript/compiler.sx b/lib/hyperscript/compiler.sx index 62cc8074..15abbccc 100644 --- a/lib/hyperscript/compiler.sx +++ b/lib/hyperscript/compiler.sx @@ -936,12 +936,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" "1")) - ((= strategy "visibility") - (list (quote dom-set-style) tgt "visibility" "visible")) - (true (list (quote dom-set-style) tgt "display" ""))))) + (list (quote hs-show!) tgt strategy))) ((= head (quote transition)) (emit-transition ast)) ((= head (quote transition-from)) (let diff --git a/lib/hyperscript/runtime.sx b/lib/hyperscript/runtime.sx index 06d40be3..25450134 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-show! + (fn + (el strategy) + (let + ((tag (dom-get-prop el "tagName"))) + (cond + ((= tag "DIALOG") + (when (not (dom-has-attr? el "open")) (host-call el "showModal"))) + ((= tag "DETAILS") (dom-set-prop el "open" true)) + ((= strategy "opacity") (dom-set-style el "opacity" "1")) + ((= strategy "visibility") (dom-set-style el "visibility" "visible")) + (true (dom-set-style el "display" "")))))) + (define hs-first (fn (lst) (first lst))) (define hs-last (fn (lst) (last lst)))