problems with insertRow()/insertCell() on empty tbody/row

RESOLVED FIXED in M16

Status

()

P3
normal
RESOLVED FIXED
19 years ago
18 years ago

People

(Reporter: dbaron, Assigned: karnaze)

Tracking

({testcase})

Trunk
x86
Linux
testcase
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [TESTCASE])

Attachments

(2 attachments)

When insertRow() is called on an empty tbody, strange things happen.  If you do:

for (var i = 0 ; i < 6 ; i++ ) {
	var myrow = theTBODY.insertRow(i);
	/* then give myrow the text "I am row " + i + "." */
}

then you end up with the rows in the wrong order: 1, 2, 3, 4, 5, 0

The same thing happens for insertCell().

I think in both cases they should come out with 0...6 (or 1...6).  Note that the
problem still occurs i initially equals 1 or -1, but it is always the first cell
inserted that ends up at the end (i.e., "2,3,4,5,1" or "0,1,2,3,4,5,-1").

I will attach two testcases demonstrating the problem: one for insertRow() and
one for insertCell().  I'm not sure whether the indices should be 0 or 1-based.
The DOM1 spec is *VERY* vague about insertRow and insertCell.  However, this bug
occurs either way.

Observed on Linux:
 - debug build from source pull, 1999-07-01 (?)
 - opt build from mozilla.org, 1999-06-30-08-M8
Whiteboard: [TESTCASE]
Note that although empty tr or tbody elements are invalid HTML (I think), I
still think this ought to work.
Created attachment 703 [details]
insertRow() test case
Created attachment 704 [details]
insertCell() test case
(Assignee)

Updated

19 years ago
Status: NEW → ASSIGNED
Target Milestone: M10

Comment 4

19 years ago
Spoke to karnaze during bug triage today.  Moving to M11.  Not an M10 blocker.
*** Bug 15686 has been marked as a duplicate of this bug. ***
The attachment in bug 15686 may show there are even problems when the row is not
initially empty, depending on what the index parameter of insertCell() means.
(Assignee)

Comment 7

19 years ago
Moving to M13.
(Assignee)

Updated

19 years ago
Target Milestone: M13 → M14
(Assignee)

Comment 8

19 years ago
mass move to m14.
Bulk moving [testcase] code to new testcase keyword. Sorry for the spam!
Keywords: testcase
(Assignee)

Comment 10

19 years ago
Moving to M16.
Target Milestone: M14 → M16

Comment 11

19 years ago
I believe 25306 is a duplicate of this one.

Use this script to create a new table:
----------------------------------------
function fnTable()
{
	var newTable = document.createElement("table");
	newTable.setAttribute("border","1");
	for(row=0;row<12;row++)
	{
		var newRow = newTable.insertRow(row);
		for(col=0;col<8;col++)
		{
			var newCell = newRow.insertCell(col);			
		// new cell
			var newValue = "";					
					// fill cell
			var newValue2 = document.createTextNode("r" + row + "c" 
+ col);
			newCell.appendChild(newValue2);
		}
	}
	document.body.appendChild(newTable);
}
---------------------------------------------
The rows show up OK using a Feb20 build on NT4/sp6. The column problem is still 
there: while row "0" is first, column "0" is last. I believe the "row" 
behaviour is the correct one, since the indices are 0-based.
(Assignee)

Comment 12

19 years ago
*** Bug 25306 has been marked as a duplicate of this bug. ***
(Assignee)

Comment 13

19 years ago
Fixed.
Status: ASSIGNED → RESOLVED
Last Resolved: 19 years ago
Resolution: --- → FIXED

Updated

18 years ago
QA Contact: chrisd → amar

Comment 14

18 years ago
QA contact update
You need to log in before you can comment on or make changes to this bug.