dom manipulation works in IE but not in FF

15 views
Skip to first unread message

bhomass

unread,
Jun 24, 2009, 2:43:56 AM6/24/09
to Google Web Toolkit
I am doing an operation in which I remove a <form> but keep all its
children.

Element parent = (Element) currentForm.getParentElement();

NodeList<Node> formChildren = currentForm.getChildNodes(); //
for (int i = 0; i < formChildren.getLength(); i++) {
parent.insertBefore(formChildren.getItem(i), currentForm);
}
parent.removeChild(currentForm);

this code works in hosted browser. it works after compilation in IE,
but failes in FF.
FF removes the whole thing. there is nothing left after removing the
form.

how would one go about debugging something like this?

is this a known cross browser problem?

bhomass

unread,
Jul 3, 2009, 12:47:18 AM7/3/09
to Google Web Toolkit
this is one serious bug. no one knows anything about it?

I checked it out using gwt-log. in FF, even though
currentForm.getInnerHTML() returns the right element,
currentForm.getChildNodes() returns two non-existent #text.

is this a known problem?

waf

unread,
Jul 3, 2009, 8:12:18 AM7/3/09
to Google Web Toolkit
Hi,

I've checked this and it seems to work fine (as expected)
in web mode (IE7, Chrome, FF 3.0.11/3.5) but it breaks in
hosted mode on linux/firefox with the following exception

[ERROR] Uncaught exception escaped
com.google.gwt.core.client.JavaScriptException: (TypeError):
this.removeChild is not a function
fileName: jar:file:/home/wlodek/gwt/trunk/build/staging/gwt-
linux-0.0.0/gwt-user.jar!/com/google/gwt/dom/client/Node.java
lineNumber: 285
stack: ([object
HTMLFormElement])@jar:file:/home/wlodek/gwt/trunk/build/staging/gwt-
linux-0.0.0/gwt-user.jar!/com/google/gwt/dom/client/Node.java:285
static void com.google.gwt.user.client.DOM.dispatchEvent
(com.google.gwt.user.client.Event,com.google.gwt.user.client.Element,com.google.gwt.user.client.EventListener)
([object
Event],[object HTMLButtonElement],[object gwt_nativewrapper_class])@:0
([object Event])@jar:file:/home/wlodek/gwt/trunk/build/staging/gwt-
linux-0.0.0/gwt-user.jar!/com/google/gwt/user/client/impl/
DOMImplStandard.java:169
@:0

at com.google.gwt.dom.client.Node$.removeChild$(Native Method)
at pl.waf.test.client.Form.removeForm(Form.java:59)
at pl.waf.test.client.Form.access$0(Form.java:50)
at pl.waf.test.client.Form$1.onClick(Form.java:44)
at com.google.gwt.event.dom.client.ClickEvent.dispatch
(ClickEvent.java:54)
at com.google.gwt.event.dom.client.ClickEvent.dispatch
(ClickEvent.java:1)
at com.google.gwt.event.shared.HandlerManager
$HandlerRegistry.fireEvent(HandlerManager.java:65)
at com.google.gwt.event.shared.HandlerManager
$HandlerRegistry.access$1(HandlerManager.java:53)
at com.google.gwt.event.shared.HandlerManager.fireEvent
(HandlerManager.java:178)
at com.google.gwt.user.client.ui.Widget.fireEvent(Widget.java:
52)
at com.google.gwt.event.dom.client.DomEvent.fireNativeEvent
(DomEvent.java:116)
at com.google.gwt.user.client.ui.Widget.onBrowserEvent
(Widget.java:90)
at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:
1320)
at com.google.gwt.user.client.DOM.dispatchEventAndCatch
(DOM.java:1299)
at com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1262)

--
waf
Message has been deleted

bhomass

unread,
Jul 3, 2009, 1:24:48 PM7/3/09
to Google Web Toolkit
it fails for both of the form nodes in this doc. will you mind try it
out in FF like you did before? you get two #text nodes when you do
formelement.getChildNodes(), where the right answer is one table
element.

<TABLE border="0" cellpadding="0" cellspacing="0" height="100%"
width="100%">
<TBODY>
<TR>
<TD
align="left" cellpadding="0" cellspacing="0" valign="top" width="600">
<LINK
href="stylesheet.css" rel="stylesheet" />
<!--
SCRIPT language="javascript" src="checkjs.js"/-->
<BR/>
<table>
<tr>

