Closed Bug 49942 Opened 24 years ago Closed 23 years ago

getComputedStyle for a positioned child returns value relative to the body and not the parent element

Categories

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

defect

Tracking

()

VERIFIED FIXED
Future

People

(Reporter: martin.honnen, Assigned: harishd)

References

Details

(Keywords: dom2)

Attachments

(1 file)

Consider the following inner DIV in an outer DIV both positioned absolutely

<HTML>
<HEAD>
<STYLE>
#outer {
  position: absolute;
  left: 20px; top: 20px;
  width: 200px; height: 200px;
  background-color: blue;
}
#inner {
  position: absolute;
  left: 50px; top: 50px;
  width: 100px; height: 100px;
  background-color: red;
}
</STYLE>
<SCRIPT>

</SCRIPT>
</HEAD>
<BODY ONLOAD="var l = document.getElementById('inner');
              var s = document.defaultView.getComputedStyle(l, null);
              alert('inner.left: (should be 50px) ' + s.getPropertyValue('left')
+ '\ninner.top: (should be 50px) ' + s.getPropertyValue('top'));"
>
<DIV ID="outer">
<DIV ID="inner">
</DIV>
</DIV>
</BODY>
</HTML>

The alert shows 70px instead of 50px so it seems to take the values relative to
the document body and not relative to outer DIV.
Though the DOM and CSS specs are not too explicit on this I think it is a bug.
jst confirmed that.
*** Bug 50050 has been marked as a duplicate of this bug. ***
This bug has been marked "future" because the original netscape engineer
workingon this is over-burdened. If you feel this is an error, that you or
another known resource will be working on this bug,or if it blocks your work in
some way -- please attach your concern to the bug for reconsideration.
Status: NEW → ASSIGNED
OS: Windows 95 → All
Hardware: PC → All
Target Milestone: --- → Future
reassigning to harishd
Assignee: jst → harishd
Status: ASSIGNED → NEW
Keywords: dom2
Component: DOM Level 2 → DOM Style
Taking QA Contact on all open or unverified DOM Style bugs...
QA Contact: vidur → ian
I've checked in the fix. Marking FIXED.
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
verified per testcase
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: