Fix custom element check: require keyword arg to disambiguate from variables

Hyphenated names like app-url are variables, not custom elements.
Only treat as custom element when first arg is a Keyword (tag call pattern).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-04 13:55:36 +00:00
parent d551806976
commit f5c266e785
3 changed files with 9 additions and 9 deletions

View File

@@ -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