Element.getWidth() using clientWidth/offsetWidth inconsistently, returning inconsistent results
Reported by Julian Stahnke | June 20th, 2008 @ 06:16 PM | in 1.6.0.3
The Element.getWidth() method returns this when the element is visible:
return {width: element.offsetWidth, height: element.offsetHeight};
But uses clientWidth/clientHeight when the element is invisible and the method does its show/hide stuff:
var originalWidth = element.clientWidth;
var originalHeight = element.clientHeight;
This yields inconsistent results when the element has borders. (clientWidth doesn’t seem to include the border-width—at least in Firefox 3 and Safari 3.1).
A fix would be to always use offsetWidth.
Comments and changes to this ticket
-
Juriy Zaytsev June 20th, 2008 @ 08:15 PM
- → Milestone changed from to 1.6.0.3
- → State changed from new to bug
-
John-David Dalton June 20th, 2008 @ 10:41 PM
- → State changed from bug to duplicate
This is tied into the already patched ticket ->
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
The Prototype JavaScript library.
