Skip to content

Commit

Permalink
[main.js] getHTML: add aria-label to correct childnode
Browse files Browse the repository at this point in the history
Resolves #289
  • Loading branch information
pkra committed Feb 8, 2017
1 parent 5bb9b98 commit 14c33c2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ function GetHTML(result) {
if (data.speakText){
for (var i=0, m=html.childNodes.length; i < m; i++)
html.childNodes[i].setAttribute("aria-hidden",true);
if (!html.getAttribute("aria-label")) html.setAttribute("aria-label",result.speakText);
if (!html.firstChild.getAttribute("aria-label")) html.firstChild.setAttribute("aria-label",result.speakText);
}
// remove automatically generated IDs
var ids = html.querySelectorAll('[id^="MJXc-Node-"]');
Expand Down
16 changes: 16 additions & 0 deletions test/issue289.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var tape = require('tape');
var mjAPI = require("../lib/main.js");

tape('mmlNode should not produce mml', function(t) {
t.plan(1);
mjAPI.start();
var mml = '<math alttext="0"><mn>1</mn></math>';

mjAPI.typeset({
math: mml,
format: "MathML",
htmlNode: true
}, function(data) {
t.equal(data.htmlNode.parentNode.querySelectorAll('[aria-label]').length, 1, 'Aria-label is unique');
});
});

0 comments on commit 14c33c2

Please sign in to comment.