W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2002

Re: HTMLTableElement.insertRow(-1) ambiguous

From: Philippe Le Hegaret <plh@w3.org>
Date: 18 Dec 2002 10:58:59 +0100
To: Brad Pettit <bradp@microsoft.com>
Cc: WWW DOM <www-dom@w3.org>, www-dom-ts@w3.org
Message-Id: <1040205539.408.38.camel@chacal>

On Tue, 2002-12-17 at 23:39, Brad Pettit wrote:
> The DOM TS is at odds with recent changes to the the HTML DOM.
> Specifically, I'm referring to HTMLTableElement::insertRow and how it behaves with a rowIndex of -1.
> The recent change to the spec was that rows are numbered in logical order (THEAD* TBODY+ TFOOT*) instead
> of document/DTD order (THEAD* TFOOT* TBODY+) to conform with existing implementations.
> insertRow(-1) is supposed to append a row to the table:
> 	"If index is -1 or equal to the number of rows, the new row is appended"
> 	<http://www.w3.org/TR/2002/PR-DOM-Level-2-HTML-20021108/html.html#ID-39872903>
> The test case at http://dev.w3.org/cvsweb/2001/DOM-Test-Suite/tests/level2/html/HTMLTableElement39.xml
> doesn't take this change into account.

David Faure already reported some problems of this kind in the test
suite. We really to fix those before the publication of test suite...

> >From the description of insertRow(-1) -- as well as the previous behavior -- I surmise that the intent was to append a row to the last TBODY, not to the TFOOT. However, because the rows in a table are numbered with TFOOT rows at the end, it's not clear to which section insertRow should append: The last existing section? The TFOOT? The TBODY?

Netscape/Mozilla will insert the new row in the last existing section.
IE/Win is somehow inconsistent:
Try the following: create the following table in memory by using only
createElement and appendChild (instead of using


If you do table.insertRow(0), you'll obtain:


Now, if you create this table:


and do table.insertRow(1), you'll obtain:


Note that tbody elements are created and that's not a defined behavior
in the spec. (insertRow only creates a tbody if the table is empty).
same thing for createThead/createTFoot, they create tbody as well.

> Our tests with Netscape 7 indicate that it doesn't support -1 as a parameter to insertRow.

I believe that Netscape is going to change this behavior.

> My questions: what is the correct behavior, and should the spec be updated?

Regarding the specification, it's too late for an update. If we do
something, it will be in an erratum now.

Received on Wednesday, 18 December 2002 04:59:15 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:10 UTC