Skip to content

Commit

Permalink
Fix test cases for bug #8316 fix.
Browse files Browse the repository at this point in the history
- Removed special page, just needed another test in the fixed offset tests

- Checks it's position related to scrolling
  • Loading branch information
timmywil committed Mar 31, 2011
1 parent 6c28a39 commit f9cc559
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 50 deletions.
6 changes: 3 additions & 3 deletions src/offset.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ if ( "getBoundingClientRect" in document.documentElement ) {
win = getWindow(doc),
clientTop = docElem.clientTop || body.clientTop || 0,
clientLeft = docElem.clientLeft || body.clientLeft || 0,
scrollTop = (win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ),
scrollLeft = (win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft),
scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop,
scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,
top = box.top + scrollTop - clientTop,
left = box.left + scrollLeft - clientLeft;

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

// need to be able to calculate position if either top or left is auto and position is either absolute or fixed
Expand Down
30 changes: 0 additions & 30 deletions test/data/offset/bug_8316.html

This file was deleted.

1 change: 1 addition & 0 deletions test/data/offset/fixed.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<body>
<div id="fixed-1" class="fixed"></div>
<div id="fixed-2" class="fixed"></div>
<div id="fixed-no-top-left" class="fixed"></div>
<div id="forceScroll"></div>
<div id="marker"></div>
<p class="instructions">Click the white box to move the marker to it.</p>
Expand Down
30 changes: 13 additions & 17 deletions test/unit/offset.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ testoffset("static", function( jQuery ) {
});

testoffset("fixed", function( jQuery ) {
expect(28);
expect(30);

jQuery.offset.initialize();

Expand Down Expand Up @@ -320,6 +320,17 @@ testoffset("fixed", function( jQuery ) {
ok( true, 'Fixed position is not supported' );
}
});

// Bug 8316
var $noTopLeft = jQuery('#fixed-no-top-left');
if ( jQuery.offset.supportsFixedPosition ) {
equals( $noTopLeft.offset().top, 1007, "Check offset top for fixed element with no top set" );
equals( $noTopLeft.offset().left, 1007, "Check offset left for fixed element with no left set" );
} else {
// need to have same number of assertions
ok( true, 'Fixed position is not supported' );
ok( true, 'Fixed position is not supported' );
}
});

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

testoffset("bug_8316", function( jQuery ){
expect(2);

var tests = [
{ id:'#elem', top: 100, left: 100 }
];

jQuery.each(tests, function(){
var el = jQuery(this.id);
el.offset({ top: this.top, left: this.left});
equals(Math.round(el.offset().top), this.top);
equals(Math.round(el.offset().left), this.left);
});
});

function testoffset(name, fn) {
function testoffset( name, fn ) {

test(name, function() {
// pause execution for now
Expand Down

0 comments on commit f9cc559

Please sign in to comment.