From 3a15f830592f4825f548c91699592da545cd0a5f Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Fri, 11 Sep 2015 10:44:50 -0400 Subject: [PATCH] Adjust role for SVG output and put aria-label on the SVG element rather than the enclosing span; add role and aria-label to CHTML output. Resolves issue #1192. --- unpacked/jax/output/CommonHTML/jax.js | 3 +++ unpacked/jax/output/SVG/jax.js | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index 65fa68910..20420ca51 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -1666,6 +1666,9 @@ MML.math.Augment({ toCommonHTML: function (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) { node.parentNode.style.width = this.CHTML.pwidth; node.parentNode.style.minWidth = this.CHTML.mwidth; diff --git a/unpacked/jax/output/SVG/jax.js b/unpacked/jax/output/SVG/jax.js index 1718cc829..c273f3a9d 100644 --- a/unpacked/jax/output/SVG/jax.js +++ b/unpacked/jax/output/SVG/jax.js @@ -2100,9 +2100,8 @@ // Add it to the MathJax span // var alttext = this.Get("alttext"); - if (alttext && !svg.element.getAttribute("aria-label")) span.setAttribute("aria-label",alttext); - if (!svg.element.getAttribute("role")) span.setAttribute("role","math"); -// span.setAttribute("tabindex",0); // causes focus outline, so disable for now + if (alttext && !svg.element.getAttribute("aria-label")) svg.element.setAttribute("aria-label",alttext); + if (!svg.element.getAttribute("role")) svg.element.setAttribute("role","img"); span.appendChild(svg.element); svg.element = null; //