stuff
This commit is contained in:
parent
bc92231240
commit
b8225c639e
11904 changed files with 1472749 additions and 133 deletions
33
node_modules/speech-rule-engine/mjs/walker/walker_util.js
generated
vendored
Normal file
33
node_modules/speech-rule-engine/mjs/walker/walker_util.js
generated
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import * as DomUtil from '../common/dom_util.js';
|
||||
import { Attribute } from '../enrich_mathml/enrich_attr.js';
|
||||
export function splitAttribute(attr) {
|
||||
return !attr ? [] : attr.split(/,/);
|
||||
}
|
||||
export function getAttribute(node, attr) {
|
||||
return node.getAttribute(attr);
|
||||
}
|
||||
export function getSemanticRoot(node) {
|
||||
if (node.hasAttribute(Attribute.TYPE) &&
|
||||
!node.hasAttribute(Attribute.PARENT)) {
|
||||
return node;
|
||||
}
|
||||
const semanticNodes = DomUtil.querySelectorAllByAttr(node, Attribute.TYPE);
|
||||
for (let i = 0, semanticNode; (semanticNode = semanticNodes[i]); i++) {
|
||||
if (!semanticNode.hasAttribute(Attribute.PARENT)) {
|
||||
return semanticNode;
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
export function getBySemanticId(root, id) {
|
||||
if (root.getAttribute(Attribute.ID) === id) {
|
||||
return root;
|
||||
}
|
||||
return DomUtil.querySelectorAllByAttrValue(root, Attribute.ID, id)[0];
|
||||
}
|
||||
export function getAllBySemanticId(root, id) {
|
||||
if (root.getAttribute(Attribute.ID) === id) {
|
||||
return [root];
|
||||
}
|
||||
return DomUtil.querySelectorAllByAttrValue(root, Attribute.ID, id);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue