* Converts the math node into a MathML-namespaced DOM element.
()
| 80 | * Converts the math node into a MathML-namespaced DOM element. |
| 81 | */ |
| 82 | toNode(): Node { |
| 83 | const node = document.createElementNS( |
| 84 | "http://www.w3.org/1998/Math/MathML", this.type); |
| 85 | |
| 86 | for (const attr in this.attributes) { |
| 87 | if (Object.prototype.hasOwnProperty.call(this.attributes, attr)) { |
| 88 | node.setAttribute(attr, this.attributes[attr]); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | if (this.classes.length > 0) { |
| 93 | node.className = createClass(this.classes); |
| 94 | } |
| 95 | |
| 96 | for (let i = 0; i < this.children.length; i++) { |
| 97 | // Combine multiple TextNodes into one TextNode, to prevent |
| 98 | // screen readers from reading each as a separate word [#3995] |
| 99 | if (this.children[i] instanceof TextNode && |
| 100 | this.children[i + 1] instanceof TextNode) { |
| 101 | let text = this.children[i].toText() + this.children[++i].toText(); |
| 102 | while (this.children[i + 1] instanceof TextNode) { |
| 103 | text += this.children[++i].toText(); |
| 104 | } |
| 105 | node.appendChild(new TextNode(text).toNode()); |
| 106 | } else { |
| 107 | node.appendChild(this.children[i].toNode()); |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | return node; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Converts the math node into an HTML markup string. |
nothing calls this directly
no test coverage detected