File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -45,10 +45,17 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
45
45
46
46
MML . TeXmathchoice = MML . mbase . Subclass ( {
47
47
type : "TeXmathchoice" , notParent : true ,
48
- choice : function ( nocache ) {
48
+ choice : function ( ) {
49
+ if ( this . selection != null ) return this . selection ;
50
+ if ( this . choosing ) return 2 ; // prevent infinite loops: see issue #1151
51
+ this . choosing = true ;
49
52
var selection = 0 , values = this . getValues ( "displaystyle" , "scriptlevel" ) ;
50
53
if ( values . scriptlevel > 0 ) { selection = Math . min ( 3 , values . scriptlevel + 1 ) }
51
54
else { selection = ( values . displaystyle ? 0 : 1 ) }
55
+ // only cache the result if we are actually in place in a <math> tag.
56
+ var node = this . inherit ; while ( node && node . type !== "math" ) node = node . inherit ;
57
+ if ( node ) this . selection = selection ;
58
+ this . choosing = false ;
52
59
return selection ;
53
60
} ,
54
61
selected : function ( ) { return this . data [ this . choice ( ) ] } ,
You can’t perform that action at this time.
0 commit comments