Bug Tracker

Modify

Ticket #5336 (closed bug: invalid)

Opened 4 years ago

Last modified 4 years ago

getComputedStyle() return value not checked when jQuery.fn.offset gets defined.

Reported by: NavahoGL Owned by: brandon
Priority: major Milestone: 1.4
Component: offset Version: 1.3.2
Keywords: Cc:
Blocking: Blocked by:

Description

(I hope my description is clear enough.)

While messing around with Konqueror and Jquery 1.3.2 I discovered the following "bug".

The moment that jQuery.fn.offset is getting defined -- the following call is being made to defaultView.getComputedStyle():

4194: while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {

4195: computedStyle = defaultView.getComputedStyle(elem, null);

The getComputedStyle() call returns NULL in my case, and the script is not executed further.

The following seems a very obvious fix, although I am not sure this does not break things elsewhere.

4195: if(!(computedStyle = defaultView.getComputedStyle(elem, null)))

4196: continue;

Change History

comment:1 Changed 4 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

Is your element visible? The most common reason for getComputedStyle returning null is that the element is hidden. As the docs say, you can only get the offset of a visible element.

 http://docs.jquery.com/CSS/offset

If your element is visible, please reopen this ticket with a test case that reproduces the problem.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.