-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
AcceptedIssue has been reproduced by MathJax teamIssue has been reproduced by MathJax teamCode ExampleContains an illustrative code example, solution, or work-aroundContains an illustrative code example, solution, or work-aroundReady for Reviewv4
Description
Issue Summary
When a DOM node that MathJax.typesetPromise was called on is removed from the DOM during the rendering process, the font size of the mjx-test node cannot be computed. window.getComputedStyle returns an empty string as value of the fontSize property and HTMLAdaptor.fontSize returns NaN.
https://github.com/mathjax/MathJax-src/blob/master/ts/adaptors/HTMLAdaptor.ts#L587
This results in console errors:
Error: <svg> attribute height: Expected length, "NaNex".
Error: <svg> attribute viewBox: Expected number, "0 -666 NaN NaN".
In our case the removal of the node happens due to the re-rendering of the involved React components.
Steps to Reproduce:
- Call
MathJax.typesetPromiseon a DOM node - Remove the node from the DOM
Technical details:
- MathJax Version: 4.0.0
- Client OS: macOS 15.6.1
- Browser: Chrome 141.0.7390.108
I am using the following MathJax configuration:
MathJax = {
startup: {
typeset: false,
pageReady() {
…
},
},
loader: {
load: ['ui/safe'],
source: {
'[tex]/amsCd': '[tex]/amscd',
},
},
output: {
fontPath: `${mathJaxPath}/mathjax-newcm-font`,
},
options: {
safeOptions: {
allow: {
//
// Values can be "all", "safe", or "none"
//
URLs: 'none', // 'none' to prevent cookie theft through external URLs
classes: 'safe', // safe start with mjx- (can be set by pattern below)
cssIDs: 'safe', // safe start with mjx- (can be set by pattern below)
styles: 'safe', // safe are in safeStyles below
},
//
// Which styles are allowed
//
safeStyles: {
color: true,
backgroundColor: true,
border: true,
cursor: true,
margin: true,
padding: true,
textShadow: true,
fontFamily: true,
fontSize: true,
fontStyle: true,
fontWeight: true,
opacity: true,
outline: true,
},
lengthMax: 3, // Largest padding/border/margin, etc. in em's
scriptsizemultiplierRange: [0.6, 1], // Valid range for scriptsizemultiplier
scriptlevelRange: [-2, 2], // Valid range for scriptlevel
classPattern: /^mjx-[-a-zA-Z0-9_.]+$/, // Pattern for allowed class names
idPattern: /^mjx-[-a-zA-Z0-9_.]+$/, // Pattern for allowed ids
dataPattern: /^data-mjx-/, // Pattern for data attributes
},
},
tex: {
inlineMath: [['$', '$']],
displayMath: [['$$', '$$']],
processEscapes: true,
},
};and loading MathJax via
<script src="/mathjax/tex-svg.js"></script>Supporting information:
- Please supply a link to a (live) minimal example page, when possible.
- If your issue is with the display of the mathematics produced by MathJax, include a screen snapshot that illustrates the problem, when possible.
- Check your browser console window for any error messages, and include them here.
- Include the MathJax configuration you are using, and the script tag that loads MathJax itself.
Metadata
Metadata
Assignees
Labels
AcceptedIssue has been reproduced by MathJax teamIssue has been reproduced by MathJax teamCode ExampleContains an illustrative code example, solution, or work-aroundContains an illustrative code example, solution, or work-aroundReady for Reviewv4