File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -23,8 +23,8 @@ jQuery.fn.offset = function( options ) {
23
23
24
24
docElem = doc . documentElement ;
25
25
26
- // Make sure we're not dealing with a disconnected DOM node
27
- if ( ! jQuery . contains ( docElem , elem ) ) {
26
+ // Make sure we have the API and we 're it's not a disconnected DOM node
27
+ if ( typeof elem . getBoundingClientRect === "undefined" || ! jQuery . contains ( docElem , elem ) ) {
28
28
return { top : 0 , left : 0 } ;
29
29
}
30
30
Original file line number Diff line number Diff line change @@ -15,6 +15,15 @@ test("empty set", function() {
15
15
strictEqual ( jQuery ( ) . position ( ) , undefined , "position() returns undefined for empty set (#11962)" ) ;
16
16
} ) ;
17
17
18
+ test ( "object without getBoundingClientRect" , function ( ) {
19
+ expect ( 2 ) ;
20
+
21
+ // Simulates a browser without gBCR on elements, we just want to return 0,0
22
+ var result = jQuery ( { ownerDocument : document } ) . offset ( ) ;
23
+ equal ( result . top , 0 , "Check top" ) ;
24
+ equal ( result . left , 0 , "Check left" ) ;
25
+ } ) ;
26
+
18
27
test ( "disconnected node" , function ( ) {
19
28
expect ( 2 ) ;
20
29
You can’t perform that action at this time.
0 commit comments