#487 bug
knell

Element.getStyle('height') is wrong for hidden elements in Opera

Reported by knell | December 11th, 2008 @ 04:20 PM | in 1.7

I use Prototype JS 1.6.0.3. Browsers' versions described below.

In Opera getStyle('height') and getHeight() return 0 for hidden elements.

Example code:


<script type="text/javascript">
function ontest()
{
    var bb = $('bb');
    var str = 'getHeight(): ' + bb.getHeight() 
        + '\ngetStyle(): ' 
        + bb.getStyle('height')
	+ '\ncurrentStyle: ' + bb.currentStyle.height;
    alert(str);
}
</script>
<style type="text/css">
#cc { display: none; }
#bb { height: 52px; }
</style>

<body>
<div id="cc"><div id="bb">Content</div></div>
<input type="button" value="Click" onclick="ontest()"/>
</body>

Opera 9.62:


  getHeight(): 0
  getStyle(): 0px
  currentStyle: 52px

FF 3.0.4: bb.currentStyle is undefined but shows height properly by getStyle('height')

IE 7.0.5730.13:


   getHeight(): 0
   getStyle(): 52px
   currentStyle: 52px

Safari 3.2.1: undefined value (I think it's about 'currentStyle') but shows height properly by getStyle('height')

So, in Opera unable to determine height of hidden element with PrototypeJS framework. Also. I think the same behavior and with width, or may be with other properties.

Comments and changes to this ticket

  • Serty Oan

    Serty Oan March 27th, 2009 @ 03:04 PM

    • Tag set to display, opera

    Problem is that the div#bb is hidden but its display is block and Opera seems not to set element.clientWidth when an element is in a parent that is hidden. You can take it from currentStyle in some browsers, but you ll get a % if the dimension is not set in pixel. Seems linked to the render engine more than to JavaScript imho.

  • Juriy Zaytsev

    Juriy Zaytsev March 28th, 2009 @ 08:19 PM

    • Tag changed from display, opera to needs_patch, needs_tests, opera
    • Milestone set to 1.7
    • State changed from “new” to “bug”
    • Title changed from “Element.getStyle() and getHeight() and Opera 9.62” to “Element.getStyle('height') is wrong for hidden elements in Opera”
    • Assigned user set to “Juriy Zaytsev”

    This should be fixed in a trunk, but the way "hidden" elements are detected is very naive. Marking as a bug. Will try to take care of it in final 1.6.1.

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 02:26 AM

    • Tag changed from needs_patch, needs_tests, opera to missing:tests, needs_patch, opera

    [not-tagged:"needs_tests" tagged:"missing:tests" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 02:28 AM

    • Tag changed from missing:tests, needs_patch, opera to missing:patch, missing:tests, opera

    [not-tagged:"needs_patch" tagged:"missing:patch" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 03:36 AM

    • Tag changed from missing:patch, missing:tests, opera to missing:patch, needs:tests, opera

    [not-tagged:"missing:tests" tagged:"needs:tests" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 03:37 AM

    • Tag changed from missing:patch, needs:tests, opera to needs:patch, needs:tests, opera

    [not-tagged:"missing:patch" tagged:"needs:patch" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 12:44 PM

    • Tag changed from needs:patch, needs:tests, opera to needs:patch, needs:tests

    [not-tagged:"opera" bulk edit command]

  • T.J. Crowder

    T.J. Crowder November 16th, 2009 @ 04:50 PM

    • Assigned user cleared.

    [responsible:none bulk edit command]

  • Tisho Georgiev

    Tisho Georgiev March 1st, 2010 @ 09:40 PM

    • Tag changed from needs:patch, needs:tests to needs:patch, needs:tests, section:dom

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

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.

Shared Ticket Bins

Pages