Bug Tracker

Opened 13 years ago

Closed 12 years ago

Last modified 11 years ago

#6088 closed bug (fixed)

Height/Width sometimes returns document dimensions in Opera

Reported by: lavignep Owned by:
Priority: Milestone: 1.4.3
Component: dimensions Version: 1.4.2
Keywords: height width opera Cc:
Blocked by: Blocking:

Description

I seems that Opera (tested only on version 10) has a scrollTo function on some elements which defeats the ("scrollTo" in elem && elem.document) test in these methods.

Anyhow, any elements in any browsers could defeat this test.

Change History (8)

comment:1 Changed 13 years ago by matzes

I have also a problem with returning document dimension in Opera. When I disable the prototype-library it works fine on my website.

JS Bin - Testpage:
without prototype: http://jsbin.com/eheju
with prototype: http://jsbin.com/eheju/2

JavaScript:

jQuery(function() {
  var i = jQuery("#test");
  i.text(".width() of red box: " + i.width() + "px (css: 300px)");
});

HTML (with prototype):

<!DOCTYPE html>
<html>
<head>
  <script  class="jsbin" src="http://ajax.googleapis.com/ajax/libs/prototype/1/prototype.js"></script>
  <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 <script>     
   jQuery.noConflict();  
 </script>   
<meta charset=utf-8 />
<title>Bug Test</title>
<style>
  #test { width:300px; background:#c00; }
</style>
</head>
<body>
  <div id="test"></div>
</body>
</html>

comment:2 Changed 13 years ago by gbilotta

Same issue here. For some reason, the HTMLElement prototype seems to include all the window methods, so "does it walk and quack like a window?" becomes true even though the element is _not_ the window. The change was introduced in [6313] to make it work with non-main windows and documents, but it's a little too liberal.

A possible solution is to replace that line with:

  return ("scrollTo" in elem && elem.document && !elem.parentNode) ? // does it walk and quack like a window?

with the rationale that HTML elements have a parentNode while windows and documents don't.

comment:4 Changed 13 years ago by kof13

Thank you for the fix, its really a blocker.

comment:5 Changed 13 years ago by dmethvin

need: ReviewCommit

comment:6 in reply to:  3 Changed 13 years ago by sitkatech

Replying to gbilotta:

Posted the fix here: http://github.com/Oblomov/jquery/commit/f1fd7952743ce4a07a556f1f9a1ba175dd7bca5c

What's the status of this fix? Is it going to be committed to the central repository? We're having this problem and prefer not to be on a branch at this time. We've noticed this ticket was for milestone 1.4.2 but it never made it into the release. Any chance of getting this in to 1.4.3? Thanks...

comment:7 Changed 13 years ago by phildriscoll

See also http://dev.jquery.com/ticket/6575#comment:5 for a slightly different fix, and note that this problem occurs in two places in the jQuery source.

comment:8 Changed 12 years ago by john

Component: cssdimensions
Milestone: 1.4.21.4.3
Resolution: fixed
Status: newclosed
Version: 1.4.11.4.2
Note: See TracTickets for help on using tickets.