Well... I'd say the reason it that it is IE. I don't think the programers had a specific intention to do it that way.
I'm guessing that the table tag is different between browsers.
e.g. which nodes does the default table auto-magically contain?
<table>
<thead>
</thead>
<tbody>
</tbody>
<tfoot>
</tfoot>
</table>
Why not just try walking the DOM and see what each browser thinks that the document contains?
IE does a lot of "optimization" of the DOM. To get an impression of what this might look like, "Select all", "Copy" in IE, and then "Paste Alternate" in Visual Studio, You get the following:
<INPUT value="Submit Query" type=submit>
<INPUT value=Reset type=reset>
<INPUT type=button>
<INPUT type=text>
<INPUT value="" type=password>
<INPUT type=file>
<INPUT type=hidden>
<INPUT type=checkbox>
<INPUT type=radio>
<BUTTON type=submit></BUTTON>
<SELECT></SELECT>
<TEXTAREA></TEXTAREA>
So it nukes some of the empty tags and adds some default attributes.
IE tries to be helpful and hides text nodes that contain only whitespace.
In the following:
<p>
<input>
</p>
W3C DOM spec says that <p>
has 3 child nodes ("\n", <input>
and "\n"), IE will pretend there's only one.
The solution is to skip text nodes in all browsers:
var node = element.firstChild;
while(node && node.nodeType == 3) node = node.nextSibling;
Popular JS frameworks have functions for such things.