Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading fails if body does not contain div #329

Open
voegtlel opened this issue Jun 17, 2024 · 0 comments
Open

Loading fails if body does not contain div #329

voegtlel opened this issue Jun 17, 2024 · 0 comments

Comments

@voegtlel
Copy link

Hello,

it may seem strange, but this fails:

<html><head><script>
document.addEventListener("DOMContentLoaded", function() {
  // Uncommenting this makes the loading succeed. It must be a div, e.g. a table does not help.
  //document.body.appendChild(document.createElement('div'));
  let script = document.createElement('script');
  script.src = "https://cdn.jsdelivr.net/npm/[email protected]/es5/bundle.js";
  script.onload = function() { window.loadMathJax(); };
  document.head.append(script);
});
</script></head><body></body></html>

with the error:

Error load MathJax => Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.

it fails in this place in the bundle.js:

                            if (!document.getElementById("SVG-styles")) {
                                var s = u.MathJax.Stylesheet();
                                document.head.appendChild(s)
                            }

apparently, in the error case, s is not an html node, after adding a div node to the body (the commented line), it becomes a proper html node.

I'm not blocked by this (workaround is commented out), but found it a strange situation and hard to find the error, so I believe this should be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant