@@ -94,6 +94,12 @@ const voidElements = new Set([
9494
9595const foreignContextElements = new Set ( [ "math" , "svg" ] ) ;
9696
97+ /**
98+ * Elements that can be used to integrate HTML content within foreign namespaces (e.g., SVG or MathML).
99+ *
100+ * Entries must use the SVG-adjusted casing (e.g. "foreignObject" not
101+ * "foreignobject") since they are compared against adjusted tag names.
102+ */
97103const htmlIntegrationElements = new Set ( [
98104 "mi" ,
99105 "mo" ,
@@ -364,8 +370,10 @@ export class Parser implements Callbacks {
364370
365371 /*
366372 * Closing tags for SVG elements inside HTML integration points
367- * (e.g. </foreignObject> while inside its own content) still need
368- * case adjustment so the name matches what was pushed to the stack.
373+ * (e.g. </foreignObject> while inside its own content) need case
374+ * adjustment so the name matches what was pushed to the stack.
375+ * `foreignContext.length > 1` means a foreign ancestor exists —
376+ * the base [None] entry plus at least one pushed context.
369377 */
370378 if ( this . foreignContext . length > 1 ) {
371379 const adjusted = svgTagNameAdjustments . get ( name ) ;
@@ -395,7 +403,12 @@ export class Parser implements Callbacks {
395403 this . openTagStart = this . startIndex ;
396404 this . tagname = name ;
397405
398- // The spec ignores a second <form> when one is already open.
406+ /*
407+ * The spec ignores a second <form> when one is already open.
408+ * Setting tagname to "" suppresses all downstream effects: attribs
409+ * stays null so endOpenTag is a no-op, and closeCurrentTag can't
410+ * match "" on the stack.
411+ */
399412 if ( this . htmlMode && name === "form" && this . stack . includes ( "form" ) ) {
400413 this . tagname = "" ;
401414 return ;
0 commit comments