merge branch 'develop' into more-menu (fix conflicts with Volker's changes)

This commit is contained in:
Davide P. Cervone 2015-09-14 07:27:21 -04:00
commit 45817c1519
9 changed files with 764 additions and 53 deletions

View File

@ -3105,11 +3105,13 @@ MathJax.Hub.Startup = {
isMac: (navigator.platform.substr(0,3) === "Mac"), isMac: (navigator.platform.substr(0,3) === "Mac"),
isPC: (navigator.platform.substr(0,3) === "Win"), isPC: (navigator.platform.substr(0,3) === "Win"),
isMSIE: ("ActiveXObject" in window && "clipboardData" in window), isMSIE: ("ActiveXObject" in window && "clipboardData" in window),
isEdge: ("MSGestureEvent" in window && "chrome" in window &&
window.chrome.loadTimes == null),
isFirefox: (!!AGENT.match(/Gecko\//) && !AGENT.match(/like Gecko/)), isFirefox: (!!AGENT.match(/Gecko\//) && !AGENT.match(/like Gecko/)),
isSafari: (!!AGENT.match(/ (Apple)?WebKit\//) && !AGENT.match(/ like iPhone /) && isSafari: (!!AGENT.match(/ (Apple)?WebKit\//) && !AGENT.match(/ like iPhone /) &&
(!window.chrome || window.chrome.loadTimes == null)), (!window.chrome || window.chrome.app == null)),
isChrome: (window.chrome != null && window.chrome.loadTimes != null), isChrome: ("chrome" in window && window.chrome.loadTimes != null),
isOpera: (window.opera != null && window.opera.version != null), isOpera: ("opera" in window && window.opera.version != null),
isKonqueror: ("konqueror" in window && navigator.vendor == "KDE"), isKonqueror: ("konqueror" in window && navigator.vendor == "KDE"),
versionAtLeast: function (v) { versionAtLeast: function (v) {
var bv = (this.version).split('.'); v = (new String(v)).split('.'); var bv = (this.version).split('.'); v = (new String(v)).split('.');
@ -3137,7 +3139,7 @@ MathJax.Hub.Startup = {
HUB.Browser = HUB.Insert(new String(browser),BROWSERS); HUB.Browser = HUB.Insert(new String(browser),BROWSERS);
var VERSION = new RegExp( var VERSION = new RegExp(
".*(Version/| Trident/.*; rv:)((?:\\d+\\.)+\\d+)|" + // for Safari, Opera10, and IE11+ ".*(Version/| Trident/.*; rv:)((?:\\d+\\.)+\\d+)|" + // for Safari, Opera10, and IE11+
".*("+browser+")"+(browser == "MSIE" ? " " : "/")+"((?:\\d+\\.)*\\d+)|"+ // for one of the main browser ".*("+browser+")"+(browser == "MSIE" ? " " : "/")+"((?:\\d+\\.)*\\d+)|"+ // for one of the main browsers
"(?:^|\\(| )([a-z][-a-z0-9._: ]+|(?:Apple)?WebKit)/((?:\\d+\\.)+\\d+)"); // for unrecognized browser "(?:^|\\(| )([a-z][-a-z0-9._: ]+|(?:Apple)?WebKit)/((?:\\d+\\.)+\\d+)"); // for unrecognized browser
var MATCH = VERSION.exec(xAGENT) || ["","","","unknown","0.0"]; var MATCH = VERSION.exec(xAGENT) || ["","","","unknown","0.0"];
HUB.Browser.name = (MATCH[1] != "" ? browser : (MATCH[3] || MATCH[5])); HUB.Browser.name = (MATCH[1] != "" ? browser : (MATCH[3] || MATCH[5]));
@ -3191,8 +3193,15 @@ MathJax.Hub.Startup = {
AGENT.match(/ Fennec\//) != null || AGENT.match(/ Fennec\//) != null ||
AGENT.match(/Mobile/) != null); AGENT.match(/Mobile/) != null);
}, },
Chrome: function (browser) {
browser.noContextMenu = browser.isMobile = !!navigator.userAgent.match(/ Mobile[ \/]/);
},
Opera: function (browser) {browser.version = opera.version()}, Opera: function (browser) {browser.version = opera.version()},
Edge: function (browser) {
browser.isMobile = !!navigator.userAgent.match(/ Phone/);
},
MSIE: function (browser) { MSIE: function (browser) {
browser.isMobile = !!navigator.userAgent.match(/ Phone/);
browser.isIE9 = !!(document.documentMode && (window.performance || window.msPerformance)); browser.isIE9 = !!(document.documentMode && (window.performance || window.msPerformance));
MathJax.HTML.setScriptBug = !browser.isIE9 || document.documentMode < 9; MathJax.HTML.setScriptBug = !browser.isIE9 || document.documentMode < 9;
MathJax.Hub.msieHTMLCollectionBug = (document.documentMode < 9); MathJax.Hub.msieHTMLCollectionBug = (document.documentMode < 9);

View File

@ -161,8 +161,8 @@
]], ]],
["a",{href:"http://www.mathjax.org/"},["www.mathjax.org"]], ["a",{href:"http://www.mathjax.org/"},["www.mathjax.org"]],
["span",{id: "MathJax_HelpClose", onclick: HELP.Remove, ["span",{id: "MathJax_HelpClose", onclick: HELP.Remove,
onkeydown: HELP.Keydown, tabIndex: 0, "aria-label": "Close", onkeydown: HELP.Keydown, tabIndex: 0, role: "button",
"aria-describedby": LOCALE._(["HelpDialog","CloseWindow"],"Close window")}, "aria-label": LOCALE._(["HelpDialog","CloseWindow"],"Close window")},
[["span",{},["\u00D7"]]] [["span",{},["\u00D7"]]]
] ]
])); ]));

