This project is archived and is in readonly mode.

#1236 ✓invalid

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

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins