Skip to content

Commit

Permalink
capricorn86#558@patch: Additional TreeWalker checks for parentNode.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmilton committed Aug 7, 2022
1 parent f7c8a89 commit a67971a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/happy-dom/src/tree-walker/TreeWalker.ts
Expand Up @@ -125,7 +125,7 @@ export default class TreeWalker {
* @returns Current node.
*/
public previousSibling(): INode {
if (this.currentNode !== this.root && this.currentNode) {
if (this.currentNode !== this.root && this.currentNode && this.currentNode.parentNode) {
const siblings = this.currentNode.parentNode.childNodes;
const index = siblings.indexOf(this.currentNode);

Expand All @@ -149,7 +149,7 @@ export default class TreeWalker {
* @returns Current node.
*/
public nextSibling(): INode {
if (this.currentNode !== this.root && this.currentNode) {
if (this.currentNode !== this.root && this.currentNode && this.currentNode.parentNode) {
const siblings = this.currentNode.parentNode.childNodes;
const index = siblings.indexOf(this.currentNode);

Expand Down

0 comments on commit a67971a

Please sign in to comment.