Skip to content

Fix Svelte 5 compile break on raw-HTML tables (<table><tr> without <tbody>) - #793

Merged
mishig25 merged 1 commit into
mainfrom
fix-svelte5-table-nesting
Jul 3, 2026
Merged

Fix Svelte 5 compile break on raw-HTML tables (<table><tr> without <tbody>)#793
mishig25 merged 1 commit into
mainfrom
fix-svelte5-table-nesting

Conversation

@mishig25

@mishig25 mishig25 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What

Follow-up to #792fixes downstream doc builds currently broken on main (e.g. hub-docs build).

Svelte 5 raises a hard compile error (node_invalid_placement) when <tr> is a direct child of <table>: browsers auto-insert <tbody> while parsing, which breaks Svelte's hydration assumptions. Svelte 4 tolerated it. Raw-HTML tables in doc markdown commonly use exactly this idiom (hub-docs/docs/hub/transformers-js.md, bertopic.md, …).

Fix

  • preprocessors/mdsvex/index.js: after mdsvex processing, wrap direct-child <tr> runs in an explicit <tbody>. The rendered DOM is identical to what browsers auto-inserted for the pre-Svelte-5 output, so no visual/CSS change (tbody tr selectors already assumed it).
  • svelte.config.js: silence Svelte 5's new element_invalid_self_closing_tag warning — md-generated content triggers it pervasively (<video ... />, <div id=... />) and it's non-actionable noise in build logs.

Tables that already declare <thead>/<tbody> are untouched (the regex only fires when <tr> directly follows <table …>).

Verification

Full local hub-docs build (doc-builder build hub docs/hub --not_python_module --html, 268 pages — the exact job that failed): passes, output contains <table><tbody><tr>. No other node_invalid_placement patterns surfaced across the 274 source files.

🤖 Generated with Claude Code

Svelte 5 raises a hard compile error (node_invalid_placement) when <tr>
is a direct child of <table>, which is a common raw-HTML idiom in doc
markdown (e.g. hub-docs transformers-js.md) and broke downstream doc
builds after #792. Wrap direct-child rows in an explicit <tbody> after
mdsvex processing — the resulting DOM is identical to what browsers
auto-inserted for the old output.

Also silence the new element_invalid_self_closing_tag warning, which
md-generated content triggers pervasively (<video ... />, <div ... />).

Verified with a full local hub-docs build (268 pages, previously failing).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mishig25
mishig25 merged commit e2e7253 into main Jul 3, 2026
5 checks passed
@mishig25
mishig25 deleted the fix-svelte5-table-nesting branch July 3, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant