Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • M MathJax
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 304
    • Issues 304
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 15
    • Merge requests 15
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • MathJax
  • MathJax
  • Issues
  • #2490
Closed
Open
Issue created Jul 31, 2020 by Administrator@rootContributor

\toggle causes the entire <body> to be removed from DOM when clicked if converted using `MathJax.tex2chtml`

Created by: lishid

Issue Summary

\toggle causes the entire <body> to be removed from DOM when clicked if converted using MathJax.tex2chtml (using the method from the example https://github.com/mathjax/MathJax-demos-web/blob/master/input-tex2chtml.html.md)

This does not seem to happen if the tex is parsed from DOM text.

Steps to Reproduce:

Fiddle link: https://jsfiddle.net/wq8gvca3/

Source:

<html>
<head>
    <script type="text/javascript" id="MathJax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js"></script>
</head>
<body>
This text is part of the body. It will disappear once the toggle is clicked on.
<p id="container"></p>
This text is after the container.
<script>
    document.getElementById('container')
        .appendChild(MathJax.tex2chtml('\\toggle{math1}{math2}\\endtoggle'));
    MathJax.startup.document.clear();
    MathJax.startup.document.updateDocument();
</script>
</body>
</html>

Clicking on the toggle renders the entire document blank, and shows the following in the console.

Uncaught TypeError: Cannot read property 'parentNode' of null
    at c.parent (tex-chtml-full.js:1)
    at c.insert (tex-chtml-full.js:1)
    at e.l.updateDocument (tex-chtml-full.js:1)
    at Object.renderMath (tex-chtml-full.js:1)
    at v.renderMath (tex-chtml-full.js:1)
    at e.n.rerender (tex-chtml-full.js:1)
    at HTMLElement.<anonymous> (tex-chtml-full.js:1)

Preliminary debugging suggests the removal came from: https://github.com/mathjax/MathJax-src/blob/1d5ce9837c82f1d12efec8da829c2138bd640c08/ts/handlers/html/HTMLMathItem.ts#L87

Seems like the start node was set to the

element rather than the element that's actual rendered.

Technical details:

  • MathJax Version: 3.0.5 (tex-chtml-full)
  • Client OS: Windows 10 1909
  • Browser: Chrome 83.0.4103.116

Supporting information:

Assignee
Assign to
Time tracking