Skip to content

Commit ff06d41

Browse files
committed
Merge branch 'bug_8316' of https://github.com/timmywil/jquery into timmywil-bug_8316
2 parents 459bd7f + f9cc559 commit ff06d41

File tree

4 files changed

+17
-50
lines changed

4 files changed

+17
-50
lines changed

src/offset.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ if ( "getBoundingClientRect" in document.documentElement ) {
3737
win = getWindow(doc),
3838
clientTop = docElem.clientTop || body.clientTop || 0,
3939
clientLeft = docElem.clientLeft || body.clientLeft || 0,
40-
scrollTop = (win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ),
41-
scrollLeft = (win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft),
40+
scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop,
41+
scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,
4242
top = box.top + scrollTop - clientTop,
4343
left = box.left + scrollLeft - clientLeft;
4444

@@ -180,7 +180,7 @@ jQuery.offset = {
180180
curOffset = curElem.offset(),
181181
curCSSTop = jQuery.css( elem, "top" ),
182182
curCSSLeft = jQuery.css( elem, "left" ),
183-
calculatePosition = ((position === "absolute" || position === "fixed") && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1),
183+
calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1,
184184
props = {}, curPosition = {}, curTop, curLeft;
185185

186186
// need to be able to calculate position if either top or left is auto and position is either absolute or fixed

test/data/offset/bug_8316.html

Lines changed: 0 additions & 30 deletions
This file was deleted.

test/data/offset/fixed.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<body>
3636
<div id="fixed-1" class="fixed"></div>
3737
<div id="fixed-2" class="fixed"></div>
38+
<div id="fixed-no-top-left" class="fixed"></div>
3839
<div id="forceScroll"></div>
3940
<div id="marker"></div>
4041
<p class="instructions">Click the white box to move the marker to it.</p>

test/unit/offset.js

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ testoffset("static", function( jQuery ) {
265265
});
266266

267267
testoffset("fixed", function( jQuery ) {
268-
expect(28);
268+
expect(30);
269269

270270
jQuery.offset.initialize();
271271

@@ -320,6 +320,17 @@ testoffset("fixed", function( jQuery ) {
320320
ok( true, 'Fixed position is not supported' );
321321
}
322322
});
323+
324+
// Bug 8316
325+
var $noTopLeft = jQuery('#fixed-no-top-left');
326+
if ( jQuery.offset.supportsFixedPosition ) {
327+
equals( $noTopLeft.offset().top, 1007, "Check offset top for fixed element with no top set" );
328+
equals( $noTopLeft.offset().left, 1007, "Check offset left for fixed element with no left set" );
329+
} else {
330+
// need to have same number of assertions
331+
ok( true, 'Fixed position is not supported' );
332+
ok( true, 'Fixed position is not supported' );
333+
}
323334
});
324335

325336
testoffset("table", function( jQuery ) {
@@ -422,22 +433,7 @@ test("offsetParent", function(){
422433
equals( div[1], jQuery("#nothiddendiv")[0], "The div is the offsetParent." );
423434
});
424435

425-
testoffset("bug_8316", function( jQuery ){
426-
expect(2);
427-
428-
var tests = [
429-
{ id:'#elem', top: 100, left: 100 }
430-
];
431-
432-
jQuery.each(tests, function(){
433-
var el = jQuery(this.id);
434-
el.offset({ top: this.top, left: this.left});
435-
equals(Math.round(el.offset().top), this.top);
436-
equals(Math.round(el.offset().left), this.left);
437-
});
438-
});
439-
440-
function testoffset(name, fn) {
436+
function testoffset( name, fn ) {
441437

442438
test(name, function() {
443439
// pause execution for now

0 commit comments

Comments
 (0)