tags:

views:

39

answers:

1

I'm adding an element to a document with the following:

Element parent = getParentElement(); // Returns the right thing.
HTML html = new HTML();
html.setHTML( "<td>BLAH</td>" );
parent.appendChild( html.getElement() );

When I view the resulting document with FireBug though, the parent's child looks like this:

<div class="gwt-HTML"> BLAH </div>

I can use FireBug to add in the <td> elements manually, and all my formatting applies, etc. Does anyone know why the HTML element seems to be removing my <td> tags?

+1  A: 

It turns out that it's FireFox that's stripping it out. If I just use plain old javascript to create a div, or a tr, and set innerHTML to be <td>BLAH</td>, it still gets stripped. A couple of others have noticed this as well: http://www.jtanium.com/2009/10/28/firefox-gotcha-innerhtml-strips-td-tags/

If I use javascript to create a <table> tag, and add it to the DOM, I can then place the <td> in that. Of course, it helpfully creates a <tbody><tr> for me as well, so I'm not really getting back what I put in....

Curtis
If anyone's interested, I posted a writeup of my final solution, with code, over on my blog: http://blog.grgcomponents.com/2010/08/26/firefox-is-a-thief-and-not-to-be-trusted/
Curtis