@@ -41,6 +41,26 @@ var cachedScrollbarWidth, supportsOffsetFractions,
41
41
rpercent = / % $ / ,
42
42
_position = $ . fn . position ;
43
43
44
+ // Support: IE <=9 only
45
+ supportsOffsetFractions = function ( ) {
46
+ var element = $ ( "<div>" )
47
+ . css ( "position" , "absolute" )
48
+ . appendTo ( "body" )
49
+ . offset ( {
50
+ top : 1.5 ,
51
+ left : 1.5
52
+ } ) ,
53
+ support = element . offset ( ) . top === 1.5 ;
54
+
55
+ element . remove ( ) ;
56
+
57
+ supportsOffsetFractions = function ( ) {
58
+ return support ;
59
+ } ;
60
+
61
+ return support ;
62
+ } ;
63
+
44
64
function getOffsets ( offsets , width , height ) {
45
65
return [
46
66
parseFloat ( offsets [ 0 ] ) * ( rpercent . test ( offsets [ 0 ] ) ? width / 100 : 1 ) ,
@@ -243,7 +263,7 @@ $.fn.position = function( options ) {
243
263
position . top += myOffset [ 1 ] ;
244
264
245
265
// if the browser doesn't support fractions, then round for consistent results
246
- if ( ! supportsOffsetFractions ) {
266
+ if ( ! supportsOffsetFractions ( ) ) {
247
267
position . left = round ( position . left ) ;
248
268
position . top = round ( position . top ) ;
249
269
}
@@ -475,45 +495,6 @@ $.ui.position = {
475
495
}
476
496
} ;
477
497
478
- // fraction support test
479
- ( function ( ) {
480
- var testElement , testElementParent , testElementStyle , offsetLeft , i ,
481
- body = document . getElementsByTagName ( "body" ) [ 0 ] ,
482
- div = document . createElement ( "div" ) ;
483
-
484
- //Create a "fake body" for testing based on method used in jQuery.support
485
- testElement = document . createElement ( body ? "div" : "body" ) ;
486
- testElementStyle = {
487
- visibility : "hidden" ,
488
- width : 0 ,
489
- height : 0 ,
490
- border : 0 ,
491
- margin : 0 ,
492
- background : "none"
493
- } ;
494
- if ( body ) {
495
- $ . extend ( testElementStyle , {
496
- position : "absolute" ,
497
- left : "-1000px" ,
498
- top : "-1000px"
499
- } ) ;
500
- }
501
- for ( i in testElementStyle ) {
502
- testElement . style [ i ] = testElementStyle [ i ] ;
503
- }
504
- testElement . appendChild ( div ) ;
505
- testElementParent = body || document . documentElement ;
506
- testElementParent . insertBefore ( testElement , testElementParent . firstChild ) ;
507
-
508
- div . style . cssText = "position: absolute; left: 10.7432222px;" ;
509
-
510
- offsetLeft = $ ( div ) . offset ( ) . left ;
511
- supportsOffsetFractions = offsetLeft > 10 && offsetLeft < 11 ;
512
-
513
- testElement . innerHTML = "" ;
514
- testElementParent . removeChild ( testElement ) ;
515
- } ) ( ) ;
516
-
517
498
} ) ( ) ;
518
499
519
500
return $ . ui . position ;
0 commit comments