Skip to content

postprocessing can "change" the skeleton node (if it's a link) #41

@pkra

Description

@pkra

I had filed Speech-Rule-Engine/speech-rule-engine#801 but it turns out it's sre2tree's fault.

The use case was \href{a}{b, c}.

While sre2tree handles the skeleton node not being the root here:

sre-to-tree/lib.js

Lines 124 to 125 in 48503b2

export const sre2tree = (node) => {
const skeletonNode = node.querySelector('[data-semantic-id]:not([data-semantic-parent])');

in this case it (re)moves the relevant attributes in

sre-to-tree/lib.js

Lines 100 to 111 in 48503b2

// rewrite (proper) links
// NOTE. Since MathJax does not support <a> in internal format, the SRE structure is placed inside the a. We assume it's on the first semantic child
const firstSemanticChild = child.querySelector('[data-semantic-speech]');
if (!firstSemanticChild) {
console.warn('Link without semantic child');
return;
}
// move all attributes
[...firstSemanticChild.attributes].forEach(attr => {
child.setAttribute(attr.name, attr.value);
firstSemanticChild.removeAttribute(attr.name);
})

(since the anchor is the parent of the skeleton node)

So when we get to

sre-to-tree/lib.js

Lines 136 to 143 in 48503b2

if (node !== skeletonNode) {
moveAttribute(skeletonNode, node, 'data-owns');
moveAttribute(skeletonNode, node, 'aria-label');
moveAttribute(skeletonNode, node, 'aria-braillelabel');
moveAttribute(skeletonNode, node, 'aria-level');
skeletonNode.removeAttribute('aria-hidden');
skeletonNode.setAttribute('role', 'presentation');
}

the skeleton node no longer has the attributes we're trying to move.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions