This project is archived and is in readonly mode.

getComputedSize and getStyle returns wrong value for elements with percentage % width or height in IE
Reported by Xandros | June 1st, 2011 @ 03:06 PM | in 2.0 (closed)
When using getComputedSize on an element (for example iframe) which has its width and height set to a percentage value (say 100%), he result may be inconsistent for IE.
Tested with Chrome 11 / FF4 / IE8
Chrome and FF4 return totalWidth correctly and IE however returns 100.
Diving into the code gives
style = this.getStyle(plane); // IE returns "100%" here while others return "900px" for example
then two lines lower style.toInt() sets the result to "100" for IE which is obviously wrong.
Suggested fix :
var capitalized = plane.capitalize(),
style = this.getStyle(plane);
getDims = style == 'auto' || style.test(/%$/);
if (getDims && !dimensions) dimensions = this.getDimensions();
style = styles[plane] = (getDims) ? dimensions[plane] : style.toInt();
Comments and changes to this ticket
-
fakedarren July 16th, 2011 @ 05:25 PM
- State changed from new to open
Would you be able to provide a JSfiddle showing this behaviour?
Regards
Darren -
Andrea Dessì July 18th, 2011 @ 09:56 AM
Is this problem related with this ticked?
"Element.getComputedSize not working with IE and relative dimensions": https://mootools.lighthouseapp.com/projects/24057/tickets/537-eleme...
and a JSFiddle test is here: http://jsfiddle.net/NKjoep/VvrAs/
-
Christoph Pojer August 19th, 2011 @ 12:14 AM
- Milestone set to 2.0
- Milestone order changed from 928 to 0
-
ibolmo January 19th, 2012 @ 10:12 AM
- State changed from open to invalid
Moved to Github Issues: https://github.com/mootools/mootools-core/issues/2160#issuecomment-...
Please use Github Issues, since Lighthouse has been deprecated.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »