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

bug in "asciimath.js":It cannot run in strict mode, and three global variables are accidentally defined. #2748

Closed
masx200 opened this issue Jul 27, 2021 · 2 comments
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Needed v2 v3
Milestone

Comments

@masx200
Copy link

masx200 commented Jul 27, 2021

Issue Summary

A summary of the issue and the browser/OS environment in which it occurs. If
suitable, include the steps required to reproduce the bug.

https://cdn.jsdelivr.net/npm/mathjax@3.2.0/es5/input/asciimath.min.js

bug in "asciimath.js":It cannot run in strict mode, and three global variables are accidentally defined.

"mathfontfamily"

"mathfontsize"

"value"

Steps to Reproduce:

  1. This is the first step
    Don't run it in strict mode.
<script src="https://cdn.jsdelivr.net/npm/mathjax@3.2.0/es5/startup.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3.2.0/es5/core.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3.2.0/es5/input/asciimath.min.js"></script>
console.log(Object.keys(window))
  1. This is the second step
    Run it in strict mode.
await import('https://cdn.jsdelivr.net/npm/mathjax@3.2.0/es5/startup.min.js')

startup.min.js:5 MathJax(?): Cannot read property 'MmlTree' of undefined

await import('https://cdn.jsdelivr.net/npm/mathjax@3.2.0/es5/core.min.js')
await import('https://cdn.jsdelivr.net/npm/mathjax@3.2.0/es5/input/asciimath.min.js')
asciimath.min.js:6 Uncaught TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
    at new constructor (asciimath.min.js:5)
    at Function.Subclass (asciimath.min.js:5)
    at asciimath.min.js:5
    at Object.24 (asciimath.min.js:5)
    at i (asciimath.min.js:5)
    at Object.406 (asciimath.min.js:5)
    at i (asciimath.min.js:5)
    at Object.884 (asciimath.min.js:5)
    at i (asciimath.min.js:5)
    at asciimath.min.js:5
  1. Further steps, etc.

Any other information you want to share that is relevant to the issue
being reported. Especially, why do you consider this to be a bug? What
do you expect to happen instead?

Technical details:

  • MathJax Version: 3.2.0
  • Client OS: Microsoft Windows [版本 10.0.19043.1110]
  • Browser: Chrome 92.0.902.55

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.
@masx200 masx200 changed the title bug in asciimath.js:It cannot run in strict mode, and three global variables are accidentally defined. bug in "asciimath.js":It cannot run in strict mode, and three global variables are accidentally defined. Jul 27, 2021
@dpvc
Copy link
Member

dpvc commented Feb 2, 2022

Sorry for the long delay in getting back to you on this, and thank you for the report. We are putting together a new release, and are collecting together the issues to be resolved; this is certainly one. We appreciate the PRs to fix the global variables, but I've made a separate one as I would like to resolve them in a slightly different way, and so I will be closing your two PR requests based on that. But we do appreciate your willingness to contribute to the project!

As for your await import commands, that is not how MathJax components get used. The startup module will load the other modules that are needed based on the MathJax configuration variable. This guarantees that the modules are loaded in the right order, and that any dependencies are also loaded. See the loading and configuring MathJax documentation, and in particular, the loading components individually section.

It is also possible to create your own custom component that combines the ones you need (so that there is only one file to download for your users). See the documentation for making a custom build of MathJax for details.

@dpvc dpvc added Accepted Issue has been reproduced by MathJax team Ready for Review v3 labels Feb 2, 2022
dpvc added a commit to mathjax/MathJax-src that referenced this issue Feb 22, 2022
Make variables local in legacy code.  (mathjax/MathJax#2748)
@dpvc dpvc added Merged Merged into develop branch and removed Ready for Review labels Feb 22, 2022
@masx200 masx200 closed this as completed Jun 4, 2022
@dpvc dpvc added this to the 3.2.1 milestone Jun 4, 2022
@dpvc dpvc added Fixed and removed Merged Merged into develop branch labels Jun 4, 2022
@dpvc dpvc removed their assignment Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Issue has been reproduced by MathJax team Fixed Test Needed v2 v3
Projects
None yet
Development

No branches or pull requests

2 participants