diff --git a/shared/static/scripts/sx.js b/shared/static/scripts/sx.js index 5a04b7d..472caad 100644 --- a/shared/static/scripts/sx.js +++ b/shared/static/scripts/sx.js @@ -1194,7 +1194,7 @@ var h = v[0]; if (!isSym(h)) return false; var n = h.name; - return !!(HTML_TAGS[n] || SVG_TAGS[n] || n === "<>" || n === "raw!" || n.charAt(0) === "~" || n.indexOf("html:") === 0 || n.indexOf("-") > 0); + return !!(HTML_TAGS[n] || SVG_TAGS[n] || n === "<>" || n === "raw!" || n.charAt(0) === "~" || n.indexOf("html:") === 0 || (n.indexOf("-") > 0 && v.length > 1 && isKw(v[1]))); } function renderComponentDOM(comp, args, env) { @@ -1317,8 +1317,8 @@ return warn; } - // Custom element (hyphenated name) → render as element - if (name.indexOf("-") > 0) return renderElement(name, expr.slice(1), env, ns); + // Custom element (hyphenated name with keyword attrs) → render as element + if (name.indexOf("-") > 0 && expr.length > 1 && isKw(expr[1])) return renderElement(name, expr.slice(1), env, ns); // SVG/MathML namespace auto-detection: inside (svg ...) or (math ...), // unknown tags are created with the inherited namespace diff --git a/shared/sx/async_eval.py b/shared/sx/async_eval.py index fb8b3e9..28bdf44 100644 --- a/shared/sx/async_eval.py +++ b/shared/sx/async_eval.py @@ -672,8 +672,8 @@ async def _arender_list(expr: list, env: dict[str, Any], ctx: RequestContext) -> if isinstance(val, Component): return await _arender_component(val, expr[1:], env, ctx) - # Custom element (hyphenated name) → render as tag - if "-" in name: + # Custom element (hyphenated name with keyword attrs) → tag + if "-" in name and len(expr) > 1 and isinstance(expr[1], Keyword): return await _arender_element(name, expr[1:], env, ctx) # SVG/MathML context → unknown names are child elements @@ -1116,8 +1116,8 @@ async def _aser(expr: Any, env: dict[str, Any], ctx: RequestContext) -> Any: expanded = _expand_macro(val, expr[1:], env) return await _aser(expanded, env, ctx) - # Custom element (hyphenated name) → serialize as tag - if "-" in name: + # Custom element (hyphenated name with keyword attrs) → serialize as tag + if "-" in name and len(expr) > 1 and isinstance(expr[1], Keyword): return await _aser_call(name, expr[1:], env, ctx) # SVG/MathML context → unknown names are child elements diff --git a/shared/sx/html.py b/shared/sx/html.py index 49b7068..d739574 100644 --- a/shared/sx/html.py +++ b/shared/sx/html.py @@ -468,8 +468,8 @@ def _render_list(expr: list, env: dict[str, Any]) -> str: return _render_component(val, expr[1:], env) # Fall through to evaluation - # --- Custom element (hyphenated name) → render as tag ------------ - if "-" in name: + # --- Custom element (hyphenated name with keyword attrs) → tag ---- + if "-" in name and len(expr) > 1 and isinstance(expr[1], Keyword): return _render_element(name, expr[1:], env) # --- SVG/MathML context → unknown names are child elements --------