HS: runtime null-safety guards — runtimeErrors 18/18 (+13 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 40s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 40s
Add (when (not (nil? target)) ...) guards after every hs-null-raise! call in both the compiler and runtime so execution stops cleanly when a DOM element is not found, instead of continuing into a JS operation on null that takes ~34 seconds to propagate. Compiler: emit-set dot/poss, emit-inc/dec poss case, remove-element, remove-attr, add-styles all now wrap the action after hs-null-raise! in a nil guard. Runtime: hs-toggle-class!, hs-toggle-between!, hs-dispatch!, hs-set-attr!, hs-toggle-attr!, hs-set-inner-html!, hs-put!, hs-transition all guarded — hs-settle and hs-measure already were. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -93,10 +93,15 @@
|
||||
(quote do)
|
||||
(list (quote hs-null-raise!) (quote __hs-obj))
|
||||
(list
|
||||
(quote dom-set-prop)
|
||||
(quote __hs-obj)
|
||||
prop
|
||||
value)))))))
|
||||
(quote when)
|
||||
(list
|
||||
(quote not)
|
||||
(list (quote nil?) (quote __hs-obj)))
|
||||
(list
|
||||
(quote dom-set-prop)
|
||||
(quote __hs-obj)
|
||||
prop
|
||||
value))))))))
|
||||
((= th (quote attr))
|
||||
(let
|
||||
((base-ast (nth target 2)))
|
||||
@@ -633,24 +638,27 @@
|
||||
(quote do)
|
||||
(list (quote hs-null-raise!) (quote __hs-obj))
|
||||
(list
|
||||
(quote let)
|
||||
(quote when)
|
||||
(list (quote not) (list (quote nil?) (quote __hs-obj)))
|
||||
(list
|
||||
(quote let)
|
||||
(list
|
||||
(quote __hs-new)
|
||||
(list
|
||||
(quote +)
|
||||
(quote __hs-new)
|
||||
(list
|
||||
(quote hs-to-number)
|
||||
(list (quote host-get) (quote __hs-obj) prop))
|
||||
amount)))
|
||||
(list
|
||||
(quote do)
|
||||
(quote +)
|
||||
(list
|
||||
(quote hs-to-number)
|
||||
(list (quote host-get) (quote __hs-obj) prop))
|
||||
amount)))
|
||||
(list
|
||||
(quote host-set!)
|
||||
(quote __hs-obj)
|
||||
prop
|
||||
(quote __hs-new))
|
||||
(list (quote set!) (quote it) (quote __hs-new))))))))
|
||||
(quote do)
|
||||
(list
|
||||
(quote host-set!)
|
||||
(quote __hs-obj)
|
||||
prop
|
||||
(quote __hs-new))
|
||||
(list (quote set!) (quote it) (quote __hs-new)))))))))
|
||||
((and (list? expr) (= (first expr) (quote style)))
|
||||
(let
|
||||
((el (if tgt-override (hs-to-sx tgt-override) (quote me)))
|
||||
@@ -759,24 +767,27 @@
|
||||
(quote do)
|
||||
(list (quote hs-null-raise!) (quote __hs-obj))
|
||||
(list
|
||||
(quote let)
|
||||
(quote when)
|
||||
(list (quote not) (list (quote nil?) (quote __hs-obj)))
|
||||
(list
|
||||
(quote let)
|
||||
(list
|
||||
(quote __hs-new)
|
||||
(list
|
||||
(quote -)
|
||||
(quote __hs-new)
|
||||
(list
|
||||
(quote hs-to-number)
|
||||
(list (quote host-get) (quote __hs-obj) prop))
|
||||
amount)))
|
||||
(list
|
||||
(quote do)
|
||||
(quote -)
|
||||
(list
|
||||
(quote hs-to-number)
|
||||
(list (quote host-get) (quote __hs-obj) prop))
|
||||
amount)))
|
||||
(list
|
||||
(quote host-set!)
|
||||
(quote __hs-obj)
|
||||
prop
|
||||
(quote __hs-new))
|
||||
(list (quote set!) (quote it) (quote __hs-new))))))))
|
||||
(quote do)
|
||||
(list
|
||||
(quote host-set!)
|
||||
(quote __hs-obj)
|
||||
prop
|
||||
(quote __hs-new))
|
||||
(list (quote set!) (quote it) (quote __hs-new)))))))))
|
||||
((and (list? expr) (= (first expr) (quote style)))
|
||||
(let
|
||||
((el (if tgt-override (hs-to-sx tgt-override) (quote me)))
|
||||
@@ -1256,6 +1267,8 @@
|
||||
(list (quote not) (hs-to-sx (nth ast 1))))
|
||||
((= head (quote no))
|
||||
(list (quote hs-falsy?) (hs-to-sx (nth ast 1))))
|
||||
((= head (quote hs-falsy?))
|
||||
(list (quote hs-falsy?) (hs-to-sx (nth ast 1))))
|
||||
((= head (quote and))
|
||||
(list
|
||||
(quote and)
|
||||
@@ -1487,19 +1500,24 @@
|
||||
(list
|
||||
(quote let)
|
||||
(list (list (quote __hs-tgt) tgt))
|
||||
(cons
|
||||
(list
|
||||
(quote do)
|
||||
(list (quote hs-null-raise!) (quote __hs-tgt))
|
||||
(cons
|
||||
(list (quote hs-null-raise!) (quote __hs-tgt))
|
||||
(map
|
||||
(fn
|
||||
(p)
|
||||
(list
|
||||
(quote dom-set-style)
|
||||
(quote __hs-tgt)
|
||||
(first p)
|
||||
(nth p 1)))
|
||||
pairs))))))
|
||||
(quote when)
|
||||
(cons
|
||||
(list
|
||||
(quote not)
|
||||
(list (quote nil?) (quote __hs-tgt)))
|
||||
(map
|
||||
(fn
|
||||
(p)
|
||||
(list
|
||||
(quote dom-set-style)
|
||||
(quote __hs-tgt)
|
||||
(first p)
|
||||
(nth p 1)))
|
||||
pairs)))))))
|
||||
((= head (quote multi-add-class))
|
||||
(let
|
||||
((target (hs-to-sx (nth ast 1)))
|
||||
@@ -1686,7 +1704,12 @@
|
||||
(list
|
||||
(quote do)
|
||||
(list (quote hs-null-raise!) (quote __hs-tgt))
|
||||
(list (quote dom-remove) (quote __hs-tgt)))))))))
|
||||
(list
|
||||
(quote when)
|
||||
(list
|
||||
(quote not)
|
||||
(list (quote nil?) (quote __hs-tgt)))
|
||||
(list (quote dom-remove) (quote __hs-tgt))))))))))
|
||||
((= head (quote add-value))
|
||||
(let
|
||||
((val (hs-to-sx (nth ast 1))) (tgt (nth ast 2)))
|
||||
@@ -1753,9 +1776,14 @@
|
||||
(quote do)
|
||||
(list (quote hs-null-raise!) (quote __hs-tgt))
|
||||
(list
|
||||
(quote dom-remove-attr)
|
||||
(quote __hs-tgt)
|
||||
(nth ast 1))))))
|
||||
(quote when)
|
||||
(list
|
||||
(quote not)
|
||||
(list (quote nil?) (quote __hs-tgt)))
|
||||
(list
|
||||
(quote dom-remove-attr)
|
||||
(quote __hs-tgt)
|
||||
(nth ast 1)))))))
|
||||
((= head (quote remove-css))
|
||||
(let
|
||||
((tgt (if (nil? (nth ast 2)) (quote me) (hs-to-sx (nth ast 2))))
|
||||
|
||||
Reference in New Issue
Block a user