badrinarayanan / closure-library

Automatically exported from code.google.com/p/closure-library
0 stars 0 forks source link

goog.dom.htmlToDocumentFragment doesn't render table elements properly #210

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Open Firefox (3.6.10) or Chrome (7.0.517.8 dev) both in Linux
2. Create a page that has goog.dom loaded
3. Open a REPL and type 
goog.dom.htmlToDocumentFragment("<tr><td>one</td><td>two</td></tr>")

What is the expected output? What do you see instead?
> goog.dom.htmlToDocumentFragment("<tr><td>one</td><td>two</td></tr>")
"onetwo"

If the same procedure is repeated with different strings i.e. 
"<strong>text</strong>" or "<div>test</div>" you get a response that has the 
html elements highlighted (I think) indicating they are DOM objects.

Original issue reported on code.google.com by ache...@gmail.com on 20 Sep 2010 at 9:19

GoogleCodeExporter commented 8 years ago
I think this is because a <TR> can't live inside a <DIV>, but 
htmlToDocumentFragment() puts everything in a temp div, so the fragment winds 
up being invalid and it strips out the <TR> and <TD>.

It'd be nice if the documentation at least said something along the lines of 
"this function won't work if you pass it html that can't directly be in a div". 
 Or something.

Original comment by ty...@google.com on 20 Jul 2011 at 12:24

GoogleCodeExporter commented 8 years ago
Browser behaving as expected here. Should be surrounded by <table>.  You could 
possibly wrap in <table> tags and pull out the td elements as a separate step.

Original comment by nn...@google.com on 27 Apr 2012 at 9:30

GoogleCodeExporter commented 8 years ago
Actually tyang is correct. We should add documentation. A real DocumentFragment 
can contains td. It's just the way we're creating the DocumentFragment (with a 
'div' parent) that causes this to not work.

Original comment by chrishe...@google.com on 27 Apr 2012 at 9:35

GoogleCodeExporter commented 8 years ago
If this isn't something that won't be fixed how can you handle the situation 
where you are constructing a table in sections?

For example if I want to render a table by rendering the thead and then create 
a control for every row in the table, how can that be done if you can't render 
a fragment <tr><td>test</td><td>fragment</td></tr>?

Original comment by and...@gospotcheck.com on 19 Oct 2012 at 5:22