Firefox reports ChildCountIncorrect for msubsup from cases + sum (htmlAndMathml)
Description
When KaTeX htmlAndMathml output for a cases environment containing \sum_{i=1}^{n} is embedded in a standalone HTML file and opened in Firefox (zh-CN locale shows: 无效标签:<msubsup/> 标签的子标签数不正确 / English: Invalid markup: Incorrect number of children for <msubsup/> tag.), Firefox reports a MathML arity error for <msubsup>.
This matches the Firefox ChildCountIncorrect localization (dom/chrome/mathml/mathml.properties). The /> in the message is from the localization template, not necessarily a void element in the markup.
Related history: #1800 (fixed for \log_{10} ApplyFunction nesting), #3721 (x_{\min}), #3500.
Reproduction
\begin{cases}
S = \sum_{i=1}^{n} w_i \cdot x_i \\
w_i = \frac{e^{z_i}}{\sum_{j=1}^{n} e^{z_j}} \\
\text{score} = \tanh(S) \cdot 100
\end{cases}Rendered with KaTeX 0.16.22 / rehype-katex default (output: 'htmlAndMathml'), then saved as a full HTML document and opened in Firefox.
Generated MathML fragment (element child count looks like 3 for msubsup):
<msubsup><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>n</mi></msubsup>Firefox still reports ChildCountIncorrect for msubsup when laying out the accessibility MathML (.katex-mathml). Visual HTML (.katex-html) renders fine.
Environment
- KaTeX: 0.16.22 (also via rehype-katex)
- Browser: Firefox (Developer Edition 153 / zh-CN) — Chromium does not show this dialog
- OS: Windows 10
Notes
DOM inspection shows msubsup.childElementCount === 3, so this may be a Firefox layout-frame counting quirk with KaTeX’s hidden MathML, or a subtle MathML validity issue not visible from element counts alone. Either way, consumers that ship KaTeX MathML in offline HTML hit a loud Firefox error.
Workaround for exporters: strip .katex-mathml (or use output: 'html') and keep .katex-html only.
Source: KaTeX/KaTeX