If I call getParentElement() on a top-level object, I get an exception caused by a JavaScript exception. As in:
com.google.gwt.core.client.JavaScriptException: (TypeError): elem is null
fileName: http://localhost:8888
lineNumber: 307
stack: (null,"ID")@http://localhost:8888:307
connect("http://localhost:8888/sample/Sample.html?gwt.codesvr=10.27.5.51:9997","wn\\9&vcA9M(XB8}F","10.27.5.51:9997","sample","2.0")@:0
((void 0),"sample","http://localhost:8888/sample/")@http://localhost:8888/sample/hosted.html?sample:264
z()@http://localhost:8888/sample/getparentbug.nocache.js:2
(5)@http://localhost:8888/sample/getparentbug.nocache.js:8
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:195)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.smartgwt.client.util.JSOHelper.getAttribute(JSOHelper.java)
at com.smartgwt.client.widgets.BaseWidget.<init>(BaseWidget.java:112)
at com.smartgwt.client.widgets.Canvas.<init>(Canvas.java:78)
at com.smartgwt.client.widgets.Canvas.getParentElement(Canvas.java:6550)
at org.foobar.sample.GetParentBug.onModuleLoad(GetParentBug.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:369)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
at java.lang.Thread.run(Thread.java:619)
Reproducing this is simple. Just create a top-level object, have it 'draw()' itself, then call getParentElement() on it.
It seems like this should return null, as it is not exceptional for a top-level object to not have a parent.
com.google.gwt.core.client.JavaScriptException: (TypeError): elem is null
fileName: http://localhost:8888
lineNumber: 307
stack: (null,"ID")@http://localhost:8888:307
connect("http://localhost:8888/sample/Sample.html?gwt.codesvr=10.27.5.51:9997","wn\\9&vcA9M(XB8}F","10.27.5.51:9997","sample","2.0")@:0
((void 0),"sample","http://localhost:8888/sample/")@http://localhost:8888/sample/hosted.html?sample:264
z()@http://localhost:8888/sample/getparentbug.nocache.js:2
(5)@http://localhost:8888/sample/getparentbug.nocache.js:8
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:195)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.smartgwt.client.util.JSOHelper.getAttribute(JSOHelper.java)
at com.smartgwt.client.widgets.BaseWidget.<init>(BaseWidget.java:112)
at com.smartgwt.client.widgets.Canvas.<init>(Canvas.java:78)
at com.smartgwt.client.widgets.Canvas.getParentElement(Canvas.java:6550)
at org.foobar.sample.GetParentBug.onModuleLoad(GetParentBug.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:369)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:185)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:380)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
at java.lang.Thread.run(Thread.java:619)
Reproducing this is simple. Just create a top-level object, have it 'draw()' itself, then call getParentElement() on it.
It seems like this should return null, as it is not exceptional for a top-level object to not have a parent.
Comment