From 9284a946ba54334d8a59f6d05f6178ef139c1c9d Mon Sep 17 00:00:00 2001 From: giles Date: Fri, 13 Mar 2026 03:35:00 +0000 Subject: [PATCH] Guard domAppend/domInsertAfter against spread values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Spread values (from ~cssx/tw etc.) are attribute dicts, not DOM nodes. When they appear in non-element contexts (fragments, islands, lakes, reactive branches), they must not be passed to appendChild/insertBefore. Add _spread guard to platform domAppend and domInsertAfter — fixes TypeError: Node.appendChild: Argument 1 does not implement interface Node. Co-Authored-By: Claude Opus 4.6 --- shared/static/scripts/sx-browser.js | 6 +++--- shared/sx/ref/platform_js.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/shared/static/scripts/sx-browser.js b/shared/static/scripts/sx-browser.js index b0da85b..769076e 100644 --- a/shared/static/scripts/sx-browser.js +++ b/shared/static/scripts/sx-browser.js @@ -14,7 +14,7 @@ // ========================================================================= var NIL = Object.freeze({ _nil: true, toString: function() { return "nil"; } }); - var SX_VERSION = "2026-03-13T03:23:01Z"; + var SX_VERSION = "2026-03-13T03:34:17Z"; function isNil(x) { return x === NIL || x === null || x === undefined; } function isSxTruthy(x) { return x !== false && !isNil(x); } @@ -4369,7 +4369,7 @@ return (isSxTruthy((_batchDepth == 0)) ? (function() { } function domAppend(parent, child) { - if (parent && child) parent.appendChild(child); + if (parent && child && !child._spread) parent.appendChild(child); } function domPrepend(parent, child) { @@ -4441,7 +4441,7 @@ return (isSxTruthy((_batchDepth == 0)) ? (function() { } function domInsertAfter(ref, node) { - if (ref && ref.parentNode && node) { + if (ref && ref.parentNode && node && !node._spread) { ref.parentNode.insertBefore(node, ref.nextSibling); } } diff --git a/shared/sx/ref/platform_js.py b/shared/sx/ref/platform_js.py index 3caa4ec..0c96d3e 100644 --- a/shared/sx/ref/platform_js.py +++ b/shared/sx/ref/platform_js.py @@ -1620,7 +1620,7 @@ PLATFORM_DOM_JS = """ } function domAppend(parent, child) { - if (parent && child) parent.appendChild(child); + if (parent && child && !child._spread) parent.appendChild(child); } function domPrepend(parent, child) { @@ -1692,7 +1692,7 @@ PLATFORM_DOM_JS = """ } function domInsertAfter(ref, node) { - if (ref && ref.parentNode && node) { + if (ref && ref.parentNode && node && !node._spread) { ref.parentNode.insertBefore(node, ref.nextSibling); } }