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:
@@ -14,7 +14,7 @@
|
|||||||
// =========================================================================
|
// =========================================================================
|
||||||
|
|
||||||
var NIL = Object.freeze({ _nil: true, toString: function() { return "nil"; } });
|
var NIL = Object.freeze({ _nil: true, toString: function() { return "nil"; } });
|
||||||
var SX_VERSION = "2026-03-23T17:58:42Z";
|
var SX_VERSION = "2026-03-23T18:18:45Z";
|
||||||
|
|
||||||
function isNil(x) { return x === NIL || x === null || x === undefined; }
|
function isNil(x) { return x === NIL || x === null || x === undefined; }
|
||||||
function isSxTruthy(x) { return x !== false && !isNil(x); }
|
function isSxTruthy(x) { return x !== false && !isNil(x); }
|
||||||
|
|||||||
@@ -497,4 +497,13 @@
|
|||||||
(let ((rules (collected "cssx")))
|
(let ((rules (collected "cssx")))
|
||||||
(clear-collected! "cssx")
|
(clear-collected! "cssx")
|
||||||
(when (not (empty? rules))
|
(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>")))))))
|
||||||
|
|||||||
Reference in New Issue
Block a user