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

For...in loop bug in extensions/TeX/bbox.js #667

Closed
bbsmooth opened this issue Nov 13, 2013 · 2 comments

Comments

Projects
None yet
2 participants
@bbsmooth
Copy link

commented Nov 13, 2013

In bbox.js you currently have:

for(var k in j) {var f=j[k].replace(/^\s+/,"").replace(/\s+$/,"");...

j is an Array. If you have added a function to Array.prototype then the for loop breaks down because that function will be one of the properties (k) and j[k].replace() will throw an error.

Either change the for...in to a traditional for loop:

for(var k=0; k<j.length; k++)

Or add a hasOwnProperty check at the beginning of the block:

for(var k in j) {if(!j.hasOwnProperty(k)){continue;}var f=j[k].replace(/^\s+/,"").replace(/\s+$/,"");

@dpvc

This comment has been minimized.

Copy link
Member

commented Dec 10, 2013

Thanks for the report. It is something that should be fixed, and your suggestions are good. It is easy to do, and should be included in the next release.

dpvc pushed a commit to dpvc/MathJax that referenced this issue Feb 6, 2014

dpvc pushed a commit to dpvc/MathJax that referenced this issue Feb 7, 2014

@dpvc dpvc added Merged and removed Ready for Review labels Feb 7, 2014

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 7, 2014

=> Merged

@dpvc dpvc closed this Feb 7, 2014

@dpvc dpvc added v2.4 and removed Merged labels Jun 30, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.