Fix duplicate sx-cssx-live style tags
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Cache the style element reference in _cssx-style-el so flush-cssx-to-dom never creates more than one. Previous code called dom-query on every flush, which could miss the element during rapid successive calls, creating duplicates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -618,7 +618,7 @@
|
||||
(if (not (nil? renamed))
|
||||
renamed
|
||||
;; General mangling rules
|
||||
(let ((result name))
|
||||
(let ((result (replace name "*" "_")))
|
||||
;; Handle trailing ? and !
|
||||
(let ((result (cond
|
||||
(ends-with? result "?")
|
||||
@@ -1422,23 +1422,27 @@
|
||||
(= (keyword-name (nth expr 2)) "effects"))
|
||||
(nth expr 4)
|
||||
(nth expr 2))))
|
||||
(if (nil? val-expr)
|
||||
(str "var " (js-mangle name) " = NIL;")
|
||||
;; Detect zero-arg self-tail-recursive functions → while loops
|
||||
(if (and (list? val-expr)
|
||||
(not (empty? val-expr))
|
||||
(= (type-of (first val-expr)) "symbol")
|
||||
(or (= (symbol-name (first val-expr)) "fn")
|
||||
(= (symbol-name (first val-expr)) "lambda"))
|
||||
(list? (nth val-expr 1))
|
||||
(= (len (nth val-expr 1)) 0)
|
||||
(js-is-self-tail-recursive? name (rest (rest val-expr))))
|
||||
;; While loop optimization
|
||||
(let ((body (rest (rest val-expr)))
|
||||
(loop-body (js-emit-loop-body name body)))
|
||||
(str "var " (js-mangle name) " = function() { while(true) { " loop-body " } };"))
|
||||
;; Normal define
|
||||
(str "var " (js-mangle name) " = " (js-expr val-expr) ";"))))))
|
||||
(let ((mangled (js-mangle name))
|
||||
(var-decl
|
||||
(if (nil? val-expr)
|
||||
(str "var " (js-mangle name) " = NIL;")
|
||||
;; Detect zero-arg self-tail-recursive functions → while loops
|
||||
(if (and (list? val-expr)
|
||||
(not (empty? val-expr))
|
||||
(= (type-of (first val-expr)) "symbol")
|
||||
(or (= (symbol-name (first val-expr)) "fn")
|
||||
(= (symbol-name (first val-expr)) "lambda"))
|
||||
(list? (nth val-expr 1))
|
||||
(= (len (nth val-expr 1)) 0)
|
||||
(js-is-self-tail-recursive? name (rest (rest val-expr))))
|
||||
;; While loop optimization
|
||||
(let ((body (rest (rest val-expr)))
|
||||
(loop-body (js-emit-loop-body name body)))
|
||||
(str "var " mangled " = function() { while(true) { " loop-body " } };"))
|
||||
;; Normal define
|
||||
(str "var " mangled " = " (js-expr val-expr) ";")))))
|
||||
;; Self-register: every spec define is available to evaluated SX code
|
||||
(str var-decl "\nPRIMITIVES[\"" name "\"] = " mangled ";")))))
|
||||
|
||||
|
||||
;; --------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user