Closed Bug 69674 Opened 24 years ago Closed 24 years ago

Unable to set attributes before calling appendChild

Categories

(Core :: DOM: CSS Object Model, defect)

x86
Windows NT
defect
Not set
normal

Tracking

()

VERIFIED DUPLICATE of bug 60683

People

(Reporter: christopher_brien, Assigned: jst)

Details

(Keywords: dom2)

Attachments

(1 file)

From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)
BuildID:    2001022020

When using document.createElement, it is not possible to set css attributes for 
a newly created element until it is appended with appendChild.

Reproducible: Always
Steps to Reproduce:
Create an html page with a script similar to the following:

function createImages(){
	//Create an image
	firstElement = document.createElement("img");
	firstElement.src = "http://mozilla.org/images/mozilla-banner.gif";
	//append it BEFORE setting attributes
	document.body.appendChild(firstElement);
	firstElement.style.position = "absolute";
	firstElement.style.left = 100;
	firstElement.style.top  = 200;


	//Create another image
	secondElement = document.createElement("img");
	secondElement.src = "http://mozilla.org/images/mozilla-banner.gif";
	secondElement.style.position = "absolute";
	secondElement.style.left = 100;
	secondElement.style.top  = 300;
	//append it AFTER setting attributes
	document.body.appendChild(secondElement);
}

Actual Results:  The first element is added and its position is set correctly.
The second element appears with none of its attributes (except src) set.

Expected Results:  Both images appear one above the other in the example

Works in IE
Keywords: dom2
Component: DOM Level 2 → DOM Style
Taking QA Contact on all open or unverified DOM Style bugs...
dup of bug 60683. Going to attach the testcase to that bug. Thanks for providing it!

*** This bug has been marked as a duplicate of 60683 ***
Status: UNCONFIRMED → RESOLVED
Closed: 24 years ago
Resolution: --- → DUPLICATE
verified duplicate.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: