File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -336,10 +336,20 @@ describe("accessibility", () => {
336336 expect ( mathML )
337337 . withContext ( `In ${ browserName } ` )
338338 . toEqual (
339- " <msqrt><msup><mi>x</mi><mn>2</mn></msup></msqrt> <mo>=</mo> <mrow><mo>|</mo><mi>x</mi><mo>|</mo></mrow> "
339+ ` <msqrt><msup><mi>x</mi><mn>2</mn></msup></msqrt> <mo>=</mo> <mrow intent="absolute-value($x)" ><mo>|</mo><mi arg="x" >x</mi><mo>|</mo></mrow> `
340340 ) ;
341+
342+ // Check that the math corresponding element is hidden in the text
343+ // layer.
344+ const ariaHidden = await page . $eval ( "span#p58R_mc13" , el =>
345+ el . getAttribute ( "aria-hidden" )
346+ ) ;
347+ expect ( ariaHidden ) . withContext ( `In ${ browserName } ` ) . toEqual ( "true" ) ;
341348 } else {
342- pending ( `Sanitizer API (in ${ browserName } ) is not supported` ) ;
349+ // eslint-disable-next-line no-console
350+ console . log (
351+ `Pending in Chrome: Sanitizer API (in ${ browserName } ) is not supported`
352+ ) ;
343353 }
344354 } )
345355 ) ;
@@ -379,7 +389,10 @@ describe("accessibility", () => {
379389 '<math display="block"> <msup> <mi>π</mi> <mi>π</mi> </msup> <mo lspace="0.278em" rspace="0.278em">=</mo> <mi>π</mi> <mspace width="1.000em"></mspace> <mi> mod </mi> <mspace width="0.167em"></mspace> <mspace width="0.167em"></mspace> <mi>π</mi> </math>'
380390 ) ;
381391 } else {
382- pending ( `Sanitizer API (in ${ browserName } ) is not supported` ) ;
392+ // eslint-disable-next-line no-console
393+ console . log (
394+ `Pending in Chrome: Sanitizer API (in ${ browserName } ) is not supported`
395+ ) ;
383396 }
384397 } )
385398 ) ;
Original file line number Diff line number Diff line change @@ -341,6 +341,18 @@ class StructTreeLayerBuilder {
341341 element . setHTML ( node . mathML , {
342342 sanitizer : MathMLSanitizer . sanitizer ,
343343 } ) ;
344+ // Hide all the corresponding content elements in the text layer in
345+ // order to avoid screen readers reading both the MathML and the
346+ // text content.
347+ for ( const { id } of node . children || [ ] ) {
348+ if ( ! id ) {
349+ continue ;
350+ }
351+ const elem = document . getElementById ( id ) ;
352+ if ( elem ) {
353+ elem . ariaHidden = true ;
354+ }
355+ }
344356 }
345357 if (
346358 ! node . mathML &&
You canβt perform that action at this time.
0 commit comments