Bug 16659 - Acid3 expects HTMLTableElement.rows to include a <tr> element that is an immediate child of the <table>
Summary: Acid3 expects HTMLTableElement.rows to include a <tr> element that is an imme...
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Darin Adler
Depends on:
Reported: 2007-12-28 22:19 PST by Eric Seidel (no email)
Modified: 2008-01-02 17:26 PST (History)
3 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2007-12-28 22:19:32 PST
Acid3 expects table.appendChild(document.createElement('tr')) to increment row count

I had expected this to work as well... but maybe I'm missing something.  I was debugging this in Drosera and checking "table.rows.length" after each statement.  "table.appendChild(rows[1]);" seemed to fail to cause the row count to increment, which is likely why table.rows.length == 5 instead of 6, and thus the test failed.

    function () {
      // test 66: test the ordering and creation of rows
      var table = document.createElement('table');
      var rows = [
        document.createElement('tr'),    // 0: ends up first child of the tfoot
        document.createElement('tr'),    // 1: goes at the end of the table
        document.createElement('tr'),    // 2: becomes second child of thead
        document.createElement('tr'),    // 3: becomes third child of the thead
        document.createElement('tr'),    // 4: not in the table
        table.insertRow(0),              // 5: not in the table
        table.createTFoot().insertRow(0) // 6: ends up second in the tfoot
      table.insertBefore(document.createElement('thead'), table.firstChild);
      if (table.rows.length == 6 &&
          table.getElementsByTagName('tr').length == 6 &&
          table.childNodes.length == 3 &&
          table.childNodes[0] == table.tHead &&
          table.getElementsByTagName('tr')[0] == table.tHead.childNodes[0] &&
          table.getElementsByTagName('tr')[1] == table.tHead.childNodes[1] &&
          table.getElementsByTagName('tr')[1] == rows[2] &&
          table.getElementsByTagName('tr')[2] == table.tHead.childNodes[2] &&
          table.getElementsByTagName('tr')[2] == rows[3] &&
          table.childNodes[1] == table.tFoot &&
          table.getElementsByTagName('tr')[3] == table.tFoot.childNodes[0] &&
          table.getElementsByTagName('tr')[3] == rows[0] &&
          table.getElementsByTagName('tr')[4] == table.tFoot.childNodes[1] &&
          table.getElementsByTagName('tr')[4] == rows[6] &&
          table.getElementsByTagName('tr')[5] == table.childNodes[2] &&
          table.getElementsByTagName('tr')[5] == rows[1] &&
          table.tBodies.length == 0)
        return 5;
Comment 1 Darin Adler 2007-12-31 17:14:03 PST
I just worked on a bug where I encountered this. The changeset was <http://trac.webkit.org/projects/webkit/changeset/28327>.

Rows that are not inside any table section are intentionally not included in the rows collection to match IE. The only rows that show up in that collection are rows that are inside a table section that in turn is inside the table. There's definitely web content that relies on this.

On the other hand, rows outside table sections do show up visually and render as table rows.

Does HTML 5 ask for different behavior? If so, then we might need to fix HTML 5.

Someone needs to talk this one over with Hixie.
Comment 2 Darin Adler 2007-12-31 17:15:22 PST
For what it's worth, the definition of what does and does not appear in HTMLTableElement.rows in WebKit is in HTMLCollection.cpp -- look at the "case TableRows" parts of the code.
Comment 3 Darin Adler 2008-01-01 21:58:54 PST
I've got a fix for this. Hixie talked me into doing this in a way that's different from other browsers, but that matches HTML 5.
Comment 4 David Kilzer (:ddkilzer) 2008-01-02 07:40:57 PST
(In reply to comment #3)
> I've got a fix for this. Hixie talked me into doing this in a way that's
> different from other browsers, but that matches HTML 5.

See Bug 16657.

Comment 5 Darin Adler 2008-01-02 17:26:24 PST