Closed Bug 187179 Opened 22 years ago Closed 22 years ago

offsetWidth and getComputedStyle give wrong values for div nested in div of lesser width

Categories

(Core :: DOM: Core & HTML, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: scottk, Assigned: jst)

Details

(Keywords: regression, testcase)

Attachments

(1 file)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3b) Gecko/20021230
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3b) Gecko/20021230

If div(x) is nested within div(y) that has width = 'z' and overflow:hidden, both
offsetWidth and getComputedStyle.getPropertyValue("width") for div(x) return the
value of 'z', which is usually not correct.

This appears to have broken between linux trunk builds 2002121221 and
2002121321.  1.3a works correctly as well.

Reproducible: Always

Steps to Reproduce:
1.Load the test case on a current build, and 1.3a
2.compare the values.
3.

Actual Results:  
wrong offsetWidth is computed.

Expected Results:  
should produce the correct offsetWidth
adding regression and testcase keywords
Keywords: regression, testcase
I get both values 979 with Gecko/20021212 under WinXP, it look as a correct
values. Maybe OS specific trouble?
caillon, you're doing getComputedStyle now, right?
Ruslan, 20021212 is the last build that does give me the correct values.  Could
you test this again on WinXP with a current build?
Got 750px, 750 on WinXP on Gecko/20021230. So OS --> ALL?
The computed width changed because the actual width of the <div> changed.  put 
a border on the div to see this (general good practice when reporting bugs in 
computed style is to check whether the computed style matches the style you're 
seeing...)  The <div> width changed because the old value was completely 
wrong.  See bug 180711 (the fix for that is what you're detecting).

This is not a bug.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → INVALID
OK, then I guess I coded around an 'incorrect' value that was exactly what I
needed!  So the question now is how using the DOM I can get what the 'old'
offsetWidth was? What I need is the 'width' of the inner div as if it were
rendered without being constrained by the outer cliping div.

Also wasn't offsetWidth added for IE compatibility?  If so, it is no longer
compatible, as IE 6 gives the 'incorrect' value.

I no bugzilla is not a help forum but it took me several days to find the now
non-functioning 'solution' way back when we were on Mozilla 0.8, and it has
worked great until now.
You can't do what you want using a div in Mozilla right now (you could using a 
table, which does not allow the content to overflow...)

See bug 65548 on the handling of overflow with offsetWidth
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: