CSSX flush appends to persistent head stylesheet

~cssx/flush now appends rules to <style id="sx-css"> in <head>
instead of creating ephemeral inline <style> tags that get morphed
away during SPA navigation. Rules accumulate across navigations.

Future: reference-count rules and remove when no elements use them.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-23 18:19:04 +00:00
parent fe84b57bed
commit c4224925f9
2 changed files with 11 additions and 2 deletions

View File

@@ -497,4 +497,13 @@
(let ((rules (collected "cssx")))
(clear-collected! "cssx")
(when (not (empty? rules))
(raw! (str "<style data-cssx>" (join "" rules) "</style>")))))
;; Append to the persistent <style id="sx-css"> in <head> if available.
;; This survives #main-panel morphs during SPA navigation.
;; Falls back to inline <style> if no head stylesheet exists.
(let ((head-style (dom-query "#sx-css")))
(if head-style
(do
(dom-set-prop head-style "textContent"
(str (dom-get-prop head-style "textContent") (join "" rules)))
nil)
(raw! (str "<style data-cssx>" (join "" rules) "</style>")))))))