This error typically occurs when the nextSibling property is being accessed on a null value. In the provided code snippet, the error is happening at the line currentNode = currentNode.nextSibling; where currentNode is expected to have a nextSibling property.
To fix this issue, you need to ensure that currentNode is not null before accessing its nextSibling property. One way to do this is by adding a null check before accessing the property.
Here's an example of how you can modify the code to handle the null check:
while (currentNode !== void 0 && currentNode !== this.endComment) {
children.push(currentNode);
currentNode = currentNode.nextSibling;
}
In this modified code, the currentNode !== null check has been replaced with currentNode !== void 0. This ensures that the loop continues as long as currentNode is not null or undefined.
By making this change, you should be able to avoid the "Cannot read properties of null (reading 'nextSibling')" error.
