Skip to content

Commit b354f9c

Browse files
committed
Update SVG handling for v2.6 (fix up <text> element attributes, and don't need to set role any more
1 parent 247cfee commit b354f9c

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

lib/mj-page.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,6 @@ function ConfigureMathJax() {
280280
div = HTML.Element("div",{className:"MathJax_SVG_Display"});
281281
div.appendChild(span);
282282
}
283-
//
284-
// Mark math for screen readers
285-
// (screen readers don't know about role="math" yet, so use "textbox" instead)
286-
//
287-
div.setAttribute("role","textbox"); div.setAttribute("aria-readonly","true");
288283
div.className += " MathJax_SVG_Processing";
289284
script.parentNode.insertBefore(div,script);
290285
//
@@ -313,11 +308,13 @@ function ConfigureMathJax() {
313308
SVG.BBOX.TEXT.Augment({
314309
Init: function (scale,text,def) {
315310
if (!def) {def = {}}; def.stroke = "none";
311+
if (def["font-style"] === "") delete def["font-style"];
312+
if (def["font-weight"] === "") delete def["font-weight"];
316313
this.SUPER(arguments).Init.call(this,def);
317314
SVG.addText(this.element,text);
318315
var bbox = {width: text.length * 8.5, height: 18, y: -12};
319316
scale *= 1000/SVG.em;
320-
this.element.setAttribute("style","font-family: monospace");
317+
this.element.setAttribute("font-family","monospace");
321318
this.element.setAttribute("transform","scale("+scale+") matrix(1 0 0 -1 0 0)");
322319
this.w = this.r = bbox.width*scale; this.l = 0;
323320
this.h = this.H = -bbox.y*scale;
@@ -599,11 +596,6 @@ function AdjustSVG() {
599596
nodes[i].removeAttribute("href");
600597
}
601598
//
602-
// Fix incorrect roles
603-
//
604-
nodes = document.querySelectorAll(".MathJax_SVG[role=textbox], .MathJax_SVG_Display[role=textbox]");
605-
for (i = nodes.length-1; i >= 0; i--) nodes[i].setAttribute("role","math");
606-
//
607599
// Fix a problem with jsdom not setting width and height CSS.
608600
//
609601
nodes = document.querySelectorAll(".MathJax_SVG > span > span");

lib/mj-single.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,6 @@ function ConfigureMathJax() {
275275
div = HTML.Element("div",{className:"MathJax_SVG_Display"});
276276
div.appendChild(span);
277277
}
278-
//
279-
// Mark math for screen readers
280-
// (screen readers don't know about role="math" yet, so use "textbox" instead)
281-
//
282-
div.setAttribute("role","textbox"); div.setAttribute("aria-readonly","true");
283278
div.className += " MathJax_SVG_Processing";
284279
script.parentNode.insertBefore(div,script);
285280
//
@@ -308,11 +303,13 @@ function ConfigureMathJax() {
308303
SVG.BBOX.TEXT.Augment({
309304
Init: function (scale,text,def) {
310305
if (!def) {def = {}}; def.stroke = "none";
306+
if (def["font-style"] === "") delete def["font-style"];
307+
if (def["font-weight"] === "") delete def["font-weight"];
311308
this.SUPER(arguments).Init.call(this,def);
312309
SVG.addText(this.element,text);
313310
var bbox = {width: text.length * 8.5, height: 18, y: -12};
314311
scale *= 1000/SVG.em;
315-
this.element.setAttribute("style","font-family: monospace");
312+
this.element.setAttribute("font-family","monospace");
316313
this.element.setAttribute("transform","scale("+scale+") matrix(1 0 0 -1 0 0)");
317314
this.w = this.r = bbox.width*scale; this.l = 0;
318315
this.h = this.H = -bbox.y*scale;

0 commit comments

Comments
 (0)