File tree Expand file tree Collapse file tree 3 files changed +23
-4
lines changed
Expand file tree Collapse file tree 3 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -570,9 +570,11 @@ function GetHTML(result) {
570570
571571 // add speech text if there isn't one
572572 if ( data . speakText ) {
573- for ( var i = 0 , m = html . childNodes . length ; i < m ; i ++ )
574- html . childNodes [ i ] . setAttribute ( "aria-hidden" , true ) ;
575- if ( ! html . getAttribute ( "aria-label" ) ) html . setAttribute ( "aria-label" , result . speakText ) ;
573+ var labelTarget = html . querySelector ( '.mjx-math' ) ;
574+ for ( child of labelTarget . childNodes ) child . setAttribute ( "aria-hidden" , true ) ;
575+ if ( ! labelTarget . getAttribute ( "aria-label" ) ) {
576+ labelTarget . setAttribute ( "aria-label" , result . speakText ) ;
577+ }
576578 }
577579 // remove automatically generated IDs
578580 var ids = html . querySelectorAll ( '[id^="MJXc-Node-"]' ) ;
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ tape('Generate dummy speechText', function(t) {
1717
1818 mjSpeechTest = function ( data , expected , desc ) {
1919 var document = jsdom ( data . html ) . defaultView . document ;
20- var element = document . querySelector ( '.MJXc-display ' ) ;
20+ var element = document . querySelector ( '.mjx-math ' ) ;
2121 var actual = element . getAttribute ( 'aria-label' ) ;
2222 t . equal ( actual , expected , 'HTML output contains speechText from ' + desc ) ;
2323 document = jsdom ( data . mml ) . defaultView . document ;
Original file line number Diff line number Diff line change 1+ var tape = require ( 'tape' ) ;
2+ var mjAPI = require ( "../lib/main.js" ) ;
3+
4+ tape ( 'HTML output: add aria-label to correct childnode' , function ( t ) {
5+ t . plan ( 1 ) ;
6+ mjAPI . start ( ) ;
7+ var mml = '<math alttext="0"><mn>1</mn></math>' ;
8+
9+ mjAPI . typeset ( {
10+ math : mml ,
11+ format : "MathML" ,
12+ htmlNode : true ,
13+ html : true
14+ } , function ( data ) {
15+ t . equal ( data . htmlNode . parentNode . querySelectorAll ( '[aria-label]' ) . length , 1 , 'Aria-label is unique' ) ;
16+ } ) ;
17+ } ) ;
You can’t perform that action at this time.
0 commit comments