Skip to content

Commit 1281331

Browse files
committed
Review suggestions and fixes SRE function name.
1 parent 799ad89 commit 1281331

File tree

4 files changed

+15
-29
lines changed

4 files changed

+15
-29
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,6 @@
141141
"mathjax-modern-font": "^4.0.0-beta.4",
142142
"mhchemparser": "^4.2.1",
143143
"mj-context-menu": "^0.9.1",
144-
"speech-rule-engine": "^4.1.0-beta.7"
144+
"speech-rule-engine": "^4.1.0-beta.8"
145145
}
146146
}

ts/a11y/explorer/KeyExplorer.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,13 @@ export class SpeechExplorer extends AbstractExplorer<string> implements KeyExplo
309309
return parent && this.highlighter.isMactionNode(parent) ? parent : null;
310310
}
311311

312+
/**
313+
* Computes the nesting depth announcement for the currently focused sub
314+
* expression.
315+
*
316+
* @param {HTMLElement} node The current node.
317+
* @return {HTMLElement} The refocused node.
318+
*/
312319
public depth(node: HTMLElement): HTMLElement {
313320
this.generators.depth(node, !!this.actionable(node));
314321
this.refocus(node);

ts/a11y/semantic-enrich.ts

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

ts/a11y/speech/GeneratorPool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ export class GeneratorPool<N, T, D> {
394394
this.CleanUp(node);
395395
return this.lastSpeech;
396396
}
397-
let postfix = this.summaryGenerator.getExpandable(
397+
let postfix = this.summaryGenerator.getActionable(
398398
actionable ?
399399
(this.adaptor.childNodes(node).length === 0 ? -1 : 1)
400400
: 0);

0 commit comments

Comments
 (0)