Bug 13240 - World of Warcraft site fails because it expects an implicit <tbody> as the first child of a <table>
Summary: World of Warcraft site fails because it expects an implicit <tbody> as the fi...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Evangelism (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
URL: http://www.worldofwarcraft.com/info/b...
Keywords: NeedsReduction
Depends on:
Blocks:
 
Reported: 2007-03-30 22:52 PDT by Darin Adler
Modified: 2008-02-09 14:21 PST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Adler 2007-03-30 22:52:07 PDT
I ran into a problem on a World of Warcraft page:

    http://www.worldofwarcraft.com/info/basics/factions/hellfire/hellfire.xml

It turned out to be some code that assumes that a <table> gets a <tbody> automatically created. For this markup:

    <table><tr></tr></table>

IE creates a <tbody> element in the DOM. Firefox does not do this. The page doesn't work with Firefox either.

I'm not sure what we should do about this difference in behavior.
Comment 1 Darin Adler 2007-03-30 22:54:03 PDT
Same thing with just a plain empty table: <table></table>. IE supplies a <tbody>.
Comment 2 Darin Adler 2007-03-30 23:21:19 PDT
Further, if there's whitespace at the start of the table, the <tbody> replaces it instead of being added after it. So the <tbody> is the first child of the table. That's what the code on the website depends on. It gets the table and then calls childNodes[0].appendChild to add a row to the table. This relies on the table body being node 0. But the markup has whitespace, something like this:

    <table>
    <tr></tr>
    </table>

IE adds the <tbody> and seems to discard the whitespace! I'm not sure what we can do to be compatible with a site like this.
Comment 3 Darin Adler 2007-03-30 23:24:08 PDT
Strangely, there is code to create implicit tbody elements in the HTML parser that looks like dead code to me. For example, HTMLTableElement::addChild says "The creation of <tbody> elements relies on the 'childAllowed' check", which seems to imply that some types of children, perhaps <tr> elements for example, would return false from childAllowed and then trigger the code in HTMLParser::handleError. But there's no implementation of childAllowed that prevents such elements from getting added! So I think the HTML parser code is never reached.

But even if that code to create implicit tbody elements runs, it doesn't put the body *before* the whitespace; so it doesn't make the World of Warcraft site work.
Comment 4 Darin Adler 2007-03-30 23:27:18 PDT
Somehow, this site works in Firefox even though my reductions of the problem don't!
Comment 5 Alexey Proskuryakov 2007-03-30 23:39:39 PDT
Using Hixie's live DOM viewer <http://software.hixie.ch/utilities/js/live-dom-viewer/>, I see TBODY being created in WebKit - the behavior seems to fully match Firefox.
Comment 6 Darin Adler 2007-03-31 00:03:35 PDT
OK, I guess I was reading the code wrong. The <tbody> does get created, but the site's code expects it to be the first child of the <table>, but instead we have whitespace as the first child. Why does this work in Firefox?
Comment 7 Darin Adler 2007-03-31 00:08:57 PDT
Works fine if we spoof as Firefox. So that explains why they're not failing the same way we are.
Comment 8 Robert Blaut 2008-02-09 14:21:35 PST
(In reply to comment #7)
> Works fine if we spoof as Firefox. So that explains why they're not failing the
> same way we are.
> 

So it's Evangelism bug. I checked the site using r30090 and the site looks good for me. Not broken layout so it should be considered ad FIXED