I'm using GWT and I have to manipulate the DOM directly because of a buggy widget that doesn't center itself properly. I wrote the following code to clean up the children on the <body>
element during view transistions because RootPanel.clear() doesn't clean up HTML completely:
while (root.hasChildNodes()) {
root.removeChild(root.getFirstChild());
}
But it throws a NullPointerException. However, simply changing getFirstChild()
to getLastChild()
works perfectly.
while (root.hasChildNodes()) {
root.removeChild(root.getLastChild());
}
Any ideas why?