mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
Don't use live NodeList
This commit is contained in:
parent
27f19c4782
commit
cdb57ebda0
1 changed files with 2 additions and 8 deletions
|
@ -59,18 +59,14 @@ const fixContainer = (
|
||||||
container: Node,
|
container: Node,
|
||||||
root: Element | DocumentFragment,
|
root: Element | DocumentFragment,
|
||||||
): Node => {
|
): Node => {
|
||||||
const children = container.childNodes;
|
|
||||||
let wrapper: HTMLElement | null = null;
|
let wrapper: HTMLElement | null = null;
|
||||||
for (let i = 0, l = children.length; i < l; i += 1) {
|
[...container.childNodes].forEach(child => {
|
||||||
const child = children[i];
|
|
||||||
const isBR = child.nodeName === 'BR';
|
const isBR = child.nodeName === 'BR';
|
||||||
if (!isBR && isInline(child)) {
|
if (!isBR && isInline(child)) {
|
||||||
if (!wrapper) {
|
if (!wrapper) {
|
||||||
wrapper = createElement('DIV');
|
wrapper = createElement('DIV');
|
||||||
}
|
}
|
||||||
wrapper.appendChild(child);
|
wrapper.appendChild(child);
|
||||||
i -= 1;
|
|
||||||
l -= 1;
|
|
||||||
} else if (isBR || wrapper) {
|
} else if (isBR || wrapper) {
|
||||||
if (!wrapper) {
|
if (!wrapper) {
|
||||||
wrapper = createElement('DIV');
|
wrapper = createElement('DIV');
|
||||||
|
@ -80,15 +76,13 @@ const fixContainer = (
|
||||||
container.replaceChild(wrapper, child);
|
container.replaceChild(wrapper, child);
|
||||||
} else {
|
} else {
|
||||||
container.insertBefore(wrapper, child);
|
container.insertBefore(wrapper, child);
|
||||||
i += 1;
|
|
||||||
l += 1;
|
|
||||||
}
|
}
|
||||||
wrapper = null;
|
wrapper = null;
|
||||||
}
|
}
|
||||||
if (isContainer(child)) {
|
if (isContainer(child)) {
|
||||||
fixContainer(child, root);
|
fixContainer(child, root);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
if (wrapper) {
|
if (wrapper) {
|
||||||
container.appendChild(fixCursor(wrapper));
|
container.appendChild(fixCursor(wrapper));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue