RESOLVED INVALID 16160
rowIndex on DOMHTMLTableRowElement always returns -1
https://bugs.webkit.org/show_bug.cgi?id=16160
Summary rowIndex on DOMHTMLTableRowElement always returns -1
Jing Chen
Reported 2007-11-27 10:53:05 PST
When you create a table element with several <tr> elements (rows) as children, calling [DOMHTMLTableRowElement rowIndex] on the rows returns -1 every time, regardless of where they are in the table. DOMHTMLTableCellElement has a similar method, cellIndex, but that method works correctly.
Attachments
Test program (98.10 KB, application/octet-stream)
2007-11-27 11:04 PST, Jing Chen
no flags
fixed version of test (73.11 KB, application/zip)
2007-11-27 11:15 PST, Darin Adler
no flags
Jing Chen
Comment 1 2007-11-27 11:04:32 PST
Created attachment 17557 [details] Test program Build and run the application. Click "Add Table", then click the "Check" button with the selection inside any row in the table.
Darin Adler
Comment 2 2007-11-27 11:10:59 PST
The reason rowIndex is returning -1 here is that the table row element is an immediate child of the table element. Instead there needs to be a table body element in the table, and the rows need to be in the table body element. I'll have to check with other browsers to see how they behave; this may be a "behaves correctly" situation, though.
Sam Weinig
Comment 3 2007-11-27 11:11:47 PST
Does this work in JS?
Darin Adler
Comment 4 2007-11-27 11:15:07 PST
Created attachment 17558 [details] fixed version of test
Darin Adler
Comment 5 2007-11-27 11:15:44 PST
The behavior of rowIndex matches the behavior in other browsers, so we won't be changing it. However, it's easy to construct a properly formed table instead, and then it will work fine.
Darin Adler
Comment 6 2007-11-27 11:17:02 PST
(In reply to comment #3) > Does this work in JS? Behavior is the same in JavaScript. However, if the table is built with HTML markup, then the problem never arises, because the HTML parser automatically adds a <tbody> element. You can get the problem if you construct the table with the DOM or with the XML parser. I tested with other browsers and our behavior matches them.
Jing Chen
Comment 7 2007-11-27 14:56:42 PST
Thanks for the clarification! That should fix it for me.
Note You need to log in before you can comment on or make changes to this bug.