We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 04b90de commit 35682aeCopy full SHA for 35682ae
1 file changed
src/manipulation.ts
@@ -49,7 +49,12 @@ export function replaceElement(
49
const { parent } = replacement;
50
if (parent) {
51
const childs = parent.children;
52
- childs[childs.lastIndexOf(element)] = replacement;
+ const childsIndex = childs.lastIndexOf(element);
53
+ if (childsIndex === -1) {
54
+ return;
55
+ }
56
+
57
+ childs[childsIndex] = replacement;
58
element.parent = null;
59
}
60
0 commit comments