Why did you use <div> instead of <table> tag?
The fact is that I don't need the table; what I need is a row snippet that can remain in memory and be used multiple times as data is dynamically inserted into a table.
This is one of many parts that are maintained in memory and used multiple times in various parts of the application. It's certainly much cleaner than concatenating strings everywhere, and for me it's all about clean, secure code, with performance a close second.
Now on to the issue at hand, have you successfully replicated the issue? Can you explain it?
Without even running the page, I think the issue is that you have invalid HTML - putting <tr><td> inside <div> tag and not <table> tag.
Try this in the console:
paraphrasing off of your suggestion, here's what I have deduced:
...when doc is made into an object it is identified as an illegal object and the foul parts (tr and td) are dropped. Makes sense, because tr is wrapped by di in the 'doc' stream.Code:var doc = CreateDoc('Text/Test.txt'); $('div').eq(1).html('<xmp>' + $(doc).outerHTML + '</xmp>');
...the stream was never converted into an object, so it maintained state as simply a stream of characters.Code:var doc = CreateDoc('Text/Test.txt'); document.getElementsByTagName('div').innerHTML = '<xmp>' + doc + '</xmp>';
Therefore, it stands to reason that the problem occurs when tr is converted into an object.
However, $('<tr><td><span>Cool Stuff</span></td></tr>') also drops the tr and tds. Apparently they may not exist as independent objects, and have a dependency on table. THAT I did not expect! I expected the fragment to create a tr object, and to eventually append it to a tbody container. Yet that did not occur.
well, that's the sense that I am making of all this.
It also stands to reason, therefore, that even if my original tr were wrapped in a table object, as soon as I retrieved its innerHTML - i.e., the tr segment that I need - the object would drop the tr and td tags as well.
The result reveals that I should maintain it as a text stream and not convert it into an object until it's in tbody.
Do you concur?
Thx for that, it's coming back to me now. It's been a very looong time since college! in the context of my deductions this makes a great deal of sense.
Thx a bunch!
But doing this:Code:document.getElementsByTagName('div').innerHTML = '<xmp><tr><td>test</td></xmp>';
will drop the invalid tags and render:Code:document.getElementsByTagName('div').innerHTML = '<div><tr><td>test</td></div>';
I was demonstrating that in
...it is apparent the doc itself did not drop tr and td, and that is precisely the reason that, when wrapped in xmp, it rendered them.Code:'<xmp>' + $(doc).outerHTML + '</xmp>'
If doc had dropped tr and td then xmp-wrapped code would not have displayed tr and td.
This suggests that I can use this format to inject rows into tbody dynamically without losing tr and td, though I have yet to test it in the code.