I use GWT, and I have to manipulate the DOM directly because of a buggy widget that does not center itself properly. I wrote the following code to clear children in the <body> element while viewing transit, because RootPanel.clear () does not completely clear the HTML:
while (root.hasChildNodes()) { root.removeChild(root.getFirstChild()); }
But it throws a NullPointerException. However, just changing getFirstChild() to getLastChild() works fine.
while (root.hasChildNodes()) { root.removeChild(root.getLastChild()); }
Any ideas why?
source share