Skip to main content

Bug Tracker

Side navigation

#7885 closed bug (fixed)

Opened January 03, 2011 02:58AM UTC

Closed April 12, 2011 04:26AM UTC

Last modified March 09, 2012 01:33PM UTC

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:
Blocked by: Blocking:
Description

Applies to

FireFox 3.6.13

How to reproduce

1. jQuery 1.4.4

1. FireFox 3.6.13

1. 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);
Attachments (0)
Change History (7)

Changed January 03, 2011 03:05AM UTC by acc15 comment:1

Changed January 03, 2011 02:26PM UTC by addyosmani comment:2

A slightly cleaner version in jsFiddle Live Test Case

Changed January 08, 2011 10:48PM UTC by snover comment:3

resolution: → patchwelcome
status: newclosed

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.

Changed January 10, 2011 01:57AM UTC by jitter comment:4

component: unfiledmanipulation
milestone: 1.6

Changed January 15, 2011 01:11PM UTC by inukshuk comment:5

This is actually a great test case for #7730.

Possible patch here:

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

Changed April 12, 2011 04:26AM UTC by john comment:6

milestone: → 1.6
resolution: patchwelcome
status: closedreopened

Changed April 12, 2011 04:26AM UTC by john comment:7

priority: undecidedlow
resolution: → fixed
status: reopenedclosed