@@ -250,8 +250,8 @@ export function EnrichedMathItemMixin<N, T, D, B extends Constructor<AbstractMat
250250 }
251251 let [ speech , braille ] = this . existingSpeech ( ) ;
252252 let [ newSpeech , newBraille ] = [ '' , '' ] ;
253- if ( ! speech || ! braille ||
254- document . options . enableSpeech || document . options . enableBraille ) {
253+ if ( ( ! speech && document . options . enableSpeech ) ||
254+ ( ! braille && document . options . enableBraille ) ) {
255255 try {
256256 [ newSpeech , newBraille ] = this . generatorPool . computeSpeech (
257257 this . typesetRoot , this . toMathML ( this . root , this ) ) ;
@@ -282,29 +282,6 @@ export function EnrichedMathItemMixin<N, T, D, B extends Constructor<AbstractMat
282282 this . state ( STATE . ATTACHSPEECH ) ;
283283 }
284284
285- /**
286- * Retrieves the actual speech element that should be used as aria label.
287- * @param {MmlNode } node The root node to search from.
288- * @return {string } The speech content.
289- */
290- protected getSpeech ( node : MmlNode ) : string {
291- const attributes = node . attributes ;
292- if ( ! attributes ) return '' ;
293- const speech = attributes . getExplicit ( 'data-semantic-speech' ) as string ;
294- // TODO (explorer) For tree role move all speech etc. to container
295- // element.
296- if ( ! attributes . hasExplicit ( 'data-semantic-parent' ) && speech ) {
297- return speech ;
298- }
299- for ( let child of node . childNodes ) {
300- let value = this . getSpeech ( child ) ;
301- if ( value ) {
302- return value ;
303- }
304- }
305- return '' ;
306- }
307-
308285 } ;
309286
310287}
@@ -414,8 +391,10 @@ export function EnrichedMathDocumentMixin<N, T, D, B extends MathDocumentConstru
414391 */
415392 public attachSpeech ( ) {
416393 if ( ! this . processed . isSet ( 'attach-speech' ) ) {
417- for ( const math of this . math ) {
418- ( math as EnrichedMathItem < N , T , D > ) . attachSpeech ( this ) ;
394+ if ( this . options . enableSpeech || this . options . enableBraille ) {
395+ for ( const math of this . math ) {
396+ ( math as EnrichedMathItem < N , T , D > ) . attachSpeech ( this ) ;
397+ }
419398 }
420399 this . processed . set ( 'attach-speech' ) ;
421400 }
0 commit comments