Bug Tracker

Ticket #7885 (closed bug: fixed)

Opened 4 years ago

Last modified 2 years ago

jQuery .offset doesn't property works when current offset is float (which is possible in FireFox)

Reported by: acc15 Owned by:
Priority: low Milestone: 1.6
Component: manipulation Version: 1.4.4
Keywords: Cc:
Blocking: Blocked by:

Description

Applies to

FireFox 3.6.13

How to reproduce

  1. jQuery 1.4.4
  2. FireFox 3.6.13
  3. Open test page

Test page:

<html>
<head>
<title>test</title>
<script type="text/javascript" src="jquery-1.4.4.js"></script>
</head>
<body>
	<div id="test" style="position:ablosute;background-color:blue;left:10.7432222px;top:10.532325px;width:100px;height:100px;">TEST</div>
	<script type="text/javascript">
		$(document).ready(function() {
			var expected = {left:100,top:100};
			$('#test').offset(expected);
			var actual = $('#test').offset();
			alert(expected.left == actual.left && expected.top == actual.top ? 'bug has been fixed' : 'bug still remains, expected [' + expected.left + '; ' + expected.top + 
				'], actual [' + actual.left + '; ' + actual.top + ']');
		});
	</script>
</body>
</html>

Workaround

use

$('#test').css(expected);

Change History

comment:1 Changed 4 years ago by acc15

comment:2 Changed 4 years ago by addyosmani

A slightly cleaner version in jsFiddle  Live Test Case

comment:3 Changed 4 years ago by snover

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

Related to 7730.

If Firefox decides to mangle the offset values there isn’t a lot that can be done. In any case, it’s not something that we are probably going to spend time on. Feel free to submit a patch that works consistently across all browsers without causing trouble with devices that support sub-pixel precision and we would be happy to consider it.

comment:4 Changed 4 years ago by jitter

  • Component changed from unfiled to manipulation
  • Milestone 1.6 deleted

comment:5 Changed 4 years ago by inukshuk

This is actually a great test case for #7730.

Possible patch here:

 https://github.com/jquery/jquery/pull/182

comment:6 Changed 3 years ago by john

  • Status changed from closed to reopened
  • Resolution patchwelcome deleted
  • Milestone set to 1.6

comment:7 Changed 3 years ago by john

  • Priority changed from undecided to low
  • Status changed from reopened to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.