<td>

<FORM id="TopSalesSearchForm">

<TABLE align="center" border="0" cellpadding="0" cellspacing="0"
width="98%">

<TBODY>

<TR>

<TD width="40">

<IMG height="35" src="images/searchprefix.gif" width="36" />

</TD>

<TD background="images/searchbg.gif" class="font3" width="100%">

sales

number:<INPUT class="unnamed1" name="searchName" /><INPUT
class="button" name="search" onclick="submitMe('search');return
false;" type="submit" value="Submit Query" />

</TD>

</TR>

</TBODY>

</TABLE>

</FORM>
</
td>
</tr>
<tr>

<td>

<FORM id="EditSalesForm">

<TABLE align="center" border="0" cellpadding="4" cellspacing="1"
class="t2" width="98%">

<TBODY>

<TR class="t3" height="27">

<TD width="30">

Seq Number 

</TD>

<TD align="middle" width="40">

Serial Number

</TD>

<TD align="middle" width="130">

Created On

</TD>

<TD align="middle" width="130">

Client

</TD>

<TD align="middle" width="200">

Created By

</TD>

<TD align="middle" width="50">

Spec

</TD>

<TD align="middle" width="50">

Total Units

</TD>

<TD align="middle" width="100">

Apparent Total

</TD>

<TD align="middle" width="100">

Grand Total

</TD>

</TR>

<TR class="t4" height="27">

<TD align="middle" width="30">

1

</TD>

<TD align="middle" width="40">

<A href="SaleItemView.do">NP98787</A>

</TD>

<TD align="middle" width="130">

Nicole Kidman

</TD>

<TD align="middle" width="130">

04-09-2008

</TD>

<TD width="200">

Good

</TD>

<TD align="middle" width="50">

65

</TD>

<TD align="right" width="50">

$89.00

</TD>

<TD align="right" width="100">

$4,800.00

</TD>

<TD align="right" width="100">

$9,000.00

</TD>

</TR>

<TR class="t1" height="27">

<TD align="middle" width="30">

2

</TD>

<TD align="middle" width="40">

<A href="SaleItemView.do">HY90s</A>

</TD>

<TD align="middle" width="130">

Woody Allen

</TD>

<TD align="middle" width="130">

3-23-2009

</TD>

<TD width="200">

Great

</TD>

<TD align="middle" width="50">

87

</TD>

<TD align="right" width="50">

$29.00

</TD>

<TD align="right" width="100">

$1,300.00

</TD>

<TD align="right" width="100">

$4,030.00

</TD>

</TR>

<TR class="t4" height="27">

<TD align="middle" width="30">

3

</TD>

<TD align="middle" width="40">

<A href="SaleItemView.do">LO98d</A>

</TD>

<TD align="middle" width="130">

Russell Crow

</TD>

<TD align="middle" width="130">

1-21-2004

</TD>

<TD width="200">

Nice

</TD>

<TD align="middle" width="50">

76

</TD>

<TD align="right" width="50">

$32.00

</TD>

<TD align="right" width="100">

$3,100.00

</TD>

<TD align="right" width="100">

$6,120.00

</TD>

</TR>

</TBODY>

</TABLE>

</FORM>
</
td>
</tr>
</table>
</TD>
</TR>
</TBODY>
</TABLE>

waf

unread,
Jul 3, 2009, 3:39:13 PM7/3/09
to Google Web Toolkit

For me it looks like you are not creating this form using GWT,
because if you did and because FormPanel is a SimplePanel you will
end up with a single panel/table inside Form without any text nodes.
That's the way it looks like in my example.
But if you are creating this form some other way I would say
it is normal that you will have extra text nodes,
because any whitespace will result in a text node.
As far as I know you shouldn't have those text nodes
if form/table opening and closing tags are written like this

<form ...><table ...>
...
</table></form>

--
waf

bhomass

unread,
Jul 7, 2009, 2:53:42 AM7/7/09
to Google Web Toolkit
having some text nodes aren't so bad. the thing is after reading two
text nodes, it does not see the table node at all. why should that be?

for supplementary information, this is GWT 1.5.3 and I am talking
about deployed mode.
Reply all
Reply to author
Forward
0 new messages