Skip to content

Commit

Permalink
Update RHS terminalify to be more idiomatic (#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 authored Jun 18, 2023
1 parent 879aa24 commit 1802e24
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/RHS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,13 @@ export default class RHS extends Builder {

terminalify(parentNode: Element) {
// we store effects to perform later so the iteration doesn't get messed up
const surrogateTags = ['INS', 'DEL', 'MARK'];
const pairs: { parent: Element; child: Text }[] = [];
for (let i = 0; i < parentNode.childNodes.length; i++) {
const node = parentNode.childNodes[i];
for (const node of parentNode.childNodes) {
if (node.nodeType === 3) {
pairs.push({ parent: parentNode, child: node as Text });
} else if (
node.nodeType === 1 &&
(node.nodeName === 'INS' || node.nodeName === 'DEL' || node.nodeName === 'MARK')
) {
for (let i = 0; i < node.childNodes.length; i++) {
const child = node.childNodes[i];
} else if (surrogateTags.includes(node.nodeName)) {
for (const child of node.childNodes) {
if (child.nodeType === 3) {
pairs.push({ parent: node as Element, child: child as Text });
}
Expand Down

0 comments on commit 1802e24

Please sign in to comment.