Migrate remaining Component() callers to Element; delete the shim

The legacy back-compat ``Component(tag_name=...)`` function (a thin
string-returning wrapper over ``Element``) was the last piece of the
pre-node-tree API. Migrate its ~18 call sites across the views to the node
builders and remove it:

- stats_content.py: the table helpers now use the whitelisted ``Td`` / ``Th``
  / ``Tr`` builders and ``Element`` for table/tbody/thead/h1; helper return
  types are ``Node``.
- auth.py / statuschange.py / game.py / purchase.py: the hand-built
  ``<form>`` / ``<button>`` / ``<h1>`` / ``<h2>`` / ``<table>`` markup now uses
  ``Element("tag", ...)``.
- core.py: drop the ``Component()`` function and its back-compat note;
  ``common/components/__init__`` no longer exports it.
- Tests that exercised the shim now target ``Element`` directly
  (test_components cache/escaping/edge-case classes; test_node_tree drops the
  legacy-parity and legacy-bridge cases, which ``Element`` coverage subsumes).
- CLAUDE.md: drop the "legacy Component retained for back-compat" notes.

Full suite green (443; one obsolete legacy-bridge test removed).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-13 16:51:27 +02:00
parent bec7a1074c
commit 9c42d85f52
10 changed files with 79 additions and 115 deletions
-19
View File
@@ -11,11 +11,6 @@ Nodes are *lazy*: they hold structure and render to HTML only when asked
(``str(node)`` / ``node.__html__()`` / :func:`render`). This is what lets
``Page()`` walk a finished tree and collect every component's declared JS
(:class:`Media`) instead of each view threading ``scripts=`` by hand.
Backwards compatibility: the legacy ``Component(tag_name=...)`` function still
returns a ``SafeText`` string, so existing string-based call sites keep working
during the migration. Its child handling is Node-aware, so a tree mixing old
(string-returning) and new (node-returning) components renders correctly.
"""
import hashlib
@@ -288,20 +283,6 @@ def collect_media(node: "Node | str") -> Media:
return Media()
def Component(
attributes: list[HTMLAttribute] | None = None,
children: "list[HTMLTag] | HTMLTag | None" = None,
tag_name: str = "",
) -> SafeText:
"""Legacy element builder: returns a ``SafeText`` string.
Kept for backwards compatibility while call sites migrate to :class:`Element`
and the generated tag builders. Child handling is Node-aware, so a tree that
mixes string-returning and node-returning components still renders correctly.
"""
return render(Element(tag_name, attributes, children))
def randomid(seed: str = "", content: str = "", length: int = 10) -> str:
if not seed and not content:
return seed