[Webkit-unassigned] [Bug 8087] New: REGRESSION: Image width & height not valid on generated elements
bugzilla-daemon at opendarwin.org
bugzilla-daemon at opendarwin.org
Thu Mar 30 11:05:29 PST 2006
http://bugzilla.opendarwin.org/show_bug.cgi?id=8087
Summary: REGRESSION: Image width & height not valid on generated
elements
Product: WebKit
Version: 417.x
Platform: Macintosh
OS/Version: Mac OS X 10.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: JavaScript
AssignedTo: webkit-unassigned at opendarwin.org
ReportedBy: nmeersschaert at mac.com
If an image is generated in the DOM, either manually or thru an XMLHttpRequest, querying that image for it's height & width no longer works (it did earlier).
Here's a test case:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Image bug</title> <script type="text/javascript">
function test() {
var srcImage = document.createElement("img"); srcImage.setAttribute("src","http://images.apple.com/macosx/images/indextop20060109.jpg");
//Source image is 670x275
var image = new Image();
image.src=srcImage.getAttribute("src");
image.onload=testImage(image);
}
function testImage(image) {
//The image object should return a width of 670 since the image has been loaded
alert("Image " + image.src+" width:"+image.width);
//It actually returns 0
}
</script>
</head>
<body onload="test();">
</body>
</html>
The alert box returns width: 0.
The alert box should have returned width: 670.
If the image is loaded already such as:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Image bug</title> <script type="text/javascript">
function test() {
var srcImage = document.createElement("img"); srcImage.setAttribute("src","http://images.apple.com/macosx/images/indextop20060109.jpg");
//Source image is 670x275
var image = new Image();
image.src=srcImage.getAttribute("src");
image.onload=testImage(image);
}
function testImage(image) {
//The image object should return a width of 670 since the image has been loaded
alert("Image " + image.src+" width:"+image.width);
//It actually returns 0
}
</script>
</head>
<body onload="test();">
<img id="testSubject" src="http://images.apple.com/macosx/images/indextop20060109.jpg" alt="OS X" />
</body>
</html>
The alert box returns width: 670.
Since the script is explicitedly displaying the alert only after the onload of the image, it should display properly.
--
Configure bugmail: http://bugzilla.opendarwin.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
More information about the webkit-unassigned
mailing list