File diff suppressed because one or more lines are too long

View File

@ -295,7 +295,7 @@
onmouseup: MENU.Mouseup, ondblclick: FALSE, onmouseup: MENU.Mouseup, ondblclick: FALSE,
ondragstart: FALSE, onselectstart: FALSE, oncontextmenu: FALSE, ondragstart: FALSE, onselectstart: FALSE, oncontextmenu: FALSE,
menuItem: this, className: "MathJax_Menu", onkeydown: MENU.Keydown, menuItem: this, className: "MathJax_Menu", onkeydown: MENU.Keydown,
role: "navigation" role: "menu"
}); });
if (event.type === "contextmenu" || event.type === "mouseover") if (event.type === "contextmenu" || event.type === "mouseover")
menu.className += " MathJax_ContextMenu"; menu.className += " MathJax_ContextMenu";
@ -614,7 +614,8 @@
{onmouseup: MENU.Mouseup, {onmouseup: MENU.Mouseup,
ondragstart: FALSE, onselectstart: FALSE, onselectend: FALSE, ondragstart: FALSE, onselectstart: FALSE, onselectend: FALSE,
ontouchstart: MENU.Touchstart, ontouchend: MENU.Touchend, ontouchstart: MENU.Touchstart, ontouchend: MENU.Touchend,
className: "MathJax_MenuItem", menuItem: this}, className: "MathJax_MenuItem", role: this.role,
menuItem: this},
def); def);
}, },
@ -695,14 +696,12 @@
* Abstract class of menu items that are focusable and perform some action * Abstract class of menu items that are focusable and perform some action
*/ */
MENU.ENTRY = MENU.ITEM.Subclass({ MENU.ENTRY = MENU.ITEM.Subclass({
role: "menuitem", // Aria role. role: "menuitem", // Aria role.
Attributes: function(def) { Attributes: function(def) {
def = HUB.Insert( def = HUB.Insert(
{onmouseover: MENU.Mouseover, onmouseout: MENU.Mouseout, {onmouseover: MENU.Mouseover, onmouseout: MENU.Mouseout,
onmousedown: MENU.Mousedown, role: this.role, onmousedown: MENU.Mousedown, onkeydown: MENU.Keydown,
onkeydown: MENU.Keydown,
"aria-disabled": !!this.disabled}, "aria-disabled": !!this.disabled},
def); def);
def = this.SUPER(arguments).Attributes.call(this, def); def = this.SUPER(arguments).Attributes.call(this, def);
@ -814,6 +813,11 @@
marker: "\u25BA", // the submenu arrow marker: "\u25BA", // the submenu arrow
markerRTL: "\u25C4", // the submenu arrow for RTL markerRTL: "\u25C4", // the submenu arrow for RTL
Attributes: function(def) {
def = HUB.Insert({"aria-haspopup": "true"}, def);
def = this.SUPER(arguments).Attributes.call(this, def);
return def;
},
Init: function (name,def) { Init: function (name,def) {
if (!(name instanceof Array)) {name = [name,name]} // make [id,label] pair if (!(name instanceof Array)) {name = [name,name]} // make [id,label] pair
this.name = name; var i = 1; this.name = name; var i = 1;
@ -907,6 +911,12 @@
marker: (isPC ? "\u25CF" : "\u2713"), // the checkmark marker: (isPC ? "\u25CF" : "\u2713"), // the checkmark
role: "menuitemradio", role: "menuitemradio",
Attributes: function(def) {
var checked = CONFIG.settings[this.variable] === this.value ? "true" : "false";
def = HUB.Insert({"aria-checked": checked}, def);
def = this.SUPER(arguments).Attributes.call(this, def);
return def;
},
Init: function (name,variable,def) { Init: function (name,variable,def) {
if (!(name instanceof Array)) {name = [name,name]} // make [id,label] pair if (!(name instanceof Array)) {name = [name,name]} // make [id,label] pair
this.name = name; this.variable = variable; this.With(def); this.name = name; this.variable = variable; this.With(def);
@ -914,7 +924,9 @@
}, },
Label: function (def,menu) { Label: function (def,menu) {
var span = {className:"MathJax_MenuRadioCheck" + this.rtlClass()}; var span = {className:"MathJax_MenuRadioCheck" + this.rtlClass()};
if (CONFIG.settings[this.variable] !== this.value) {span = {style:{display:"none"}}} if (CONFIG.settings[this.variable] !== this.value) {
span = {style:{display:"none"}};
}
return [["span",span,[this.marker]]," "+this.Name()]; return [["span",span,[this.marker]]," "+this.Name()];
}, },
Mouseup: function (event,menu) { Mouseup: function (event,menu) {
@ -922,8 +934,9 @@
var child = menu.parentNode.childNodes; var child = menu.parentNode.childNodes;
for (var i = 0, m = child.length; i < m; i++) { for (var i = 0, m = child.length; i < m; i++) {
var item = child[i].menuItem; var item = child[i].menuItem;
if (item && item.variable === this.variable) if (item && item.variable === this.variable) {
{child[i].firstChild.style.display = "none"} child[i].firstChild.style.display = "none";
}
} }
menu.firstChild.display = ""; menu.firstChild.display = "";
CONFIG.settings[this.variable] = this.value; CONFIG.settings[this.variable] = this.value;
@ -945,6 +958,12 @@
marker: "\u2713", // the checkmark marker: "\u2713", // the checkmark
role: "menuitemcheckbox", role: "menuitemcheckbox",
Attributes: function(def) {
var checked = CONFIG.settings[this.variable] ? "true" : "false";
def = HUB.Insert({"aria-checked": checked}, def);
def = this.SUPER(arguments).Attributes.call(this, def);
return def;
},
Init: function (name,variable,def) { Init: function (name,variable,def) {
if (!(name instanceof Array)) {name = [name,name]} // make [id,label] pair if (!(name instanceof Array)) {name = [name,name]} // make [id,label] pair
this.name = name; this.variable = variable; this.With(def); this.name = name; this.variable = variable; this.With(def);
@ -994,6 +1013,13 @@
* A rule in a menu * A rule in a menu
*/ */
MENU.ITEM.RULE = MENU.ITEM.Subclass({ MENU.ITEM.RULE = MENU.ITEM.Subclass({
role: "separator",
Attributes: function(def) {
def = HUB.Insert({"aria-orientation": "vertical"}, def);
def = this.SUPER(arguments).Attributes.call(this, def);
return def;
},
Label: function (def,menu) { Label: function (def,menu) {
def.className += " MathJax_MenuRule"; def.className += " MathJax_MenuRule";
return null; return null;
@ -1035,8 +1061,8 @@
["a",{href:"http://www.mathjax.org/"},["www.mathjax.org"]], ["a",{href:"http://www.mathjax.org/"},["www.mathjax.org"]],
["span",{className:"MathJax_MenuClose",id:"MathJax_AboutClose", ["span",{className:"MathJax_MenuClose",id:"MathJax_AboutClose",
onclick:MENU.About.Remove, onclick:MENU.About.Remove,
onkeydown: MENU.About.Keydown, tabIndex: 0, onkeydown: MENU.About.Keydown, tabIndex: 0, role: "button",
"aria-label": "Close", "aria-describedby": _("CloseWindow","Close window")}, "aria-label": _("CloseWindow","Close window")},
[["span",{},"\u00D7"]]] [["span",{},"\u00D7"]]]
]); ]);
if (event.type === "mouseup") about.className += " MathJax_MousePost"; if (event.type === "mouseup") about.className += " MathJax_MousePost";
@ -1230,6 +1256,7 @@
if (BROWSER.isChrome && BROWSER.version.substr(0,3) !== "24.") {message = MESSAGE.MML.WebKit} if (BROWSER.isChrome && BROWSER.version.substr(0,3) !== "24.") {message = MESSAGE.MML.WebKit}
else if (BROWSER.isSafari && !BROWSER.versionAtLeast("5.0")) {message = MESSAGE.MML.WebKit} else if (BROWSER.isSafari && !BROWSER.versionAtLeast("5.0")) {message = MESSAGE.MML.WebKit}
else if (BROWSER.isMSIE) {if (!BROWSER.hasMathPlayer) {message = MESSAGE.MML.MSIE}} else if (BROWSER.isMSIE) {if (!BROWSER.hasMathPlayer) {message = MESSAGE.MML.MSIE}}
else if (BROWSER.isEdge) {message = MESSAGE.MML.WebKit}
else {message = MESSAGE.MML[BROWSER]} else {message = MESSAGE.MML[BROWSER]}
warned = "warnedMML"; warned = "warnedMML";
} }

View File

@ -134,14 +134,14 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
aligned: ['AlignedAMSArray',null,null,null,'rlrlrlrlrlrl',COLS([0,2,0,2,0,2,0,2,0,2,0]),".5em",'D'], aligned: ['AlignedAMSArray',null,null,null,'rlrlrlrlrlrl',COLS([0,2,0,2,0,2,0,2,0,2,0]),".5em",'D'],
gathered: ['AlignedAMSArray',null,null,null,'c',null,".5em",'D'], gathered: ['AlignedAMSArray',null,null,null,'c',null,".5em",'D'],
subarray: ['Array',null,null,null,null,COLS([0,0,0,0]),"0.1em",'S',1], subarray: ['Array',null,null,null,null,COLS([0]),"0.1em",'S',1],
smallmatrix: ['Array',null,null,null,'c',COLS([1/3]),".2em",'S',1], smallmatrix: ['Array',null,null,null,'c',COLS([1/3]),".2em",'S',1],
'equation': ['EquationBegin','Equation',true], 'equation': ['EquationBegin','Equation',true],
'equation*': ['EquationBegin','EquationStar',false], 'equation*': ['EquationBegin','EquationStar',false],
eqnarray: ['AMSarray',null,true,true, 'rcl',MML.LENGTH.THICKMATHSPACE,".5em"], eqnarray: ['AMSarray',null,true,true, 'rcl',COLS([0]),".5em"],
'eqnarray*': ['AMSarray',null,false,true,'rcl',MML.LENGTH.THICKMATHSPACE,".5em"] 'eqnarray*': ['AMSarray',null,false,true,'rcl',COLS([0]),".5em"]
}, },
delimiter: { delimiter: {

View File

@ -45,7 +45,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
// //
var base, bbox; var base, bbox;
if (stretch) { if (stretch) {
base = node.getElementsByTagName("mjx-base")[0]; base = CHTML.getNode(node,"mjx-base");
} else { } else {
this.CHTMLaddChild(node,0,{type:"mjx-base", noBBox:true, forceChild:true}); this.CHTMLaddChild(node,0,{type:"mjx-base", noBBox:true, forceChild:true});
base = node.firstChild; base = node.firstChild;
@ -137,10 +137,10 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
// //
CHTMLgetScripts: function (BOX,BBOX,stretch,node) { CHTMLgetScripts: function (BOX,BBOX,stretch,node) {
if (stretch) { if (stretch) {
BOX.sub = node.getElementsByTagName("mjx-sub")[0]; BOX.sub = CHTML.getNode(node,"mjx-sub");
BOX.sup = node.getElementsByTagName("mjx-sup")[0]; BOX.sup = CHTML.getNode(node,"mjx-sup");
BOX.presub = node.getElementsByTagName("mjx-presub")[0]; BOX.presub = CHTML.getNode(node,"mjx-presub");
BOX.presup = node.getElementsByTagName("mjx-presup")[0]; BOX.presup = CHTML.getNode(node,"mjx-presup");
BBOX.sub = this.CHTMLbbox.sub; BBOX.sub = this.CHTMLbbox.sub;
BBOX.sup = this.CHTMLbbox.sup; BBOX.sup = this.CHTMLbbox.sup;
BBOX.presub = this.CHTMLbbox.presub; BBOX.presub = this.CHTMLbbox.presub;
@ -182,7 +182,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
BBOX = state.BBOX[type] = CHTML.BBOX.empty(); BBOX = state.BBOX[type] = CHTML.BBOX.empty();
if (state.w) { if (state.w) {
BOX.style.paddingLeft = CHTML.Em(state.w); BOX.style.paddingLeft = CHTML.Em(state.w);
BBOX.w = BBOX.r = state.w; BBOX.w = BBOX.r = state.w; BBOX.x = state.w;
} }
} }
data.toCommonHTML(BOX); data.toCommonHTML(BOX);
@ -198,7 +198,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
// right-justify the scripts, otherwise, left-justify them. // right-justify the scripts, otherwise, left-justify them.
// //
CHTMLpadScript: function (type,w,bbox,state) { CHTMLpadScript: function (type,w,bbox,state) {
if (!bbox) bbox = {w:0, fake:1}; if (!bbox) bbox = {w:0, fake:1, rscale:1};
var BBOX = state.BBOX[type], dx = 0, dw = 0; var BBOX = state.BBOX[type], dx = 0, dw = 0;
if (BBOX) { if (BBOX) {
if (bbox.rscale*bbox.w < w) { if (bbox.rscale*bbox.w < w) {
@ -252,7 +252,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
CHTMLplaceSubSup: function (sub,sbox,sup,Sbox,x,delta,u,v,s) { CHTMLplaceSubSup: function (sub,sbox,sup,Sbox,x,delta,u,v,s) {
sub.style.paddingRight = CHTML.Em(s); sbox.w += s; sub.style.paddingRight = CHTML.Em(s); sbox.w += s;
sup.style.paddingBottom = CHTML.Em(u+v-Sbox.d-sbox.h); sup.style.paddingBottom = CHTML.Em(u+v-Sbox.d-sbox.h);
sup.style.paddingLeft = CHTML.Em(delta); sup.style.paddingLeft = CHTML.Em(delta+(Sbox.x||0));
sup.style.paddingRight = CHTML.Em(s); Sbox.w += s; sup.style.paddingRight = CHTML.Em(s); Sbox.w += s;
sup.parentNode.style.verticalAlign = CHTML.Em(-v); sup.parentNode.style.verticalAlign = CHTML.Em(-v);
this.CHTML.combine(sbox,x,-v); this.CHTML.combine(sbox,x,-v);
@ -272,7 +272,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
CHTMLplacePresubPresup: function (presub,pbox,presup,Pbox,delta,u,v,s) { CHTMLplacePresubPresup: function (presub,pbox,presup,Pbox,delta,u,v,s) {
presub.style.paddingLeft = CHTML.Em(s); presub.style.paddingLeft = CHTML.Em(s);
presup.style.paddingBottom = CHTML.Em(u+v-Pbox.d-pbox.h); presup.style.paddingBottom = CHTML.Em(u+v-Pbox.d-pbox.h);
presup.style.paddingLeft = CHTML.Em(delta+s); presup.style.paddingLeft = CHTML.Em(delta+s+(Pbox.x||0));
presup.style.paddingRight = CHTML.Em(-delta); presup.style.paddingRight = CHTML.Em(-delta);
presup.parentNode.style.verticalAlign = CHTML.Em(-v); presup.parentNode.style.verticalAlign = CHTML.Em(-v);
this.CHTML.combine(pbox,s,-v); this.CHTML.combine(pbox,s,-v);

View File

@ -505,9 +505,9 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
// //
if (end.length === 0) { if (end.length === 0) {
var NODE = this.CHTMLnodeElement(), var NODE = this.CHTMLnodeElement(),
stack = NODE.getElementsByTagName("mjx-stack")[0], stack = CHTML.getNode(NODE,"mjx-stack"),
sup = NODE.getElementsByTagName("mjx-sup")[0], sup = CHTML.getNode(NODE,"mjx-sup"),
sub = NODE.getElementsByTagName("mjx-sub")[0]; sub = CHTML.getNode(NODE,"mjx-sub");
if (stack) node.appendChild(stack); if (stack) node.appendChild(stack);
else if (sup) node.appendChild(sup); else if (sup) node.appendChild(sup);
else if (sub) node.appendChild(sub); else if (sub) node.appendChild(sub);
@ -569,9 +569,9 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
// //
if (start.length < 1) { if (start.length < 1) {
NODE = this.CHTMLnodeElement(); NODE = this.CHTMLnodeElement();
var prestack = NODE.getElementsByTagName("mjx-prestack")[0], var prestack = CHTML.getNode(NODE,"mjx-prestack"),
presup = NODE.getElementsByTagName("mjx-presup")[0], presup = CHTML.getNode(NODE,"mjx-presup"),
presub = NODE.getElementsByTagName("mjx-presub")[0]; presub = CHTML.getNode(NODE,"mjx-presub");
if (prestack) node.appendChild(prestack); if (prestack) node.appendChild(prestack);
else if (presup) node.appendChild(presup); else if (presup) node.appendChild(presup);
else if (presub) node.appendChild(presub); else if (presub) node.appendChild(presub);
@ -598,9 +598,9 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
// //
if (end.length === 0) { if (end.length === 0) {
NODE = this.CHTMLnodeElement(); NODE = this.CHTMLnodeElement();
var stack = NODE.getElementsByTagName("mjx-stack")[0], var stack = CHTML.getNode(NODE,"mjx-stack"),
sup = NODE.getElementsByTagName("mjx-sup")[0], sup = CHTML.getNode(NODE,"mjx-sup"),
sub = NODE.getElementsByTagName("mjx-sub")[0]; sub = CHTML.getNode(NODE,"mjx-sub");
if (stack) node.appendChild(stack); if (stack) node.appendChild(stack);
else if (sup) node.appendChild(sup); else if (sup) node.appendChild(sup);
else if (sub) node.appendChild(sub); else if (sub) node.appendChild(sub);

View File

@ -325,8 +325,9 @@
if (!def) def = {}; if (!def) def = {};
if (def.isMathJax == null) def.isMathJax = true; if (def.isMathJax == null) def.isMathJax = true;
if (def.className) def.className = type+" "+def.className; else def.className = type; if (def.className) def.className = type+" "+def.className; else def.className = type;
type = "span";
} }
return this.HTMLElement("span",def,content); return this.HTMLElement(type,def,content);
}, },
addElement: function (node,type,def,content) { addElement: function (node,type,def,content) {
return node.appendChild(this.Element(type,def,content)); return node.appendChild(this.Element(type,def,content));
@ -335,6 +336,22 @@
ucMatch: HTML.ucMatch, ucMatch: HTML.ucMatch,
setScript: HTML.setScript, setScript: HTML.setScript,
//
// This replaces node.getElementsByTagName(type)[0]
// and should be replaced by that if we go back to using
// custom tags
//
getNode: (document.getElementsByClassName ?
function (node,type) {return node.getElementsByClassName(type)[0]} :
function (node,type) {
var nodes = node.getElementsByTagName("span");
var name = RegExp("\\b"+type+"\\b");
for (var i = 0, m = nodes.length; i < m; i++) {
if (name.test(nodes[i].className)) return nodes[i];
}
}
),
/********************************************/ /********************************************/
@ -361,7 +378,7 @@
// Remove any existing output // Remove any existing output
// //
prev = script.previousSibling; prev = script.previousSibling;
if (prev && prev.nodeName.toLowerCase() === "mjx-chtml") if (prev && prev.className && String(prev.className).substr(0,9) === "mjx-chtml")
prev.parentNode.removeChild(prev); prev.parentNode.removeChild(prev);
// //
// Add the node for the math and mark it as being processed // Add the node for the math and mark it as being processed
@ -1328,7 +1345,7 @@
if (child) { if (child) {
var type = options.childNodes; var type = options.childNodes;
if (type) { if (type) {
if (type instanceof Array) type = type[i]; if (type instanceof Array) type = type[i]||"span";
node = CHTML.addElement(node,type); node = CHTML.addElement(node,type);
} }
cnode = child.toCommonHTML(node,options.childOptions); cnode = child.toCommonHTML(node,options.childOptions);
@ -1667,6 +1684,9 @@
MML.math.Augment({ MML.math.Augment({
toCommonHTML: function (node) { toCommonHTML: function (node) {
node = this.CHTMLdefaultNode(node); node = this.CHTMLdefaultNode(node);
var alttext = this.Get("alttext");
if (alttext && !node.getAttribute("aria-label")) node.setAttribute("aria-label",alttext);
if (!node.getAttribute("role")) node.setAttribute("role","math");
if (this.CHTML.pwidth) { if (this.CHTML.pwidth) {
node.parentNode.style.width = this.CHTML.pwidth; node.parentNode.style.width = this.CHTML.pwidth;
node.parentNode.style.minWidth = this.CHTML.mwidth; node.parentNode.style.minWidth = this.CHTML.mwidth;
@ -2032,9 +2052,9 @@
// //
var base, under, over, nodes = []; var base, under, over, nodes = [];
if (stretch) { if (stretch) {
base = node.getElementsByTagName("mjx-op")[0]; base = CHTML.getNode(node,"mjx-op");
under = node.getElementsByTagName("mjx-under")[0]; under = CHTML.getNode(node,"mjx-under");
over = node.getElementsByTagName("mjx-over")[0]; over = CHTML.getNode(node,"mjx-over");
nodes[0] = base; nodes[1] = under||over; nodes[2] = over; nodes[0] = base; nodes[1] = under||over; nodes[2] = over;
} else { } else {
var types = ["mjx-op","mjx-under","mjx-over"]; var types = ["mjx-op","mjx-under","mjx-over"];
@ -2232,9 +2252,9 @@
// //
var base, sub, sup; var base, sub, sup;
if (stretch) { if (stretch) {
base = node.getElementsByTagName("mjx-base")[0]; base = CHTML.getNode(node,"mjx-base");
sub = node.getElementsByTagName("mjx-sub")[0]; sub = CHTML.getNode(node,"mjx-sub");
sup = node.getElementsByTagName("mjx-sup")[0]; sup = CHTML.getNode(node,"mjx-sup");
} else { } else {
var types = ["mjx-base","mjx-sub","mjx-sup"]; var types = ["mjx-base","mjx-sub","mjx-sup"];
if (this.sup === 1) types[1] = types[2]; if (this.sup === 1) types[1] = types[2];

View File

@ -2100,9 +2100,8 @@
// Add it to the MathJax span // Add it to the MathJax span
// //
var alttext = this.Get("alttext"); var alttext = this.Get("alttext");
if (alttext && !svg.element.getAttribute("aria-label")) span.setAttribute("aria-label",alttext); if (alttext && !svg.element.getAttribute("aria-label")) svg.element.setAttribute("aria-label",alttext);
if (!svg.element.getAttribute("role")) span.setAttribute("role","math"); if (!svg.element.getAttribute("role")) svg.element.setAttribute("role","img");
// span.setAttribute("tabindex",0); // causes focus outline, so disable for now
svg.element.setAttribute("focusable","false"); svg.element.setAttribute("focusable","false");
span.appendChild(svg.element); span.appendChild(svg.element);
svg.element = null; svg.element = null;