Bug Tracker

Modify

Ticket #8197 (closed bug: wontfix)

Opened 2 years ago

Last modified 14 months ago

.offsetParent() returns wrong element in Firefox

Reported by: jdege@… Owned by:
Priority: low Milestone: 1.next
Component: offset Version: 1.5
Keywords: Cc:
Blocking: Blocked by:

Description

.offsetParent() is supposed to return the nearest positioned element, where "positioned" means it has a css position attribute of "relative", "absolute", or "fixed".

The problem is that in Firefox "position:relative" is ignored, when applied to table elements. A <td> element is never "positioned", even if it does have a position:relative css attribute. Yet JQuery's .offsetParent() returns the <td>, and .offset() returns coordinates relative to the <td>.

In IE8, "position:relative" in a <td> is processed, .offsetParent() returns the <td> and .offset() returns coordinates relative to the <td>.

In other words, JQuery behaves the same for both browsers. But since Firefox is handling the <td> very differently, it shouldn't.

The result is that using .offset on elements within a position:relative <td> returns incorrect values, and attempts to place position:absolute elements based on those values will draw them in the wrong position.

Example:

 http://jsfiddle.net/K48r2/

Tested with:

JQuery version 1.5

JQuery version 1.4.4

Firefox 3.6.13 on Linux

Firefox 3.6.13 on Windows

IE 8.0.7600.16385 on Windows

Change History

comment:1 Changed 2 years ago by jitter

  • Priority changed from undecided to low
  • Resolution set to wontfix
  • Status changed from new to closed
  • Component changed from unfiled to offset

You really shouldn't be trying to position: relative a td, that doesn't make much sense.

Your test case already includes the correct way to go about this (including a div with position relative inside the td).

The CSS specification say the following in the  positioning schemes section:

The effect of 'position:relative' on table-row-group, table-header-group, table-footer-group, table-row, table-column-group, table-column, table-cell, and table-caption elements is undefined.

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.