Skip to content

Commit

Permalink
#960@trivial: Fix introduced bug in ElementUtility.appendChild() and …
Browse files Browse the repository at this point in the history
…ElementUtility.insertBefore().
  • Loading branch information
capricorn86 committed Aug 22, 2023
1 parent 3b120c0 commit 0b31097
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/happy-dom/src/nodes/element/ElementUtility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ export default class ElementUtility {
if (attribute) {
parentNodeChildren._removeNamedItem(<IHTMLElement>node, attribute.value);
}
parentNodeChildren.splice(index, 1);
}

parentNodeChildren.splice(index, 1);
}
}
}
Expand Down Expand Up @@ -149,6 +150,8 @@ export default class ElementUtility {
parentNodeChildren._removeNamedItem(<IHTMLElement>newNode, attribute.value);
}
}

parentNodeChildren.splice(index, 1);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/happy-dom/test/nodes/element/Element.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ describe('Element', () => {
const div1 = document.createElement('div');
div1.classList.add('someClassName');
div1.innerHTML = 'div1';
container.after(div1);
container?.after(div1);
expect(document.body.children.length).toBe(2);

const div2 = document.createElement('div');
Expand Down

0 comments on commit 0b31097

Please sign in to comment.