@@ -596,6 +596,30 @@ describe("HtmlHydrate", () => {
596596 ] )
597597 } ) . pipe ( Effect . scoped ) )
598598
599+ it . effect ( "creates a missing SVG child as SVG and leaves a MathML form's submits alone" , ( ) =>
600+ Effect . gen ( function * ( ) {
601+ const Icon = Html . component ( {
602+ name : "Icon" ,
603+ model : Schema . Null ,
604+ message : Schema . Never
605+ } ) . make ( {
606+ init : ( ) => null ,
607+ update : ( $ ) => $ . model ,
608+ // Keep the form before the missing title so hydration adopts it.
609+ view : ( h ) => h . div ( h . el ( "math" , h . form . attr ( "method" , "dialog" ) ) , h . el ( "svg" , h . el ( "title" , "Chart" ) ) )
610+ } )
611+ const rendered = yield * HtmlServer . renderToHtml ( Icon , { } )
612+ const app = yield * container ( rendered . html . replace ( "<title>Chart</title>" , "" ) )
613+ // The test DOM parses <math> children as HTML; browsers use MathML.
614+ const form = document . createElementNS ( "http://www.w3.org/1998/Math/MathML" , "form" )
615+ form . setAttribute ( "method" , "dialog" )
616+ app . querySelector ( "math" ) ! . replaceChildren ( form )
617+ yield * HtmlHydrate . hydrateEffect ( Icon , { } , app , rendered . state )
618+ assert . strictEqual ( app . querySelector ( "title" ) ! . namespaceURI , "http://www.w3.org/2000/svg" )
619+ assert . strictEqual ( app . querySelector ( "math" ) ! . firstElementChild , form )
620+ assert . isTrue ( submitted ( form ) )
621+ } ) . pipe ( Effect . scoped ) )
622+
599623 it . effect ( "replaces a stale element with text inside comment markers while keeping surrounding siblings" , ( ) =>
600624 Effect . gen ( function * ( ) {
601625 const Texty = Html . component ( {
0 commit comments