@@ -4,7 +4,7 @@ if ( !includesModule( "offset" ) ) {
4
4
return ;
5
5
}
6
6
7
- var alwaysScrollable ,
7
+ var alwaysScrollable , supportsFixedPosition , supportsScroll ,
8
8
forceScroll = supportjQuery ( "<div></div>" ) . css ( { width : 2000 , height : 2000 } ) ,
9
9
checkSupport = function ( assert ) {
10
10
@@ -14,13 +14,14 @@ var alwaysScrollable,
14
14
var checkFixed = supportjQuery ( "<div/>" )
15
15
. css ( { position : "fixed" , top : "20px" } )
16
16
. appendTo ( "#qunit-fixture" ) ;
17
- window . supportsFixedPosition = checkFixed [ 0 ] . offsetTop === 20 ;
17
+ supportsFixedPosition = checkFixed [ 0 ] . offsetTop === 20 ;
18
18
checkFixed . remove ( ) ;
19
19
20
20
// Append forceScroll to the body instead of #qunit-fixture because the latter is hidden
21
21
forceScroll . appendTo ( "body" ) ;
22
22
window . scrollTo ( 200 , 200 ) ;
23
- window . supportsScroll = document . documentElement . scrollTop || document . body . scrollTop ;
23
+ supportsScroll = ! ! document . documentElement . scrollTop ;
24
+
24
25
forceScroll . detach ( ) ;
25
26
26
27
// Support: iOS <=7
@@ -369,7 +370,7 @@ testIframe( "static", "offset/static.html", function( assert, $ ) {
369
370
} ) ;
370
371
} ) ;
371
372
372
- testIframe ( "fixed" , "offset/fixed.html" , function ( assert , $ , window ) {
373
+ testIframe ( "fixed" , "offset/fixed.html" , function ( assert , $ ) {
373
374
assert . expect ( 38 ) ;
374
375
375
376
var tests , $noTopLeft ;
@@ -392,15 +393,15 @@ testIframe( "fixed", "offset/fixed.html", function( assert, $, window ) {
392
393
] ;
393
394
394
395
jQuery . each ( tests , function ( ) {
395
- if ( ! window . supportsScroll ) {
396
+ if ( ! supportsScroll ) {
396
397
assert . ok ( true , "Browser doesn't support scroll position." ) ;
397
398
assert . ok ( true , "Browser doesn't support scroll position." ) ;
398
399
assert . ok ( true , "Browser doesn't support scroll position." ) ;
399
400
assert . ok ( true , "Browser doesn't support scroll position." ) ;
400
401
assert . ok ( true , "Browser doesn't support scroll position." ) ;
401
402
assert . ok ( true , "Browser doesn't support scroll position." ) ;
402
403
403
- } else if ( window . supportsFixedPosition ) {
404
+ } else if ( supportsFixedPosition ) {
404
405
assert . equal ( jQuery . isPlainObject ( $ ( this . id ) . offset ( ) ) , true , "jQuery('" + this . id + "').offset() is plain object" ) ;
405
406
assert . equal ( jQuery . isPlainObject ( $ ( this . id ) . position ( ) ) , true , "jQuery('" + this . id + "').position() is plain object" ) ;
406
407
assert . equal ( $ ( this . id ) . offset ( ) . top , this . offsetTop , "jQuery('" + this . id + "').offset().top" ) ;
@@ -429,7 +430,7 @@ testIframe( "fixed", "offset/fixed.html", function( assert, $, window ) {
429
430
] ;
430
431
431
432
jQuery . each ( tests , function ( ) {
432
- if ( window . supportsFixedPosition ) {
433
+ if ( supportsFixedPosition ) {
433
434
$ ( this . id ) . offset ( { "top" : this . top , "left" : this . left } ) ;
434
435
assert . equal ( $ ( this . id ) . offset ( ) . top , this . top , "jQuery('" + this . id + "').offset({ top: " + this . top + " })" ) ;
435
436
assert . equal ( $ ( this . id ) . offset ( ) . left , this . left , "jQuery('" + this . id + "').offset({ left: " + this . left + " })" ) ;
@@ -454,7 +455,7 @@ testIframe( "fixed", "offset/fixed.html", function( assert, $, window ) {
454
455
455
456
// Bug 8316
456
457
$noTopLeft = $ ( "#fixed-no-top-left" ) ;
457
- if ( window . supportsFixedPosition ) {
458
+ if ( supportsFixedPosition ) {
458
459
assert . equal ( $noTopLeft . offset ( ) . top , 1007 , "Check offset top for fixed element with no top set" ) ;
459
460
assert . equal ( $noTopLeft . offset ( ) . left , 1007 , "Check offset left for fixed element with no left set" ) ;
460
461
} else {
@@ -503,7 +504,7 @@ testIframe( "scroll", "offset/scroll.html", function( assert, $, win ) {
503
504
504
505
win . name = "test" ;
505
506
506
- if ( ! window . supportsScroll ) {
507
+ if ( ! supportsScroll ) {
507
508
assert . ok ( true , "Browser doesn't support scroll position." ) ;
508
509
assert . ok ( true , "Browser doesn't support scroll position." ) ;
509
510
0 commit comments