Bug 16659
Summary: | Acid3 expects HTMLTableElement.rows to include a <tr> element that is an immediate child of the <table> | ||
---|---|---|---|
Product: | WebKit | Reporter: | Eric Seidel (no email) <eric> |
Component: | DOM | Assignee: | Darin Adler <darin> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | bdakin, darin, ian |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | All | ||
OS: | All |
Eric Seidel (no email)
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
];
rows[6].parentNode.appendChild(rows[0]);
table.appendChild(rows[1]);
table.insertBefore(document.createElement('thead'), table.firstChild);
table.firstChild.appendChild(rows[2]);
rows[2].parentNode.appendChild(rows[3]);
rows[4].appendChild(rows[5].parentNode);
table.insertRow(0);
table.tFoot.appendChild(rows[6]);
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;
},
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Darin Adler
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.
Darin Adler
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.
Darin Adler
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.
David Kilzer (:ddkilzer)
(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.
Darin Adler
r29101