close #356 improve loop checker
This commit is contained in:
@@ -861,6 +861,24 @@ export class Replayer {
|
|||||||
};
|
};
|
||||||
const queue: addedNodeMutation[] = [];
|
const queue: addedNodeMutation[] = [];
|
||||||
|
|
||||||
|
// next not present at this moment
|
||||||
|
function nextNotInDOM(mutation: addedNodeMutation) {
|
||||||
|
let next: Node | null = null;
|
||||||
|
if (mutation.nextId) {
|
||||||
|
next = mirror.getNode(mutation.nextId) as Node;
|
||||||
|
}
|
||||||
|
// next not present at this moment
|
||||||
|
if (
|
||||||
|
mutation.nextId !== null &&
|
||||||
|
mutation.nextId !== undefined &&
|
||||||
|
mutation.nextId !== -1 &&
|
||||||
|
!next
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const appendNode = (mutation: addedNodeMutation) => {
|
const appendNode = (mutation: addedNodeMutation) => {
|
||||||
if (!this.iframe.contentDocument) {
|
if (!this.iframe.contentDocument) {
|
||||||
return console.warn('Looks like your replayer has been destroyed.');
|
return console.warn('Looks like your replayer has been destroyed.');
|
||||||
@@ -889,14 +907,8 @@ export class Replayer {
|
|||||||
if (mutation.nextId) {
|
if (mutation.nextId) {
|
||||||
next = mirror.getNode(mutation.nextId) as Node;
|
next = mirror.getNode(mutation.nextId) as Node;
|
||||||
}
|
}
|
||||||
// next not present at this moment
|
if (nextNotInDOM(mutation)) {
|
||||||
if (
|
queue.push(mutation);
|
||||||
mutation.nextId !== null &&
|
|
||||||
mutation.nextId !== undefined &&
|
|
||||||
mutation.nextId !== -1 &&
|
|
||||||
!next
|
|
||||||
) {
|
|
||||||
return queue.push(mutation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const target = buildNodeWithSN(
|
const target = buildNodeWithSN(
|
||||||
@@ -942,7 +954,11 @@ export class Replayer {
|
|||||||
});
|
});
|
||||||
|
|
||||||
while (queue.length) {
|
while (queue.length) {
|
||||||
if (queue.every((m) => !Boolean(mirror.getNode(m.parentId)))) {
|
if (
|
||||||
|
queue.every(
|
||||||
|
(m) => !Boolean(mirror.getNode(m.parentId)) || nextNotInDOM(m),
|
||||||
|
)
|
||||||
|
) {
|
||||||
return queue.forEach((m) => this.warnNodeNotFound(d, m.node.id));
|
return queue.forEach((m) => this.warnNodeNotFound(d, m.node.id));
|
||||||
}
|
}
|
||||||
const mutation = queue.shift()!;
|
const mutation = queue.shift()!;
|
||||||
|
|||||||
Reference in New Issue
Block a user