Skip to content

Commit

Permalink
Don't use live NodeList
Browse files Browse the repository at this point in the history
  • Loading branch information
djmaze authored and neilj committed Feb 19, 2023
1 parent 27f19c4 commit cdb57eb
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions source/node/MergeSplit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,14 @@ const fixContainer = (
container: Node,
root: Element | DocumentFragment,
): Node => {
const children = container.childNodes;
let wrapper: HTMLElement | null = null;
for (let i = 0, l = children.length; i < l; i += 1) {
const child = children[i];
[...container.childNodes].forEach(child => {
const isBR = child.nodeName === 'BR';
if (!isBR && isInline(child)) {
if (!wrapper) {
wrapper = createElement('DIV');
}
wrapper.appendChild(child);
i -= 1;
l -= 1;
} else if (isBR || wrapper) {
if (!wrapper) {
wrapper = createElement('DIV');
Expand All @@ -80,15 +76,13 @@ const fixContainer = (
container.replaceChild(wrapper, child);
} else {
container.insertBefore(wrapper, child);
i += 1;
l += 1;
}
wrapper = null;
}
if (isContainer(child)) {
fixContainer(child, root);
}
}
});
if (wrapper) {
container.appendChild(fixCursor(wrapper));
}
Expand Down

0 comments on commit cdb57eb

Please sign in to comment.